I noticed a strange problem after exportation of a Collada mesh description file in Blender.
Let's examine the context : I've created a very simple project on Blender concisting to apply a simple texture mapping on a plane.
Here's a screen of the output:
Here's a picture of the material configuration:
As you can see, the material diffuse components are all equal to 0.7 (Kd 0.7 0.7 0.7).
And finally the texture attached to the material:
It is named 'floor_COLOR.jpg'.
Now, here's the output file from Wavefront OBJ loader (the material part) first:
# Blender MTL File: 'bumped_plane.blend'
# Material Count: 1
newmtl PlaneMtl
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.70000 0.70000 0.70000 //Material diffuse components
Ks 0.889474 0.889474 0.889474
Ni 1.000000
d 1.000000
illum 2
map_Kd floor_COLOR.jpg
As you can see all the material data is respected at the texture level : we have the diffuse material components all equal to 0.7 and the diffuse map called 'floor_COLOR.jpg'.
Now let's have a look to a piece of code of the exported file from Collada exporter, but in a first time without texture (let's focus on the diffuse material components):
[...]
<diffuse>
<color sid="diffuse">0.7 0.7 0.7 1</color>
</diffuse>
[...]
As you can see I've correctly recovered all the diffuse material data.
But know if I export my file using texture mapping I have the following result:
[...]
<image id="floor_COLOR_jpg" name="floor_COLOR_jpg">
<init_from>floor_COLOR.jpg</init_from>
</image>
[...]
<diffuse>
<texture texture="floor_COLOR_jpg-sampler" texcoord="UVMap"/>
</diffuse>
[...]
Ok, I recovered the path and the type of my texture but where are the diffuse material components ??
For me, the result should be something like:
<diffuse>
<texture texture="floor_COLOR_jpg-sampler" texcoord="UVMap"/>
<color sid="diffuse">0.7 0.7 0.7 1</color>
</diffuse>
The diffuse phong shading equation is the following:
diffuse_color = gl_LightSource.diffuse * gl_FrontMaterial.diffuse * dot(NormalDir, LightDir)
diffuse_color *= fragment_color_from_diffuse_texture //Here 'floor_COLOR.jpg' (sampler2D)
where 'gl_FrontMaterial.diffuse' refers to diffuse material components (Kd)!
With this export I have the impression the equation should be like:
diffuse_color = gl_LightSource.diffuse * fragment_color_from_diffuse_texture * dot(NormalDir, LightDir)
But it's not correct!
So, why the diffuse material components have disappeared ?!
Thanks a lot in advance for your help!
It would appear that the exporter is designed that way. This may or may not match the collada file specifications. (I haven't read them)
In blender you can assign an image texture to influence the diffuse colour and control the mixture amount between the image and the diffuse colour. When exporting to collada an image effecting the diffuse colour in any amount is always exported as the only source of diffuse colour.
You may want to ask one of the developers that work on collada if this is intentional or submit a bug report if you believe it is incorrect.