[osg-users] Render to Texture

J.P. Delport jpdelport at csir.co.za
Wed Jul 16 08:02:53 PDT 2008


Hi Paul,

paul1492 at yahoo.com wrote:
> I'm not sure what is going on but I switched to dumping a "png" file and still see the banding (see attached)...
> Are you sure the PNG plugin can handle dumping an RGBA GL_FLOAT image?
No, I'm sure it can't. I meant RGBA for 8-bit per channel data.

Your previous post said nothing about GL_FLOAT, so my assumptions were 
wrong, but float values explain the banding as well. As you can see from 
the image, the writer expected one byte channel, but your data has 4.

You have a few options:
1) convert the float data to RGBA one byte per channel before calling write.

2) use a RGBA one byte per channel texture as your render target (I 
think osgprerender has switches for hdr, otherwise search for "hdr" in 
the examples)

3) If you really want to write the float data, modify the attached 
reader/writer that reads/writes RGBA 32-bit floats. It writes it in text 
format, you can read it with Matlab/Octave/...

The files go into
OpenSceneGraph/src/osgPlugins/rgba32f

edit the CMakeLists in osgPlugins to add the directory.

Use .rgba32f extension to read/write.

4) make/find another float writer.

cheers

jp



> All I did was add a osgDB::writeImageFile(*_image, "somefilename.png") at the end of the GL_FLOAT/RGBA if statement in  MyCameraPostDrawCallback::operator() in the osgprerender.cpp example and then ran this example using "--image cow.osg".
> 
> Paul P.
> 
> 
> ----- Original Message ----
> From: J.P. Delport <jpdelport at csir.co.za>
> To: OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
> Sent: Tuesday, July 15, 2008 8:11:14 AM
> Subject: Re: [osg-users] Render to Texture
> 
> Hi,
> 
> make sure the image writer can handle your image format. Bands usually 
> mean an alignment error in the data the writer expects. E.g. expects 
> binary input data to be RGB, but the data is RGBA.
> 
> .jpg does not support alpha I think.
> 
> Try .png
> 
> jp
> 
> paul1492 at yahoo.com wrote:
>> I'm attempting to render to a texture and then dump the rendered texture to a file (every frame), but I'm having trouble.
>> I've attempted to use the osgprerender example (using the --image option), and replaced the MyCameraPostDrawCallback::operator() to have a
>>     osgDB::writeImageFile(*_image, fileName);
>> where fileName is a ".tif" file (or .jpg file).
>> When I look at the .tif file using the Linux "display" program, I get some funny banded image. What am I doing wrong?
>> Is there a more efficient way to get access to the rendered image? Must I allocate an "image" array to the texture to access the image?
>> Paul P.
>>
>>
>>       
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rgba32f.zip
Type: application/zip
Size: 1789 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080716/5d3fa51c/attachment-0003.zip>


More information about the osg-users mailing list