Hi,

> 5. Because the technique depends on the usage of a vertex shader I would add 
> two static methods one returns a basic osg::Program with phong shading and 
> another one only returns the shader code with the necessary uniforms and a 
> vertex quantization function that should be used in the shader. 


Maybe there's an interesting idea in osgEarth : the use pseudo-loaders to 
create library-specific objects. It's possible to write a plugin which create 
shaders in the following way, by mapping "popgeometry" file extension to a 
pseudo-loader. The file name let you know the shader type :


Code:
osg::Shader* vertexShader = osgDB:readShaderFile("vertexShader.popgeometry")
osg::Shader* fragmentShader = osgDB:readShaderFile("fragmentShader.popgeometry")




You can create osg::Node, osg::Shader or any osg::Object subclass with a 
plugin, and even add parameters, in the filename or in the "options" parameters 
:


Code:
osg::Shader* vertexShader = 
osgDB:readShaderFile("vertexShader.lod1.popgeometry")
osg::Shader* vertexShader = 
osgDB:readShaderFile("vertexShader.lod2.popgeometry")
osg::Shader* vertexShader = 
osgDB:readShaderFile("vertexShader.lod3.popgeometry")
osg::Shader* fragmentShader = 
osgDB:readShaderFile("fragmentShader.phong.popgeometry", options)
osg::Shader* fragmentShader = 
osgDB:readShaderFile("fragmentShader.flat.popgeometry", options)
osg::Shader* fragmentShader = 
osgDB:readShaderFile("fragmentShader.debug.popgeometry", options)




Have a look here, there is a list of all "factory" methods available to plugins 
: 
http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01311.html#a78e08a10faa6c81a5c255d14f7c30cd7

And the base class for the plugins : 
http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00658.html

To write a new plugin, an easy way is copy/paste the "ReaderWriterOBJ.cpp" file 
from the "obj" plugin, in "ReaderWriterPopGeometry.cpp" and replace all the 
code/parameters related to "obj" file format by code to handle "PopGeometry" 
objects creation (not from actually files, but using "options" parameters and 
your algorithms)


Aurelien

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59104#59104





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to