[osg-users] Strange behaviour on GBufferCamera with 2 attached osg::Image

Werner Modenbach Werner.Modenbach at texion.eu
Wed Jun 27 06:52:30 PDT 2018


Hi Robert,

I'm sorry, I thougth it's OK like that.
Find the definition of the "unknown" method below.
I think this shrinks the code to be just OSG, except createScreenQuad()
but that should not really matter.

Thanks

- Werner -

Am 27.06.2018 um 15:44 schrieb Robert Osfield:
> Hi Werner,
>
> You appear to be included reference to calls and classes that aren't
> in the OpenSceneGraph, are you using a 3rd party library that is
> providing these?
>
> At this point I can't see a way of helping you as there bit doing the
> set up are unknown to us.
>
> Robert.
> On Wed, 27 Jun 2018 at 13:53, Werner Modenbach
> <Werner.Modenbach at texion.eu> wrote:
>> Hi all,
>>
>> I found a strange behavior of a GBufferCamera. I want to get the color channel in one image and the depth channel in another image.When
>> What I do:
>>
>>         if (!renderImage.valid()) {
>>
>>             renderImage = new osg::Image;
>>
>>             renderImage->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1);
>>
>>             renderImage->setInternalTextureFormat(GL_RGBA8);
>>
>>         }
>>
>>         if (includeDepth && !depthImage.valid()) {
>>
>>             depthImage = new osg::Image;
>>
>>             depthImage->allocateImage(width, height, 1, GL_DEPTH_COMPONENT, GL_FLOAT, 1);
>>
>>             renderImage->setInternalTextureFormat(GL_LUMINANCE32F_ARB);
>>
>>         }
>>
>>         if (!includeDepth)
>>             renderCamera = view->createRTTCameraImage(osg::Camera::COLOR_BUFFER, 0, renderImage.get(), true);
>>         else
>>             renderCamera = view->createRTTCameraGBufferImage(osg::Camera::COLOR_BUFFER0, renderImage.get(), osg::Camera::DEPTH_BUFFER, depthImage.get(),
>>                                                             osg::Camera::COLOR_BUFFER1, 0, 0, true);
>>
>> The definition of createRTT...
>>
>>     osg::Camera *createRTTCameraGBufferImage(osg::Camera::BufferComponent _bufferType1, osg::Image *_image1,
>>                                         osg::Camera::BufferComponent _bufferType2, osg::Image *_image2,
>>                                         osg::Camera::BufferComponent _bufferType3, osg::Image *_image3,
>>                                         int _orderNumber, bool _isAbsolute, bool _withScreenQuad = true) {

osg::ref_ptr<osg::Camera>camera=newosg::Camera;

camera->getOrCreateStateSet()->setGlobalDefaults();

camera->setClearColor(osg::Vec4());

camera->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

camera->setRenderOrder(osg::Camera::PRE_RENDER,_orderNumber);

if(_image1){

camera->setViewport(0,0,_image1->s(),_image1->t());

camera->attach(_bufferType1,_image1);

}

if(_image2){

camera->setViewport(0,0,_image2->s(),_image2->t());

camera->attach(_bufferType2,_image2);

}

if(_image3){

camera->setViewport(0,0,_image3->s(),_image3->t());

camera->attach(_bufferType3,_image3);

}

if(_isAbsolute){

camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0,1.0,0.0,1.0));

camera->setViewMatrix(osg::Matrix::identity());

if(_withScreenQuad){

camera->addChild(createScreenQuad(1.0f,1.0f));

}

}

returncamera.release();

}

>>
>>
>> When rendering without depth, I get a correct color channel image.
>> When rendering both, color and depth, the depth image is OK but the color image seems having only the red color information.
>> Are there any limitations in using 2 images?
>>
>> Has anybody else had such an effect already or can anybody give me a hint?
>>
>> Many thanks in advance
>>
>> - Werner -
>>
>> Many thanks in advance.
>> _______________________________________________
>> 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

-- 
*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: info at texion.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180627/5197ec87/attachment.html>


More information about the osg-users mailing list