Jump to content

  • Log In with Google      Sign In   
  • Create Account

Use BackBuffer as Texture Input


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Frederick   Members   -  Reputation: 140

Like
0Likes
Like

Posted 06 November 2012 - 11:24 AM

Hi Guys!

I´d like to implement a refraction like effect, and would like to warp the "background" of the object in some way.
As the object is marked as translucent it is rendered in a separate queue after the opaque objects - so it can be assumed that at this
stage the background has been fully drawn.

Is it possible to use the actual BackBuffer as Texture Input or do I have to render to the scene to a separate RenderTexture and perform the read from this texture ?

I would like to avoid the additional copying that is involved with that.

Thanks a lot,
Frederick

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7978

Like
2Likes
Like

Posted 06 November 2012 - 12:35 PM

You can't do this directly as you would be both reading from and writing to the same GPU-side resource at the same time, so you have two main options.

Option 1 is to use a framebuffer object, which is basically what you've just described. Yes, it has some additional overhead, but it's not too onerous. This is the tried and tested solution used by all modern games, whether they be using GL FBOs or the D3D equivalent, so you can safely and confidently use it.

There's no real additional copying involved with this, but you are effectively covering each pixel in a screen-sized rect twice. Expect to lose at most 25% of your performance if you're already GPU-bound; if you're CPU-bound you may not even notice it.

Option 2 is to draw as normal, then glCopyTexSubImage to a screen-sized texture. This one does involve extra copying and extra data traffic, so it's going to be slower than using an FBO, but it is handy to keep as a fallback for GL implementations that don't support FBOs.

Edited by mhagain, 07 November 2012 - 07:13 AM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Frederick   Members   -  Reputation: 140

Like
0Likes
Like

Posted 07 November 2012 - 07:15 AM

Hey thanks!

ok, when I think about it seems logical to me now Posted Image

You can't do this directly as you would be both reading from and writing to the same GPU-side resource at the same time, so you have two main options.


Of course I would read the background, warp it and then render the front of the object on top of it. Doing that at the same time can´t work on a logical level... did not quite see that before Posted Image

I guess I will go with the framebuffers then, no problem at all when post effects are applied (at some point in the future). They need offscreen buffers anyway.

Thanks!

Edited by Frederick, 07 November 2012 - 07:19 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS