Water ripples with sphere mapping
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?
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement