HI Aurelien, Wow, sounds like a big step, can't believe you've already coded up a solution :-)
I haven't had a chance to review your changes yet but in principle it sounds like the approach is solid and will be compatible with the shader composition pipeline as well as opening the door for better support for using standard fixed function style built-ins. The only parts I'd query about is the removal of existing methods as these could break the build, I understand the motivation behind removing the old API's because there can be abused and have users end up with an inconsistent state in the scene graph. When I do a full review I'll consider on a case by case basis whether it's appropriate right now to remove these API's. FYI, it's half term holidays for my children this week so I'll be working part time this week, and playing for the rest :-) Cheers, Robert. On 11 February 2013 15:02, Aurelien Albert <[email protected]> wrote: > Hi, > > I'm working on a OpenGL 3 application and facing some problems with osg/fixed > pipeline attributes/uniforms. > > To solve this in a "generic" way, here is my submission, which contains > xxxxxxxx parts. The main idea is to provide access to deprecated > fixed-pipeline data (gl_material, etc...) using built-in uniforms. > > This is probably the first step before providing access to deprecated > functions (the whole fixed pipeline execution). > > 1/ Part 1 : > > Removed in osg::State : > - setUseModelViewAndProjectionUniforms / getUseModelViewAndProjectionUniforms > => now use flags instead of a boolean > > Added in osg::State : > - an enum to specify which built-in uniforms you want > - setActiveBuiltInUniforms which takes flags as argument > - setConvertShaderSourceForVertexAttributeAliasing to activate the vertex > shader source code automatic conversion > - built-in uniforms for more matrices > - added the methods to manage built-in matrices uniforms update and apply : > void applyBuiltInMatrixUniformsIfRequired(); > void updateBuiltInMatrixUniformsIfRequired(unsigned int > buildInMatrixUniformsToUpdate); > void resetBuiltInMatrixUniforms(); > > Default values should be equivalent to previous revision : > - use only some matrix builtin uniforms > - automatically convert vertex shader source code if vertex attribute > aliasing is active > > > 2/ Part 2 : > > Removed in osg::StateSet : > - the method getAttributeList() which return non-const reference > - the method getTextureAttributeList() which return non-const reference > - the method getUniformList() which return non-const reference > > => this is to avoid attribute or uniforms list modification without the > StateSet knows it > > Added in osg::StateSet : > - getUniformListToApply which returns the list of uniforms to be applied, > including active builtin uniforms and user-added uniforms > - updateUniformListToApply which updates the list returned by > "getUniformListToApply" method > > Added in osg::StateAttribute : > - method getBuiltInUniforms() to return the list of builtin uniforms > associated with this state attribute > > Other modifications in osg::StateSet : > - all methods which modify the attributeList, the textureAttributeList or > the uniformList now call "updateUniformListToApply" to keep this list in sync > > Other modifications in osg::State : > - all code which looks like : > > applyUniformList(_uniformMap,dstate->getUniformList()); > > is converted to : > > > applyUniformList(_uniformMap,dstate->getUniformListToApply(_activeBuiltInUniforms)); > > > 2/ Part 3 : > > Updated osg::Material to return new built-in uniform if activated by the > flags : > > osg_FrontMaterial.colorMode > osg_FrontMaterial.ambient > osg_FrontMaterial.diffuse > osg_FrontMaterial.specular > osg_FrontMaterial.emission > osg_FrontMaterial.shininess > > and > > osg_BackMaterial.colorMode > osg_BackMaterial.ambient > osg_BackMaterial.diffuse > osg_BackMaterial.specular > osg_BackMaterial.emission > osg_BackMaterial.shininess > > Updated other files to reflect small API changes (mainly the removal of > "non-const" getAttributeList method) : > osgAnimation/LinkVisitor.cpp > osgDB/SharedStateManager.cpp > osgUtil/GLObjectsVisitor.cpp > osgUtil/IncrementalCompileOperation.cpp > osgUtil/Optimizer.cpp > osgUtil/RenderLeaf.cpp > > > > > With this, we get : > > - same as before if "setActiveBuiltInUniforms" is set to None > - activable one-by-one builtin uniforms, configured via the State class > - a little CPU overhead, but only when a StateSet is modified (which should > not happen very often for a lot of StateSet) > - a bigger CPU overhead, but only when active built-in uniform flags are > modified on the State > - built-in uniforms can be added to any StateAttribute sub-class by modifying > only this sub-class > - built-in uniforms acts as standard uniforms : inherited, protected... > - built-in uniforms are *really* built-in : there is no method to get/set it > from outside a StateAttribute class and all algorithms doesn't know about > them : the only know about the "uniformList" > > I think this is a big modification, but can be very usefull to get access to > more data in GLSL code and this is a first step to get a full OpenGL 3 core > profile OSG working. > > And just to let you know, I plan to add these kind of uniform for : > - other deprecated data : lightmodel, light... > - usefull extra data : viewport extends and matrix... > > > > Aurelien > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=52536#52536 > > > > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
