[osg-users] Render To Texture attached Image do not support RGBA32 format, value clamped to 1!
J.P. Delport
jpdelport at csir.co.za
Thu Jul 3 00:07:48 PDT 2008
Hi,
I have just edited osgmultiplerendertargets example and can confirm you
can get values > 1.
In the example, search for e-12 and change to e12 in the shader.
Run with:
osgmultiplerendertargets --hdr --image.
You will see that it prints values > 1.
jp
hesicong2006 wrote:
> Hi, Robert:
> I'm now writing shader to compute world coordinate of the scene and
> save them as image. The value output by shader will exceed 1 and require
> float values, so I use GL_RGBA32F_ARB for RTT texture. Since I must save
> them to an image, I must allocate a Image and attach it to the texture.
> My texture setup code is :
>
> osg::ref_ptr<osg::Texture2D> texture=new osg::Texture2D();
>
> osg::ref_ptr<osg::Image> image=new osg::Image;
> image->allocateImage(1024,768 , 1, GL_RGBA, GL_FLOAT);
>
> texture->setTextureSize(1024,768);
> texture->setInternalFormat(GL_RGBA32F_ARB);
> texture->setSourceFormat(GL_RGBA);
> texture->setSourceType(GL_FLOAT);
> texture->setResizeNonPowerOfTwoHint(false);
> texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
> texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
> texture->setImage(0, image.get());
>
>
> And then I attach the image to camera:
>
> camera=viewer->getCamera();
> camera->setGraphicsContext(gc.get());
> camera->setViewport(0,0,wWidth,wHeight);
> camera->attach(osg::Camera::COLOR_BUFFER, texture->getImage());
> camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
>
> But after I ran the program and saved the image, I found out the shader
> output value which exceed 1 is clamped to 1! In order to check the
> problem, I wrote a small callback to check it:
>
> class VoxlizationPreDrawCallback : public osg::Camera::DrawCallback
> {
> public:
> virtual void operator () (osg::RenderInfo& ) const
> {
> for(int y=0;y<768;y++)
> {
> for(int x=0;x<1024;x++)
> {
> float value=*(float*)imageToSave->data(x,y);
> if(value>1)
> {
> std::cout<<"x="<<x<<" y="<<y<<std::endl;
> }
> }
> }
> }
>
> osg::Image* imageToSave;
> };
>
> But no value exceed 1. I changed the value>1 to value==1, it will give
> me a lot of values.
>
> I also tried if my shader can't output values above 1, I changed the
> camera setting from
>
> camera->attach(osg::Camera::COLOR_BUFFER, texture->getImage());
> to
> camera->attach(osg::Camera::COLOR_BUFFER, texture->get());
>
> And I can see in GDebugger 4.2 frame buffer object, some values actually
> above 1.
> So I guess the process of camera writing values to osg::Image does not
> support RGBA32 float format or it clamp the value to 1, float value
> should not clamp to 1, it buggy!
> Please check it! Thanks! And I also attached my little code and a box
> model which size is (2*2*2) to help reproduce the problem.
>
> Hesicong
> 2008-7-3
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
More information about the osg-users
mailing list