4

I am following the Nvidia GPU Gems Chapter 1 regarding water simulation using shaders. I am trying to follow the chapter to create an ocean water shader using glsl in OpenGL es 2.0 (iOS).

I am able to create the geometric waves as described in the chapter but when it comes to creating the texture normal map I am having trouble. The chapter is slightly unclear about what is actually getting rendered out to the texture render target. Am I supposed to render a normal map or a height map? In the text it suggests that normals are getting rendered to the target as an rgb color but then again, images (b) and (d) under section 1.3 "Authoring" seem to indicate that a grayscale height map should be rendered to the texture target. The chapter also talks about using a lookup texture for the u coordinate of the texture, but it is unclear to me how this fits in with rendering to the texture. Are there 2 different textures to render to? If anyone can help clarify how these components fit together I would very much appreciate it!

SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
LOP_Luke
  • 3,150
  • 3
  • 22
  • 25

1 Answers1

0

Why are you rendering to a texture at all? You can easily just calculate these values on-the-fly in your geometry shader. Since they change each frame, you need to repeat these calculation each time anyway, so I don't see what you gain by rendering to a texture.

You do need to calculate two values though: the height displacement (using equation 3) and the normal for each vertex (using equation 6b).

fluffels
  • 4,051
  • 7
  • 35
  • 53
  • 1
    The tutorial suggests that to get higher resolution waves in the simulation you can render normal values to a texture target. "We also extend the technique into the realm of pixel shaders, using a sum of periodic wave functions to create a dynamic tiling bump map to capture the finer details of the water surface." - 1.1 Goals and Scope. I have the geometric waves and normals working (created "on the fly" in the vertex shader), it's the normal map that I am having trouble creating. – LOP_Luke May 21 '13 at 20:46
  • The reason that paper creates the normal map is because it's quite old. You can just calculate per-vertex normals and pass them through to the Fragment shader. That's what I did when I implemented this and it works fine :) – fluffels May 23 '13 at 07:00