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

Werner Modenbach Werner.Modenbach at texion.eu
Wed Jun 27 07:14:25 PDT 2018


Hi Robert,

I'd really like doing that. Unfortunately I'm on Windows and the only
development environment is Qt.
So I cannot even create a small project outside Qt.
But honestly I tend to believe it's something in OSG.
Really the only difference in the 2 versions is the additional
attachment of the depth image.

I'm sorry.

- Werner -

Am 27.06.2018 um 16:04 schrieb Robert Osfield:
> HI Werner,
>
> The code looks OK. I don't see any reason why attaching an image to
> both the colour and depth attachments wouldn't work, it's not
> something I have tested out though.
>
> There is chance it's an OSG bug, but perhaps there is something in
> your setup that isn't quite right.  It's impossible to know from what
> info I have.  Could you create a small test program that tests out
> assigning an image to colour and depth buffers and if this fails then
> share this so others like myself can have a look at it and either spot
> an error on the OSG side or in your code.  If it works then this
> simple case might shine a light on what you are doing differently.
>
> Robert.
> On Wed, 27 Jun 2018 at 14:52, Werner Modenbach
> <Werner.Modenbach at texion.eu> wrote:
>> 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 = new osg::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));
>>
>>         }
>>
>>     }
>>
>>     return camera.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
>> _______________________________________________
>> 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/8b335eed/attachment-0001.html>


More information about the osg-users mailing list