Planetside Software Forums

General => Terragen Discussion => Topic started by: Asterlil on April 05, 2019, 01:14:28 PM

Title: Duplicated materials when importing obj
Post by: Asterlil on April 05, 2019, 01:14:28 PM
(http://www.lilatladera.com/Terragen/dupNodes.jpg)

I was exploring the materials node network for my dojo structure and noticed that the same material gets duplicated several times. The image shows one example, where the glass in different windows has been given a unique shader; there are others, and it makes a long list of nodes even longer. What is the best practise here? Can I pull all these nodes together? Can I point one shader node (a red box) to the three shaders (white boxes) and delete the orphaned red boxes?

Question framed as only a noob can.  :P
Title: Re: Duplicated materials when importing obj
Post by: midnight.mangler on April 05, 2019, 01:16:56 PM
Nothing wrong with being a noob, my fellow noob! :) I am too noobish to offer seasoned advice but I post here in the spirit of noob solidarity!
Title: Re: Duplicated materials when importing obj
Post by: Asterlil on April 05, 2019, 01:36:03 PM
Well, thank Bob I'm not the only one here! I've been feeling quite abashed by the fantastic images these seasoned entities have been posting.
Title: Re: Duplicated materials when importing obj
Post by: jaf on April 05, 2019, 02:00:33 PM
Like this:
Title: Re: Duplicated materials when importing obj
Post by: cyphyr on April 05, 2019, 03:04:11 PM
I have noticed that if I export an obj from Lightwave I get all the shaders from any other objects that are also open in Lightwave at the same time.

The only solution I know is to only ever have the one object open in Lightwave when I export.
Obviously I don't know what you are exporting or editing your obj's in but simplifying the obj's and their mat files should happen in that package and not in Terragen.
Title: Re: Duplicated materials when importing obj
Post by: digitalguru on April 05, 2019, 04:23:03 PM
This also happens in Maya.

You can just edit the .mtl file in a text editor. If you open it you'll see the list of materials associated with the obj (and usually a list of all materials in the scene)

Quotenewmtl farmHouse_glass_SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 0.20 0.20 0.20
Ni 1.00
Ks 0.50 0.50 0.50
newmtl iceHouse_frame_SG
illum 4
Kd 0.03 0.03 0.03
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
newmtl iceHouse_glass_SG
illum 4
Kd 0.21 0.17 0.09
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
newmtl initialShadingGroup
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00

just delete all but the one you need:

Quotenewmtl farmHouse_glass_SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 0.20 0.20 0.20
Ni 1.00
Ks 0.50 0.50 0.50

You can also edit an .obj file in a text editor to point it at a different .mtl file if you want:

Quote# This file uses centimeters as units for non-parametric coordinates.

mtllib grass_vp_scaled.mtl
g default
v -0.006589 0.000000 -0.018105
v -0.005733 0.000010 -0.018242
v -0.007263 0.017582 -0.027499
v -0.008287 0.017641 -0.027373...
Title: Re: Duplicated materials when importing obj
Post by: sboerner on April 05, 2019, 04:51:34 PM
Quotejust delete all but the one you need

I would exercise some caution here. Shading groups are baked into the mesh when you export the obj file, so deleting shading group references in the mtl file could leave you with some orphaned polys. Correct?

Better to clean up the shading groups and materials in the source application, be it Maya or whatever, before exporting.
Title: Re: Duplicated materials when importing obj
Post by: digitalguru on April 05, 2019, 05:17:02 PM
QuoteBetter to clean up the shading groups and materials in the source application, be it Maya or whatever, before exporting.

Always good to have a well-organized scene to export from, with shaders named appropriately, just make a copy of the .mtl first before editing if you're unsure.

Quoteso deleting shading group references in the mtl file could leave you with some orphaned polys. Correct?

If you know the material listed is not attached to your exported object, (but happens to be in your scene) it's safe to delete

Just to clarify though, one exported .obj could have several materials attached, so you just have to make a note or name them all appropriately so you can find them easily.



Title: Re: Duplicated materials when importing obj
Post by: Asterlil on April 05, 2019, 07:50:56 PM
This is all useful stuff.

I did go through the materials for each sub-mesh before exporting the structure as an obj; in Blender, the widget appears to treat each instance of, say, "basic white", as a new material when it encounters it in subsequent sub-meshes. With Blender it's good practice to re-use a material wherever practical; in future, for export purposes, I'll bear this experience in mind and propagate unique names that identify the sub-mesh they belong to.

And yes, if I had any other scene elements in the mother file, they would have been incorporated into the obj export, which I found out the hard way.

My dojo has a number of procedural wood materials, none of which were exported as anything but solid colors. Has anyone got any recommendations for a fractal that replicates wood grain?
Title: Re: Duplicated materials when importing obj
Post by: Oshyan on April 05, 2019, 11:35:53 PM
There are some some procedural wood shaders here in the forums:
https://planetside.co.uk/forums/index.php/topic,24690.msg253894.html#msg253894
One here:
http://www.store.nwdastore.com/terragen-materials-pack
And NWDA used to have another one from DandelO, maybe they've got it in an archive somewhere?
Found all these looking for "Wood" in the File Sharing area of the forums. :)

- Oshyan
Title: Re: Duplicated materials when importing obj
Post by: Dune on April 06, 2019, 02:10:54 AM
I often use Poseray to organize my parts and materials; copying materials to parts, so all parts that have the same texture are now combined.

And with the procedural wood you have to separate the parts in such a way that any Y stretched textures are not on X/Z stretched planks, and such, but that's logical. And not use world position.