Multilayer Refraction

Started by
0 comments, last by Styves 11 years, 1 month ago

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?

-----Quat
Advertisement

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.

This topic is closed to new replies.

Advertisement