Hi Robert,

I'm struggling to follow what bits work and what doesn't.  Is it that
_image->getInternalTexureFormat() is not GL_RGBA32F_ARB?
yes, finally after a debug session I found out that setting up the internal Format for the RenderBuffer (is done via: FrameBufferAttachment::FrameBufferAttachment(Camera::Attachment& attachment) depends on the right setup of the osg::Image
which is attached to the Camera(Node)

in osgPrerender - example, for option --image,  there is following in use:

image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);

it works ok, but the float values in the image will only be prerendered with 8bit precision this way.

instead, increasing the prerender precision to 16bit is possible but not simply by using:

image->allocateImage(tex_width, tex_height, 1, GL_RGBA32F_ARB , GL_FLOAT);

the function will not set up the image correctly with format 0x8814 , but with a little fix inside of

void Image::allocateImage(int s,int t,int r,
                       GLenum format,GLenum type,
                       int packing)

it works.  i have attached the code that works for me.

btw: maybe the problem exists always, if image prerendering is done with other rendertarget formats than standard GL_RGBA?
i'm not sure about this, have not tested such cases.


Markus


///////////////////////////////////////////////////////////////////////////////////////////////
myfix:


void Image::allocateImage(int s,int t,int r,
                       GLenum format,GLenum type,
                       int packing)
{
   _mipmapData.clear();

   unsigned int previousTotalSize = 0;

///////////////
   GLenum internalformat = format;

     if(format == 0x8814) // the fix is only for format GL_RGBA32F_ARB
   {
       internalformat = format;
       format = GL_RGBA;
   }
///////////////
if (_data) previousTotalSize = computeRowWidthInBytes(_s,_pixelFormat,_dataType,_packing)*_t*_r; unsigned int newTotalSize = computeRowWidthInBytes(s,format,type,packing)*t*r;

   if (newTotalSize!=previousTotalSize)
   {
       if (newTotalSize)
           setData(new unsigned char [newTotalSize],USE_NEW_DELETE);
       else
           deallocateData(); // and sets it to NULL.
   }

   if (_data)
   {
       _s = s;
       _t = t;
       _r = r;
       _pixelFormat = format;
       _dataType = type;
       _packing = packing;
_internalTextureFormat = internalformat; // instead of direct use of 'format'
   }
   else
   {
// throw exception?? not for now, will simply set values to 0.
       _s = 0;
       _t = 0;
       _r = 0;
       _pixelFormat = 0;
       _dataType = 0;
       _packing = 0;
       _internalTextureFormat = 0;
   }
++_modifiedCount;
}

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to