OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Camera with FBO and dynamic color buffer attachement see their glDrawBuffer state messed up


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
filnet
User


Joined: 10 Oct 2014
Posts: 55

PostPosted: Tue Mar 06, 2018 12:59 pm    Post subject:
Camera with FBO and dynamic color buffer attachement see their glDrawBuffer state messed up
Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts axis / axes with color array doesn't ... Steal General 0 Wed Sep 05, 2018 4:07 pm View latest post
No new posts missing color for simple model with G... aroth General 1 Fri Jul 27, 2018 1:55 pm View latest post
No new posts Warning: Material::apply(State&) ... bcolbert General 3 Mon Jul 23, 2018 6:19 pm View latest post
No new posts Can Material, Color, LightSource, etc... jovo General 1 Thu Jul 19, 2018 10:02 am View latest post
No new posts ReaderWriterCFG - offset for single c... Marcin Prus Submission 0 Fri Jul 06, 2018 11:27 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP