Material woes...
by Joel Schilling · in General Discussion · 09/28/2009 (10:33 am) · 3 replies
So, I'm happily building my demo level in T3D using some models I purchased, and everything is going well. I have 4 different types of houses in my little village, and I go to add 3 more types, and city walls, and everything looks great. Then I close out the level and when I open it the first 4 houses have the texture of the wall, and look like crap. So I try changing the texture on the first 4 houses back, and then it ends up changing the other 3 house and the city walls when I reopen the level.
Looking more closely at the models with the material editor, I notice that the models are sharing materials. So, I start from scratch, making real sure that each of the models has its own set of materials, and I get back to the point where I had the 7 different houses and city walls and everything looks great. Then I close out the level and reopen it, and the first 4 houses have the city wall material on them again!
So I take a close look at the models in the material editor and each one has its own set of textures, and the textures are pointing at the correct TGA's, and yet it's still not rendering correctly. So I open up the material.cs files and take a look at it and it seems that each material in T3D gets mapped to a material designator in the Collada model. (Forgive me if I'm getting the terminology wrong, I'm kind of new to this) But the materials in the models use a number of the same material names like, "wd1", "wd2", "st1", etc. So I have a model called peasant_house and one called stone_house, each containing a material called "wd", and in T3D I have a material called peasant_house_wd mapping to the material "wd" in peasant_house, and a material called stone_house_wd mapping to the material "wd" in stone_house, but it seems the materials "wd" aren't mapped in a model scope, but a global scope, and the first one (or last perhaps) mapped is being applied to both.
I tried going in to 3ds Max, and renaming all the materials in the models to peasant_wd, peasant_wd1, etc. I even managed to find the submaterials. However when I export to Collada and bring it in to T3D, there are still materials in the model called "wd." I take a look at the Collada model, and sure enough there are elements in the XML with id of "wd". So I wonder if the material editor in T3D map not only to materials in the model, but surfaces, perhaps? I tried manually editing the .dae, since I don't know my way around 3ds Max that well, replacing every id and name of "wd" to "peasant_wd", and then the model won't load in T3D anymore.
Is this a bug, or am I doing something wrong? Is it reasonable to expect every single model you use to have a complete unique material/surface id, to prevent name collision? It seems to me that the mapping should be done on a per model basis. I would appreciate any advice on this to keep my materials of one house being applied to the other, because honestly I played around with this for a whole day, and just can't seem to have both models in the level at the same time and have each look good. (Well it does when you first put them in the level, but not after you save and reload.
Another material question in next post...
Looking more closely at the models with the material editor, I notice that the models are sharing materials. So, I start from scratch, making real sure that each of the models has its own set of materials, and I get back to the point where I had the 7 different houses and city walls and everything looks great. Then I close out the level and reopen it, and the first 4 houses have the city wall material on them again!
So I take a close look at the models in the material editor and each one has its own set of textures, and the textures are pointing at the correct TGA's, and yet it's still not rendering correctly. So I open up the material.cs files and take a look at it and it seems that each material in T3D gets mapped to a material designator in the Collada model. (Forgive me if I'm getting the terminology wrong, I'm kind of new to this) But the materials in the models use a number of the same material names like, "wd1", "wd2", "st1", etc. So I have a model called peasant_house and one called stone_house, each containing a material called "wd", and in T3D I have a material called peasant_house_wd mapping to the material "wd" in peasant_house, and a material called stone_house_wd mapping to the material "wd" in stone_house, but it seems the materials "wd" aren't mapped in a model scope, but a global scope, and the first one (or last perhaps) mapped is being applied to both.
I tried going in to 3ds Max, and renaming all the materials in the models to peasant_wd, peasant_wd1, etc. I even managed to find the submaterials. However when I export to Collada and bring it in to T3D, there are still materials in the model called "wd." I take a look at the Collada model, and sure enough there are elements in the XML with id of "wd". So I wonder if the material editor in T3D map not only to materials in the model, but surfaces, perhaps? I tried manually editing the .dae, since I don't know my way around 3ds Max that well, replacing every id and name of "wd" to "peasant_wd", and then the model won't load in T3D anymore.
Is this a bug, or am I doing something wrong? Is it reasonable to expect every single model you use to have a complete unique material/surface id, to prevent name collision? It seems to me that the mapping should be done on a per model basis. I would appreciate any advice on this to keep my materials of one house being applied to the other, because honestly I played around with this for a whole day, and just can't seem to have both models in the level at the same time and have each look good. (Well it does when you first put them in the level, but not after you save and reload.
Another material question in next post...
#2
10/01/2009 (5:09 pm)
just a heads up this type of question would be more readily answered in the private forums as not many T3D'rs really look around here very often. I believe there is a thread in there related to instancing, as well.
#3
Thanks for the tip, I will go ask on the private forums.
10/01/2009 (6:17 pm)
Well, I figured out the first question on my own... the second I'm still looking for. Just the term "instancing" may help me find what I need. I've tried everything from setSkinName to Cloaking, and I just can't seem to get it to work. Thanks for the tip, I will go ask on the private forums.
Torque 3D Owner Joel Schilling
But when I change the material on the second instance of the model it changes the first, which seems perfectly fine to me, since it seems the material mapping is on a model basis, not an instance of the model.
So my thought was to copy the .dae file and map the materials separately. (Though it does seem wasteful to have 10 of the same model to apply 10 different materials.) However if I just copy the model, then the materials will have the same names, and I will run into the same issue as the above post.
Is there some other technique of placing NPC's in the world other than putting them in as static shapes that allows you to specify the texture for the model? Or is it something that I may have to write in C++ myself?
Help on the issues would be greatly appreciated, because I am getting a bit frustrated about materials.