Jump to content
  • Advertisement
Sign in to follow this  
Coluna

Refracting the framebuffer

This topic is 3740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks; Im trying to create a simple fx (well, the basic implementation is very simple): refract the framebuffer. As u will say, just render the normal objects to the screen, grap the framebuffer (FB for short) to a texture, and render your objects that refracts the screen. But there is a problem: what if between your refract object and the wall behind it, there is an particle system (blend, no z-write)? Ok, if I grab the FB after ALL objects, including the transparent ones, this case will still work. But what if the particle now is between our camera and the refract object? As there is no z-buffer in that part of the screen, the refract object will be drawn, overlaping the particle system that is in front of it!! Some games do this in the correct way (the last one I see this was Bioshock and its glass-walls, but in some games that have refracting water like crysis, it works too), but I couldnt find a simple solution to get that working...if I draw the refractors before the transparents, the particles behind them will be invisible, and it wont be possible to extend this to heat/haze effects. Can anybody helps me?

Share this post


Link to post
Share on other sites
Advertisement
Well, the easiest solution is to render the to-be-refracted scene to a texture with a clip plane placed at the refracting object's position - (ab)using the near clip plane is a great way to do this in a very fast and portable manner. After that, you'd render normally to the frame buffer, using the said texture on the refractive objects. Reason grabbing the frame buffer is bad is because, as you've noticed, you'll always get ghost refractions of whatever is in front of the refractive object.

Share this post


Link to post
Share on other sites
Ok, this solves for one object. But what if I have more objects that needs the FB? I had some ideas using the stencil masking and rendering twice (one before and one after the refractors) the blend objects, but I'll have some saturation where the blend object is between the refractor and the camera...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!