[osg-users] Multipass shading/rendering

Art Tevs stud_info2 at yahoo.de
Wed Sep 12 07:21:09 PDT 2007


Hi Chris,

I have already implemented the things your are
speaking about. I am calling it osgPPUG: stands for
osg post processing unit graph. There I can build up a
graph of post processing units (rtt quads) which can
do single/multipass, single or multiple rendering
targets for inputs and outputs and other cool things.
The osgPPUG is designed to be extendable, so that new
ppus could be written as plugins.


I have presented an overview about them on the osg BOF
at Siggraph last month. I promised to make a node kit
of them so that it could be used by everyone. However
I still do not get enough time to prepare the code to
put it online.

The code still use some parts of my application, which
can be safely removed, but the code has to be
rewritten. If you like to help me in preparing the
node kit, so I would be very appreciated ;-) Otherwise
you have either to wait until I publish this as a node
kit, or write it on your own.

Of course for more question about this, just contact
me.

To answer your question: More code is required to see
what happens. It could be that you do not properly
connected shaders with input and output textures. But
I have to take a look into the code.

Cheers, Art




--- hellhound at binary-revolution.org schrieb:

> Hi,
> 
> I need to implement some post processing shader
> effect, based on multipass 
> shading/rendering processes. In thiss multipass
> process each shader could have one or more RTT
> targets as input and output of the pass.
> 
> To realize this i've implemented a render to texture
> class based on the 
> osgprerender and osgtexturerectangle examples. This
> class creates for each
> instance a texture rectangle and a FBO POST-Process
> camera by this way:
>  
> void createCamera(osg::ref_ptr<osg::Node> subGraph,
> unsigned int passPos)
> { 
>     m_camera = new osg::Camera;
>     m_camera->setName("rttCamera");
>     m_camera->setClearColor(m_clearColor);
>     
>    
>
m_camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
>    
> m_camera->setViewMatrix(osg::Matrix::identity());
>    
> m_camera->setViewport(0,0,windowWidth,windowHeight);
>     
>     // define orthogonal projection
>     
>
m_camera->setProjectionMatrix(osg::Matrix::ortho2D(0,windowWidth,0,windowHeight));
>     
>     // bind camera as POST-Process Camera with the
> position value of the pass
>    
> m_camera->setRenderOrder(osg::Camera::POST_RENDER,
> passPos);
>     
>     // add subcene to camera to render
>     m_camera->addChild(subGraph.get());
> } 
> 
> The initialized camera is a member of type
> osg::ref_ptr<osg::Camera> and the
> passPos Parameter defines the pass of the shader. 
> 
> Each pass is handled as single
> osg::ref_ptr<osg::StateSet> in a specialised 
> pass class. For each pass i define the referenced
> shader and textures which 
> depends on. So that i have the following object tree
> structure:
> 
> osg::Geometry
>       osg::Texture2D  "Decal"    
>       osg::Texture2D  "Normal"
> 
>       RTT next (my RTTclass)
>           RectangleTexture 
>           Camera (PRE)
> 
>       RTT prev(my RTTclass)
>           RectangleTexture 
>           osg::CameraNode (PRE) 
> 
>       Pass1 "Dot3" (Main)
>           StateSet
>              Program
>              ShaderV
>                  Attributes
>                  Uniform
>                  Uniform
>              ShaderF
>                  Uniform
>                  Uniform
>              <-- Decal   (in)
>              <-- Normal  (in)
>              --> Next    (out)    
> 
>       Pass2 
>           StateSet
>              Program
>              ShaderV
>                  Attributes
>                  Uniform
>                  Uniform
>              ShaderF
>                  Uniform
>                  Uniform
>              <-- Next     (in)
>              --> Prev     (out to screen (texturized
> quad))
> 
> This works fine, if i use only a single pass shader.
> In this case the RTT 
> Texture is rendered to a texturized quad in front of
> the view. If i use this
> RTT as input for the second path, and try to render
> the output of the second
> rtt on the textured quad nothing is shown where the
> textured quad should be...
> 
> I have no idea what could be wrong or what i've
> overseen... Perhaps i made 
> somthing conceptionally wrong. Has anyone
> implemented a multipass shadering
> with osg and could me push to the correct sollution?
> 
> If you required more code, i will append if i am
> back from work...
> 
> Thanks in advance,
> best regards
> Chris
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 



      Wissenswertes für Bastler und Hobby Handwerker. BE A BETTER HEIMWERKER! www.yahoo.de/clever



More information about the osg-users mailing list