Sign in to follow this  

Where can I find resources on how to do water reflections?

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

I know how to do reflections with the stencil buffer, but have no clue on how to do "wavy reflections" like those seen in this screenshot: http://www.facewound.com/images/2a.jpg I'd take and guess and say it has some to do with direct pixel manipulation or maybe just messing with texture coordinates, but it doesnt seem like a way/good way to do it.

Share this post


Link to post
Share on other sites
they just capture the screen above the waterline into a texture + just draw a polygon with this texture bound for the water.
using some texture lookup manipulation in a shader

eg glsl
vec3 col = texture2D( texture0, vec2(gl_FragCoord.x + sin( time + gl_FragCoord.x/10.0), gl_FragCoord.y + sin( time gl_FragCoord.y/10.0) );

Share this post


Link to post
Share on other sites
for glsl u need at least radeon 9500 or nvidia nx3x or greater
u may be able to do something with lesser hardware using another extension fragment_program etc
check out if doom3 have the heat haze when u run it on a 9200

Share this post


Link to post
Share on other sites
You could also create the geometry on which the reflection is drawn out of many quads which are one above the other. That way you have many vertices on the left and the right of the water surface in a vertical row.
Now you can simply modify the texture coordinates every time before you're sending the corresponding vertex through the GL pipeline to make the texture on every second border between the quads on the water geometry moving a bit to the left and then to the right again. This won't create a sine wave, but for resolutions like in the screenshot the result should come close.
Additionally there is absolutely no need for any shaders that way, it's just a bit more cpu utilisation.
Maybe some optimisation can be done by reducing oGL overhead with vertex arrays.

Share this post


Link to post
Share on other sites
here is a very basic overview how i do my water

I use FBO to render the scene above the water to a texture
I use a 3D noise texture to create the offset for the ripples
I use GLSL to animate and create my texture coords , you can easily use fixed function pipeline todo this but i choose to use a vertex/pixel shader instead

Picture

Share this post


Link to post
Share on other sites

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