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 

Read FBO with PBO


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Cary, Karl A.
Guest





PostPosted: Tue Jul 11, 2017 1:28 am    Post subject:
Read FBO with PBO
Reply with quote

I have a unique situation where I have to render my full scene to the screen, but then also render a separate subset out to a shared memory segment. This was achieved by creating a second camera, attaching the needed subset, rendering to an FBO with a texture applied, and then doing a readImageFromCurrentTexture in the final draw callback. This all works. The resultant data is then memcpy'd to the location in shared memory that it needs to go (unfortunately I can't change that requirement at all, the target is raw data at the location). Alternatively I also tried applying the image directly to the fbo rather than a texture, and it was slightly faster, but still very slow. To test that this method will ultimately work, if I attach the texture but then only do the readImageFromCurrentTexture if I signal it, via keyboard input, the scene continues to render to the FBO and the last scene copied from the texture will be continually sent to the shared memory segment. The performanc
e of this is what we are looking for, we just have the one frame hit every time I signal it. All this really does is prove that if I can speed up the read, this solution will work.

The issue I have is the readImageFromCurrentTexture is extremely slow, about 20 ms. My initial thought was to use a pixel buffer object just like in the osgscreencapture example, which we have done before for applying some post processing effects with the data from the backbuffer with great success. The problem is, I can't figure out how to bind to the frame buffer object. In raw GL, you bind to GL_COLOR_ATTACHMENT0_EXT. That fails and gives a State::apply error and results in simply reading the back buffer instead. I have tried all of the COLOR_ATTACHMENT buffers and they all give me the same result.

Is it possible to bind just to the texture and do a glTexSubImage2D instead of a glReadPixels? If so, how do I actually get that set up? I have attempted to do it the same way I bind the texture for doing the readImageFromCurrentTexture but that does not work either.



------------------
Post generated by Mail2Forum
Back to top
Steal
User


Joined: 26 Jan 2017
Posts: 60

PostPosted: Tue Jul 11, 2017 6:40 pm    Post subject:
Reply with quote

Hi,

This is not a direct answer to your problem, but always keep the source handy and Ctrl-F in visual studio can yield a lot of answers.

See how readImageFromCurrentTexture is implemented.

I don't think it should have to take that long, but the function is a bit clunky.

So in short, you want to copy the pixels of a subset of your final render image to a buffer?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General 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 How to read FBO attachment back to th... MariusD General 2 Fri Jan 06, 2017 12:05 pm View latest post
No new posts Read/write shaders from/to external f... rocco martino Submission 0 Wed Oct 19, 2016 2:02 pm View latest post
No new posts Could not find plugin to read objects... robertosfield Plugins [osgPlugins] 2 Sat Jul 02, 2016 1:45 pm View latest post
No new posts Read back data from a storage buffer ... Bikappa General 2 Wed May 11, 2016 10:30 am View latest post
No new posts Javascript read .osg/.osgb? FlySky General 1 Thu Mar 10, 2016 4:15 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