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 

FIX: osgPPU rendering not working in the first frame


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgPPU [osgPPU]
View previous topic :: View next topic  
Author Message
airion
User


Joined: 11 Aug 2010
Posts: 31

PostPosted: Thu Nov 17, 2011 9:20 am    Post subject:
FIX: osgPPU rendering not working in the first frame
Reply with quote

Hi,

the last days I was fighting the problem, that osgPPU rendering was not working in the first frame. Normally, this is rarely noticeable, but I use it for generating a texture, that does not change anymore - so I use osgPPU with a single shot rendering and if the rendering is faulty, the error remains visible for all the time.

I tracked the problem down to reside in UnitInOut::noticeBeginRendering(). There "mFBO->apply(*info.getState());" causes the units output texture to be generated in the first frame. This causes a glBindTexture() which brakes the binding of the already bound input texture, so that rendering can not work in this frame.

Please find attached fix, that restores the texture binding after applying the FBO.

Regards,
--Alex
Back to top
View user's profile Send private message
art (Art Tevs)
Site Admin


Joined: 20 Dec 2008
Posts: 414
Location: Saarbr├╝cken, Germany

PostPosted: Thu Nov 17, 2011 10:39 pm    Post subject:
Re: FIX: osgPPU rendering not working in the first frame
Reply with quote

Hi Alex,

hmm, ok, it seems to be a solution, however I am not sure if this is a general one. I mean, what if for example the input texture is not 2D and the output texture is also not 2D. Then fbo will still overwrite current binding.

I would propose to try following solution:

glPushAttrib(GL_TEXTURE_BIT);
mFBO->apply(*info.getState());
glPopAttrib();

Alex, could you please try if this works for you? Based on the specifications of glPushAttrib this should store current texture bindings

cheers,
art


airion wrote:
Hi,

the last days I was fighting the problem, that osgPPU rendering was not working in the first frame. Normally, this is rarely noticeable, but I use it for generating a texture, that does not change anymore - so I use osgPPU with a single shot rendering and if the rendering is faulty, the error remains visible for all the time.

I tracked the problem down to reside in UnitInOut::noticeBeginRendering(). There "mFBO->apply(*info.getState());" causes the units output texture to be generated in the first frame. This causes a glBindTexture() which brakes the binding of the already bound input texture, so that rendering can not work in this frame.

Please find attached fix, that restores the texture binding after applying the FBO.

Regards,
--Alex
Back to top
View user's profile Send private message Visit poster's website
airion
User


Joined: 11 Aug 2010
Posts: 31

PostPosted: Fri Nov 18, 2011 9:33 am    Post subject:
Reply with quote

Hello Art,

glPushAttrib / glPopAttrib works as well, but it's not available in GLES and I also use osgPPU with GLES. However in GLES there are no 3D textures, only 2D and cube maps.

Regards,
--Alex
Back to top
View user's profile Send private message
art (Art Tevs)
Site Admin


Joined: 20 Dec 2008
Posts: 414
Location: Saarbr├╝cken, Germany

PostPosted: Fri Nov 18, 2011 2:24 pm    Post subject:
Reply with quote

Hi Alex,

ok, this is of course pretty bad.

Actually, I think the correct way would be to apply the texture to the osg::State within the FBO::apply(). This would ensure that the state is tracked correctly. Of course, unfortunately this requires a patch to the main osg core.

In general, I think this might be a general osg problem, since in order to generate texture within FBO::apply() one need to make sure that current texture binding is not overwritten. I think, I will try to rewrite your patch here slightly to ensure correct work of osgPPU, but we should keep in mind, that we might need a patch for OSG as well.

Cheers,
art


airion wrote:
Hello Art,

glPushAttrib / glPopAttrib works as well, but it's not available in GLES and I also use osgPPU with GLES. However in GLES there are no 3D textures, only 2D and cube maps.

Regards,
--Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgPPU [osgPPU] 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 Frame rate improvement Ale General 4 Fri Sep 22, 2017 9:44 am View latest post
No new posts Running a per-frame task on the graph... James Turner General 0 Fri Sep 22, 2017 8:53 am View latest post
No new posts Post Processing Effect - Vertex Shade... guyv General 27 Sat Sep 16, 2017 3:48 am View latest post
No new posts Pro Process Effect Vertex Shader not ... guyv General 1 Fri Sep 15, 2017 10:22 pm View latest post
No new posts Is it possible to clear just certain ... amudhan79 General 3 Mon Sep 11, 2017 7:48 pm 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