unity – GPU Gems Chapter 1, normal update

I had plans to follow GPU Gems to get knowledge in Shaders, but my trip came to an abrupt end.

Floating wave (x, y, t) {
float w = 2 / _Wavelength;
float phase = speed * w;
return float (_Amplitude * sin (period (_Direction.xz, float2 (x, y)) * w + t * phase);

o.vertex.y + = Wave (v.vertex.x, v.vertex.z, _Time.y);

The compensation of the vertices was not a problem, but then I found partial derivatives to solve the normality of each vertex. Starting in equation 4a to equation 7.

I assumed that by looking at equation 7, one did not have to fully understand the derivatives, since it was the last step.

Equation 7:
$$ sum (w_i * D_i cdot x * A_i * cos (D_i cdot (x, y) * w_i + t * varphi_i)) $$

So I tried to update the normal (well, actually the color, but only to visualize) using this function;

normal float3 (float x, float y, float t) {
float w = 2 / _Wavelength;
float phase = speed * w;
returns float3
w * dot (_Direction.xz, float2 (x, 0)) * _Amplitude * cos (dot (_Direction.xz, float2 (x, y)) * w + t * phase),
w * dot (_Direction.xz, float2 (0, y)) * _Amplitude * cos (dot (_Direction.xz, float2 (x, y)) * w + t * phase)

o.color.xyz = normalize (normal (v.vertex.x, v.vertex.z, _Time.y));

However, it does not seem to show what I would describe as good normals for the wave surface. So obviously I'm doing something wrong.

Waiting for a smooth mix between red and blue here, for example.

Ignoring the green channel here using the full code pasted below.

I would expect the colors to mix more smoothly and evenly. Seeing that I only have one wave up here.

What I wonder is how to get the normals one would expect or if this is the expected result after the mathematics (or rather what I could do) in GPU Gems.

Note: I'm trying this in Unity, so I adapted what I assumed would be Z-up to Y-up from the GPU Gem book.

Paste in the current code

GPU Gems Chapter 1