Hi,
I have tried to use GLSL and OSG to do computation, but a problem turned out. I 
have
worked for it for a few days,however I still can solve it.
First, I will do some computation in Fragment Shading code, the result is float 
type
,and it will be passed to CPU, so the Rendering To Texture method is used. 
However the
result got is clamped in the range of 0-1,which is not the result I want.
the fragment shading code is samplified as following

Code:

void main()
{
        gl_FragColor=vec4(25.0,200.0,55,0.0);
}



the critical part code of rendering to texture is as following

Code:

        osg::ref_ptr<osg::Image> image = new osg::Image;
        image->allocateImage(100,100,1,GL_RGBA,GL_FLOAT);
        image->setInternalTextureFormat(GL_RGBA32F_ARB);
        Camera *camera=view->getCamera();
        camera->setClearMask(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
        camera->setClearColor(Vec4(0,0,0,0));
        camera->setViewport(0,0,100,100);
        camera->setRenderOrder(osg::Camera::PRE_RENDER);
        camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
        camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
        camera->attach(osg::Camera::COLOR_BUFFER,image);



In order to check the result,I use the following code
  float *data =(float *)(image->getDataPointer());
Part of the results is followed,I really do know what's wrong with it.
0.71764708
0.71764708
0.71764708
1.0
0.71764708
0.71764708
0.71764708
1.0
... 

Thank you!

Cheers,
wanghao[/quote]

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





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

Reply via email to