Only apply wave if wavelength and amplitude is larger than 0
@@ -24,13 +24,15 @@ void main()
// Offset position
for (int i = 0; i < noWaves; ++i)
{
- vec2 dir = directions[i];
float wavelength = wavelengths[i];
float amplitude = amplitudes[i];
- float frequency = wavelength > 0.001 ? 2.0 * pi / wavelength : 0.0;//sqrt(g * wavelength / (2.0 * pi)) * tanh(2.0 * pi * waterDepth / wavelength);
- float steepness = amplitude > 0.001 && frequency > 0.001 ? wavelength / (frequency * amplitude * float(noWaves)) : 0.0;
+ if(wavelength > 0.001 && amplitude > 0.001) {
+
+ vec2 dir = directions[i];
+ float frequency = 2.0 * pi / wavelength;//sqrt(g * wavelength / (2.0 * pi)) * tanh(2.0 * pi * waterDepth / wavelength);
+ float steepness = wavelength / (frequency * amplitude * float(noWaves));
float phase = speeds[i] * frequency;
float theta = dot(dir, pos.xz);
float a = theta * frequency + time * phase;
@@ -45,6 +47,7 @@ void main()
nor.x -= dir.x * frequency * amplitude * cos_a;
nor.z -= dir.y * frequency * amplitude * cos_a;
}
+ }
gl_Position = viewProjection * vec4(pos, 1.);
uvs = pos.xz;
