Hello,

I try to implement circular water from the GPU Gems chapter 1. (http://http.developer.nvidia.com/GPUGems/gpugems_ch01.html)

Here is reals formula:

**Wave height:**

with,

- Wavelength (
*L*): the crest-to-crest distance between waves in world space. Wavelength*L*relates to frequency*w*as*w*= 2*p*/*L* - Amplitude (
*A*): the height from the water plane to the wave crest. - Speed (
*S*): the distance the crest moves forward per second. It is convenient to express speed as phase-constant*S*x 2*p*/*L*. - Direction (
*D***)**: the horizontal vector perpendicular to the wave front along which the crest travels.

**Normal vector:**

with,

**Circular direction:**

I implemented these formula in the tesselation evaluation shader.

Here is the source code:

#version 430 core // In layout (quads, equal_spacing, cw) in; // Uni uniform float uni_Time; uniform float uni_Frequency; uniform float uni_Amplitude; uniform float uni_Fi; uniform vec2 uni_Direction; uniform sampler2D uni_Texture; // Out out vec3 normal; void main(void) { // Compute new vertice pos vec4 p1 = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_TessCoord.x); vec4 p2 = mix(gl_in[2].gl_Position, gl_in[3].gl_Position, gl_TessCoord.x); vec4 p = mix(p1, p2, gl_TessCoord.y); // Compute direction vec2 center = vec2(0.5f, 0.5f); vec2 dir = normalize(gl_TessCoord.yx - center); // Compute wave height float theta = dot(dir, gl_TessCoord.yx); p.y -= uni_Amplitude * sin(theta * uni_Frequency + uni_Time * uni_Fi); // Compute normal float A = uni_Amplitude * dir.x * uni_Frequency; normal.x = - (A * cos(theta * uni_Frequency + uni_Time * uni_Fi)); A = uni_Amplitude * dir.y * uni_Frequency; normal.y = - (A * cos(theta * uni_Frequency + uni_Time * uni_Fi)); normal.z = 1.0f; normal = normalize(normal); gl_Position = p; }

and the video:

The problem is,

In the case where i choose directional wave, it works fine (direction and normal vector.)

But, in the case where i choose circular wave, i get a wrong wave and normal ...

I think that, with circular wave, my direction is wrong ... but i dont understand why ...

Thanks for your help

**Edited by Blackhart, 19 August 2014 - 02:29 PM.**