Hello forum,

I am trying to render the whole scene in a texture and then i shall send the
texture through a fragment program for post processing and then render this
texture
in a screen aligned quad. In some previous posts Robert suggested to look
into the osgdistortion program, and now i am trying to render the initial
scene(the animated one) to a texture and again render that scene  to  the
texture aligned quad without any shader pass through. I did some minor
changes in the osgdistortion example, but i am getting a blank screen. The
changes that i have done are as follows:



inside the createDistortedSubGraph(osg::Node *node, osg::Camera *cam) i am
doing the following:


**************************************************'

1. Create a group node - distortionNode.

2. Get the viewport from the camera.

3. Get the width and height from the viewport.

4. Define a 2D texture with the width and height that i got. Textures's
other parameters are just the same as provided in the osgdistortion.

5. Then i define the camera to render to the texture.

    5.1. camera->setReferenceFrame(osg::Transform::RELATIVE_RF);
    5.2. Set the projection  and view matrix to identity matrix.
    5.3. Set  the viewport of the camera with the width and height.
    5.4. camera->setRenderOrder(osg::Camera::PRE_RENDER);
    5.5.
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
    5.6. camera->attach(osg::Camera::COLOR_BUFFER_BIT,texture.get());
    5.7. camera->addChild(node);
    5.8. distortionNode->addChild(camera.get());




//then create the HUD camera

6. Create a geometry.
7. Define the primitive set to  be a QUAD.
8. Define the vertex array.
    8.1 Vertex array contain the following values. (I think this where i did
something wrong)
           8.1.1.
vertices->push_back(0,0,0); vertices->push_back(width,0,0);
vertices->push_back(width,0,height);vertices->push_back(0,0,height);
9 Define the texture array.
    9.1 Texture array contain the following values:
           9.1.1.
texcoords->push_back(osg::Vec2(0,0));
texcoords->push_back(osg::Vec2(width,0));
texcoords->push_back(osg::Vec2(width,height));
                     texcoords->push_back(osg::Vec2(0,height));
10. Create the geode and add all the geometry

************************************************'**



The rest is same as in oggdistortion. Any hint would be very helpful.


Regards
Sajjad
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to