- Home /
Collada import material Main Colors
I'm importing some trivial test cases of collada in to Unity 3.4 and finding an issue with the material generation. My test scene has some simple cubes with two textures on them. Unity loads these textures in fine but the Main color it assigns to the material seems random and on large imports its quite often (0,0,0) and this is blended with the texture making the entire scene black. On the test cubes the Main color is (204,204,204) but i've seen other values as if its a wild internal variable.
Now the really interesting thing is, if i hack the collada to generate a phong diffuse color AND texture on the same material it works and i can control the material color with the tag and the texture works as expected two and they blend as expected. The problem is this is not valid collada and other collada importers do not like this and fail to display textures and materials etc.
So with a partial example the following is correct collada but results in a seemingly random Main Material color
<phong>
<emission>
<color>0 0 0 1</color>
</emission>
<ambient>
<color>0 0 0 1</color>
</ambient>
<diffuse>
<texture texture="tex-89556747-24cb-43e-sampler" texcoord="CHANNEL1"/>
</diffuse>
<specular>
<color>0 0 0 1</color>
</specular>
<shininess>
<float>0</float>
</shininess>
<index_of_refraction>
<float>1</float>
</index_of_refraction>
</phong>
Where as if we break the collada spec and do (note the extra color on the diffuse) :-
<phong>
<emission>
<color>0 0 0 1</color>
</emission>
<ambient>
<color>0 0 0 1</color>
</ambient>
<diffuse>
<texture texture="tex-89556747-24cb-43e-sampler" texcoord="CHANNEL1"/>
<color>1 1 1 1</color>
</diffuse>
<specular>
<color>0 0 0 1</color>
</specular>
<shininess>
<float>0</float>
</shininess>
<index_of_refraction>
<float>1</float>
</index_of_refraction>
</phong>
Unity is very happy with it.
So, is there any other way to set this Material Base Color when importing, doing it by hand is not a real option as this process may be repeated for hundreds of materials on many scenes. But i wonder if there is some other collada field that unity uses.
It appears this is a bug in the importer and that unity is looking always for a diffuse color and if it is actually a texture this value becomes wild and can be anything from 0 - 255. If this is a bug it would be nice to fix it by defaulting the color to 255 and still accepting this invalid collada as its actually quite helpful to be able to tint textures this way from the collada.
I can send/paste some complete trivial collada examples if anyone would like them to test
Many thanks
Robin
Your answer
Follow this Question
Related Questions
Collada Import and shared materails 2 Answers
COLLADA import with textures 3 Answers
Updating UV in imported mesh without having to re-material 0 Answers
Importing meshes with materials or assigning in unity 1 Answer
unity 2020 preserve full collada names 0 Answers