Hi,

The main issue I am trying to address here affects Camera's that use an FBO and 
attach their color buffer dynamically.
A camera must call setImplicitBufferAttachmentMask() to disable 
IMPLICIT_COLOR_BUFFER_ATTACHMENT and trigger the issue.
Once that is true, RenderStage will do some tricks to force the 
glCheckFramebufferStatus() call to succeed.
It does that by forcing glDrawBuffer/glReadBuffer to GL_NONE and does that 
permanently.
It will also force the RenderStage draw and read buffer states to GL_NONE.
This has most of the time no visible effects because for some reason related to 
stereo mode, SceneView will work around it.

But if the camera does not have an explicit draw buffer set then the workaround 
is not effective and glitches start to appear.
In that configuration the only glDrawBuffer call that happens is the one from 
the "trick" setting it to GL_NONE.
If the camera relies on the default (by not setting draw buffer explictly) then 
the GL_NONE sticks.
This explains why the new osgEarth rex engine is not working on Qt and maybe 
OSX.

The proposed fix is to make the "trick" less permanent. The glDrawBuffer is set 
to GL_NONE as before but only for the duration of the check.
This is acheived by using glPushAttrib() and glPopAttrib(). 
The fix also disables dubious calls to setDrawBuffer(GL_NONE, false) after the 
FBO is applied successfuly. 
I tested the fix only with GL 4.3 (the requirement to have a color buffer has 
been lifted after 4.1).

This issue can be reproduced with osgviewer by commenting out the following two 
lines in SingleWindow.cpp:

    view.getCamera()->setDrawBuffer(buffer);
    view.getCamera()->setReadBuffer(buffer);

With that change, osgviewer will render earth files as a black rectangle (with 
osgEarth 2.9). 


The "workaround" in SceneView comes from code that is documented as needed to 
restore draw buffer when toggling Stereo off.
The issue is that it does it on each frame if the camera draw buffer was 
explictly set and not just when toggling Stereo off !
Morevover, it looks like it does it partially.
The proposed fix is to _fully_ restore the draw buffer only when toggling 
Stereo off and not on each frame.

This issue is minor and does not need to be addressed to fix the main issue 
described above.
Note that if you address this issue then you must also address the main issue !

I also have a patch for both issues with proposed fixes.
The changes are quite compact and documented.
They were tested with osgviewer but only on a few OSG and osgEarth scenes (and 
on Windows only).

Corresponding PR is here : 
https://github.com/openscenegraph/OpenSceneGraph/pull/493

Thank you!

Cheers,
Philippe

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73023#73023





_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to