Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  
OMH

OpenGL Vertex Shader Waves - Recalculating Smooth Normals

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

Hello everybody,

 

currently I'm working on a ocean shader with some vertex shader math to simulate the waves. For a more convincing effect I'd like to recalculate the surface normals after the vertex displacement has happenend, which is where I'm struggling at the moment. It's worth mentioning what I'm working with the UDK, which means there are several restrictions for the material editor that I won't be able to bypass.

 

 

So far I've come across 2 different approaches.

 

One is to use the derivative of the wave height function for recalculating the normals. Whilst this is looking pretty good it's adding lots of pixel shader instructions, depending on the wave simultion complexity. For instance:

http://www.antongerdelan.net/opengl/vertex_displacement.html

http://software.intel.com/en-us/articles/real-time-deep-ocean-simulation-on-multi-threaded-architectures

 

The other one uses partial derivates of the WorldPosition. This is has a fixed impact on instruction count, which is nice, but as expected the resulting normals are flat shaded.

 

 

Since an ocean wave algorithm might get pretty complex I'd rather go with approach #2. So I'm wondering if there are any techniques to calculate smooth normals in the pixel shader with a fixed instruction count?

Edited by OMH

Share this post


Link to post
Share on other sites
Advertisement

The normal can be calculated as the first derivative of the wave equation. I don't have code at the moment as I am at work, however I can post something for you later on.

In the meantime, you can do some research on calculating the first derivative, it shouldn't be too hard :)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!