Sign in to follow this  
Ulfie

OpenGL Water ripples with sphere mapping

Recommended Posts

I've created a water ripple effect in OpenGL by using a grid of quads. I texture the quads with sphere mapping, as so: glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); That way, I get pretty good results, as you can see: http://home.student.uu.se/uled8027/ripple.JPG However, all I get is flat shading. Is there a way to get smooth shading of the quads? Obviously, specifying vertex normals has no effect. Is there a way around this? How would this be done with a shader?

Share this post


Link to post
Share on other sites
glShadeModel( GL_SMOOTH );

That makes shading smooth instead of flat, but that only applies to vertex colours, not to textures. The "smoothness" of textures is determined by the tex-environment for the currently bound texture unit.
If your ripple effect is a texture you want to set it to one of the "linear" tex-environment modes.

Share this post


Link to post
Share on other sites
it looks to me like you're using the same normal for the entire quad. what you need to do, is to calculate the normal for each vertex. just add up the normals for all polygons that share a a given vertex and normalize.

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