Hi Robert Osfield et. al., On 14.1.2016 16:34, Robert Osfield wrote:
I'm still open to making the shader parsing extensible, it seems like an interesting experimental tool.
As Sebastian already pointed out, the actual parsing can be done outside osg, perhaps before Shader::setShaderSource() call or at some already provided callback. In my opinion, it is more interesting to have a spot where all the necessary information for the preprocessing step converge, so that at this point user can regain some useful control over the shader composition. I was going through a Shader.cpp to find a spot/function where all the information needed for the shader composition is at hand. Unsurprisingly, that function turned out to be void PerContextShader::compileShader(osg::State& state);. The PerContextShader::compileShader() does all the preprocessing on a shader source, like state.convertVertexShaderSourceToOsgBuiltIns(), insertion of the #version, inserting line numbers for debug purposes and generates the define string based on current define set found in osg::State. The PerContextShader::compileShader() is a function of an internal class but the osg::Shader::compileShader(osg::State& state) (which calls PerContextShader::compileShader()) isn't. That being said, minimum work required to provide some degree of extensibility is to simply make osg::Shader::compileShader(osg::State& state) virtual. Thoughts? Cheers, Robert Milharcic _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

