Collada-related stuff
Posted: 08 Aug 2021, 13:30
I'll dump a few Collada findings here in case someone runs into the same problems.
1) Dark textures or pitch black shadow areas in objects (lambert shader)
In files that use <lambert> shader, I believe, made with some version of Blender's default exporter. Emission values may be left 0. This depends on Blender version, but in case the models seem black, setting emission values above 0 can change the shadowed areas being not pitch black, but rather something that has at least some lighting. Ambient-values aren't set at all by the default exporter, even though OSG's dae plugin does seem to support it (it may be worth adding <ambient></ambient> tags, and playing with the values).
In collada file:
2) Dark textures or pitch black shadow areas in objects (blinn shader)
Better Collada Export, especially the OpenMW-special edition of this, uses COLLADA's common profile, <blinn> shader setup. Exporter creates <ambient> values, but may fail to set them to useful values (likely depends on Blender version and exporter). Setting emission color to 0.1...0.2 range and/or ambient color to 0.4...0.6 range may required to fix the dark texture coloring.
3) "Failed to find matching <bind_vertex_input> for CHANNEL1" console error and lighting problems
This error message is prevalent with Better Collada Exporter files. It occurs when instance_material tag is empty. I haven't looked too deep into the correct implementation, but something like this fixes the error message, and results in correct(ish) rendering:
edit: Please also note, I'm using a OSG-version with the following uniforms forced (at line 382, daeRMaterials.cpp), just in case they are required...
edit2: The above addUniforms are indeed compulsory. It may be worth adding those to OpenMW Collada loading phase. For the darkness, emissiveMult may be the most important!
1) Dark textures or pitch black shadow areas in objects (lambert shader)
In files that use <lambert> shader, I believe, made with some version of Blender's default exporter. Emission values may be left 0. This depends on Blender version, but in case the models seem black, setting emission values above 0 can change the shadowed areas being not pitch black, but rather something that has at least some lighting. Ambient-values aren't set at all by the default exporter, even though OSG's dae plugin does seem to support it (it may be worth adding <ambient></ambient> tags, and playing with the values).
In collada file:
Code: Select all
<lambert>
<emission>
<color sid="emission">0.2 0.2 0.2 1</color>
</emission>
...
Better Collada Export, especially the OpenMW-special edition of this, uses COLLADA's common profile, <blinn> shader setup. Exporter creates <ambient> values, but may fail to set them to useful values (likely depends on Blender version and exporter). Setting emission color to 0.1...0.2 range and/or ambient color to 0.4...0.6 range may required to fix the dark texture coloring.
3) "Failed to find matching <bind_vertex_input> for CHANNEL1" console error and lighting problems
This error message is prevalent with Better Collada Exporter files. It occurs when instance_material tag is empty. I haven't looked too deep into the correct implementation, but something like this fixes the error message, and results in correct(ish) rendering:
Code: Select all
<instance_material symbol="id-trimat-13" target="#id-material-7">
<bind_vertex_input semantic="CHANNEL1" input_semantic="TEXCOORD" input_set="0"/>
</instance_material>
Code: Select all
float emissiveMult = 1.f;
ss->addUniform(new osg::Uniform("emissiveMult", emissiveMult));
ss->addUniform(new osg::Uniform("envMapColor", osg::Vec4f(1,1,1,1)));
ss->addUniform(new osg::Uniform("useFalloff", false));