Sign in to follow this  
Quat

Multilayer Refraction

Recommended Posts

Quat    568

I have multiple overlapping water meshes that use a refraction map.  Right now my engine doesn't support this scenario.  Assuming the geometry does not intersect, one solution I thought of would be just to ping-pong the render target and refraction map, and render the overlapping water features in back-to-front order.  I've ping-ponged buffers before.  Would this be too expensive?  This seems kind of brute force, are there better solutions?

 

Share this post


Link to post
Share on other sites
Styves    1792

This is probably fine. smile.png

 

You can also try copying the current screen (backbuffer, what have you) to a render target after rendering each water mesh and read that in the water shader for the next mesh - that way you don't need to reset the shader resources and rebind the new ping-ponged buffer for every mesh. You also wouldn't need to worry about which one to copy to the screen when you're doing rendering all the water - it'll be directly rendered to your scene.

 

To save some performance during the copy, you can use scissoring to only copy what's inside the meshes screen space bounding box (using a full screen pass). This'll help speed it up especially if some of your water meshes are viewed from a distance since you won't need to copy the entire screen for every mesh. smile.png If you do it this way you can also get away with tricks like using a downscaled buffer for the refraction map (since ping-ponging requires full res, otherwise you'd end up with some water looking aliased and some not). You can even blur the map during the downscale/copy if you wanted to, or pack the refraction color into a lower bit target (if you're in HDR) and lower memory consumption.

Edited by Styves

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this