Duplicated materials when importing obj

Started by Asterlil, April 05, 2019, 01:14:28 PM

Previous topic - Next topic

Asterlil



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

midnight.mangler

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!

Asterlil

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.

jaf

(04Dec20) Ryzen 1800x, 970 EVO 1TB M.2 SSD, Corsair Vengeance 64GB DDR4 3200 Mem,  EVGA GeForce GTX 1080 Ti FTW3 Graphics 457.51 (04Dec20), Win 10 Pro x64, Terragen Pro 4.5.43 Frontier, BenchMark 0:10:02

cyphyr

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.
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

digitalguru

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...

sboerner

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.

digitalguru

#7
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.




Asterlil

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?

Oshyan

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

Dune

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.