[osg-users] Multipassshading in OSG v1.2

Christian Heine Hellhound at binary-revolution.org
Thu Oct 11 07:55:10 PDT 2007


Hi Sven,
i must agree Gerrick, one possible way to implement a multipass shading
in OSG is using the osgFX libary. It's stable and work well, but i think
a big disadvantage of this libary is the inflexibility. Each Shader you
will have to bind must be implemented separatly by overwriting special
traverse methods. If you want to be more flexible, it's up to you, to
make it possible.

Actually i work on a more flexible approach (many other members too),
which should allow to get this flexibility by using configuration files.
This way is not easy but possible. If you look in the threads of this
month, you can find one post of me with all sources of the actually test
code. My code works, but i have some trouble with the RTT cameras. Fell
free to check my sources, perhaps it could push you on the right track,
if you want to make your own solution.

Best regards,
Christian


Gerrick Bivins wrote:
> I think osgFX is where you want to look. That nodekit has some classes
> Technique, Effect etc that allow you to define multiple passes. I
> haven't used it personally but a developer in our group has used it
> quite a bit. If you look at  osgfxbrowser example, I think it has
> sample code but I'm not sure if it shows how to do multipass.
>
> On 10/11/07, *Swen Walkowski* <usedformailinglists at googlemail.com
> <mailto:usedformailinglists at googlemail.com>> wrote:
>
>     Hello all,
>
>     i try to do Multipassshading in OSG v1.2.
>     I have written my own shader class in the class I use the osg::shader
>     for shading. At the time my shading code looks like that:
>     Shader::Shader(void) {
>     //creating program
>     program = new osg::Program;
>
>     //creating shader
>     vertShader = new osg::Shader(osg::Shader::VERTEX);
>     fragShader = new osg::Shader(osg::Shader::FRAGMENT);
>     }
>
>     Shader::~Shader(void) {
>     }
>
>     void Shader::apply(osg::StateSet& state) {
>     state.setAttributeAndModes(program, osg::StateAttribute::ON);
>
>     vertShader->loadShaderSourceFromFile("shaders/Fixed_Functionality.vert");
>     fragShader->loadShaderSourceFromFile("shaders/Fixed_Functionality.frag");
>
>     program->addShader(vertShader);
>     program->addShader(fragShader);
>
>     //parameterize the shader with video texture (0 by default)
>     state.addUniform(new osg::Uniform("texture", 0));
>
>     posXUniform = new osg::Uniform("posX", (float)0.0);
>     posYUniform = new osg::Uniform("posY", (float)0.0);
>     intensityUniform = new osg::Uniform("intensity", (float)1.0);
>     radiusUniform = new osg::Uniform("radius", (float)0.2);
>
>     state.addUniform(posXUniform);
>     state.addUniform(posYUniform);
>     state.addUniform(intensityUniform);
>     state.addUniform(radiusUniform)
>     }
>
>     That works well.
>
>     Now i try to add an secend shading pass. I have read a lot over
>     rendering to texture (RTT) in OSG in the mailinglist. So I tryed to
>     find the examples or something in the OSG documentation.But without
>     luke.
>
>     Hope someone can tell me were I find the documentation for
>     Multipassshading in OSG or an example or maybe how it works.
>
>     Thangs,
>     Swen
>     _______________________________________________
>     osg-users mailing list
>     osg-users at lists.openscenegraph.org
>     <mailto:osg-users at lists.openscenegraph.org>
>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   




More information about the osg-users mailing list