Sign in to follow this  

Refraction without Cubemaps or Render to texture?

This topic is 3592 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

Is it possible to do refraction without a scene cubemap, or using the render to texture method? Or, is it possible to dynamically create a cubemap of the surrounding scene (which I imagine would be slow though)? I've implemented CubeMap refraction, but I don't like the fact that it requires the surrounding scene to be static (for it to look realistic)..

Share this post


Link to post
Share on other sites
Certainly. For example, first render the non-transparent stuff in your scene. Then capture it on a texture. OpenGL/DirectX have commands to copy the screen contents to a 2D texture. Or you might want to use FBO's.

Once you have that texture, you can put it on your water/glass or any other surface that refracts by projective texturing. You can apply all kind of effects on it, like water refractions, "flame heat waves", glass distortions, and so on. And its dynamic, as long as you take this snapshot every frame. And pretty fast as well.

There are plenty of demo's that are using this trick. For example, many water rendering demo's are using this trick.

The refractions might not be 100% naturally correct though. In most demo's, you will see that the distortion effect is simply reached by giving an offset to the original texture coordinates (offset comes from noise, a normalMap, or "DUDV" map).

Greetings,
Rick

Share this post


Link to post
Share on other sites
Thanks guys!. I'll have to see how feasible this is since I'm using an engine, which restricts the use of OpenGL (unless I buy the more expensive license!). Possible just having take a screenshot from a camera that rotates for each side, and making a cubemap out of that would work?


Thanks.

Share this post


Link to post
Share on other sites
What exactly do you want to refract? In case its a relative small local object, a cubeMap would do fine. If you want a window or water, a cubeMap won't be a good solution anyway, since the refraction is only correct for 1 point. The further the rendered pixels go away from the cubeMap position, the larger the "error".

Greetings,
Rick

Share this post


Link to post
Share on other sites

This topic is 3592 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.

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