Jump to content
  • Advertisement
Sign in to follow this  
Ulfie

OpenGL Water ripples with sphere mapping

This topic is 4897 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'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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!