Hard MeshAnimated

Ocean surface

A rolling water surface that reflects the sky at grazing angles.

The target picture for the shader challenge "Ocean surface"
Recreate this picture. You pass at a 99% match, then try to write it in fewer characters than the par.

How this challenge works

You write a fragment shader that draws the picture above, live in your browser. A match bar shows how close you are, and the score combines accuracy, code size (the par is 491 characters in Unity (Built-in)) and GPU speed. Work in HLSL, GLSL, WGSL, Metal or Godot and export the result when you are done.

The numbers you need

Waves (sum of 3 sines)
pos.y = 0.10 * sin(pos.x * 2.0 + time * 1.5) + 0.07 * sin(pos.z * 3.0 - time * 1.2) + 0.04 * sin((pos.x + pos.z) * 6.0 + time * 2.5)
Normal
i_faceNormal
Fresnel
pow(1.0 - saturate(dot(i_faceNormal, i_viewDir)), 3.0)
Colors
deep float3(0.0, 0.2, 0.35), sky float3(0.6, 0.8, 1.0): lerp(deep, sky, fresnel)
Highlight
+ pow(max(dot(reflect(-i_viewDir, i_faceNormal), normalize(float3(0.4, 0.6, 0.7))), 0.0), 40.0)

Solve it in your language

Unity (Built-in), Unity (URP), Unreal, Shadertoy / WebGL, OpenGL (LWJGL, raylib), three.js, GameMaker, LÖVE (Lua), Godot, Apple (iOS, macOS), WebGPU / Bevy.

Start coding