Increase wave strength and add shoreline foam

Ocean waves are now much more pronounced, and foam appears on shorelines
in addition to wave crests.

Wave strength increases:
- Amplitude: 0.12 → 0.25 (ocean), 0.07 → 0.10 (canals)
- Frequency: 0.18 → 0.22 (ocean) - more waves per distance
- Speed: 1.60 → 2.00 (ocean) - faster wave motion

Shoreline foam:
- Appears on shallow/near-camera water (20-80 unit range)
- Uses upward-facing surface detection (horizontal = shore)
- Combined with wave crest foam for realistic effect
- Animated with same noise pattern as wave foam

Wave crest foam improvements:
- Lower threshold (0.15 vs 0.25) - more visible
- Increased intensity (0.85 vs 0.65)
- Faster animation (time * 0.8)
- Higher frequency noise (50.0 vs 40.0)

Result: Ocean now has visible motion from distance and foam on beaches.
This commit is contained in:
Kelsi 2026-02-08 22:20:45 -08:00
parent e7ff0ce0ce
commit 3cab27060c

View file

@ -115,11 +115,22 @@ bool WaterRenderer::initialize() {
result += skyTint;
result = max(result, waterColor.rgb * 0.24);
// Ocean foam on wave crests (procedural)
float wavePeak = smoothstep(0.25, 0.5, WaveOffset); // Peaks have positive offset
float foamNoise = fract(sin(dot(TexCoord * 40.0 + time * 0.5, vec2(12.9898, 78.233))) * 43758.5453);
float foam = wavePeak * foamNoise * 0.65;
result += vec3(foam); // Add white foam to wave crests
// Ocean foam on wave crests and shorelines (procedural)
// Wave crest foam
float wavePeak = smoothstep(0.15, 0.4, WaveOffset); // More foam on peaks
float foamNoise = fract(sin(dot(TexCoord * 50.0 + time * 0.8, vec2(12.9898, 78.233))) * 43758.5453);
float foamPattern = foamNoise * 0.5 + 0.5; // Scale to 0.5-1.0
float waveFoam = wavePeak * foamPattern * 0.85;
// Shoreline foam (appears in shallow water / near terrain)
// Use view-space depth as proxy - upward-facing surfaces near camera likely shoreline
float depth = length(viewPos - FragPos);
float shoreProximity = smoothstep(80.0, 20.0, depth); // Foam within 20-80 units
float upwardFacing = max(dot(norm, vec3(0.0, 0.0, 1.0)), 0.0); // Horizontal surfaces
float shoreFoam = shoreProximity * upwardFacing * foamPattern * 0.6;
float foam = max(waveFoam, shoreFoam);
result += vec3(foam); // Add white foam
// Slight fresnel: more reflective/opaque at grazing angles.
float fresnel = pow(1.0 - max(dot(norm, viewDir), 0.0), 3.0);
@ -404,9 +415,9 @@ void WaterRenderer::render(const Camera& camera, float time) {
// City/canal liquid profile: clearer water + stronger ripples/sun shimmer.
// Stormwind canals typically use LiquidType 5 in this data set.
bool canalProfile = (surface.wmoId != 0) || (surface.liquidType == 5);
float waveAmp = canalProfile ? 0.07f : 0.12f;
float waveFreq = canalProfile ? 0.30f : 0.18f;
float waveSpeed = canalProfile ? 1.20f : 1.60f;
float waveAmp = canalProfile ? 0.10f : 0.25f; // Increased from 0.07/0.12
float waveFreq = canalProfile ? 0.30f : 0.22f; // Increased from 0.18 for more waves
float waveSpeed = canalProfile ? 1.20f : 2.00f; // Increased from 1.60 for more motion
float shimmerStrength = canalProfile ? 0.95f : 0.50f;
float alphaScale = canalProfile ? 0.72f : 1.00f;