Medium NatureAnimated

Ocean horizon

Sky above, deep water below, and a wavy foam line between them.

The target picture for the shader challenge "Ocean horizon"
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 470 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

Surface
surf = 0.5 + 0.03 * sin(uv.x * 12.0 + time * 2.0) + 0.02 * sin(uv.x * 25.0 - time * 3.0)
Sky
lerp(float3(0.95,0.85,0.7), float3(0.4,0.65,0.95), (uv.y - 0.5) * 2.0)
Sea
lerp(float3(0.02,0.1,0.25), float3(0.1,0.45,0.6), uv.y * 2.0)
Foam
1.0 - smoothstep(0.0, 0.012, abs(uv.y - surf)), white

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