Hard Mesh

Procedural terrain

A flat grid becomes mountains: displace vertices with fbm and color them by height.

The target picture for the shader challenge "Procedural terrain"
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 973 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

Height
pos.y = 0.8 * fbm(pos.xz * 0.8) - 0.3
Colors by i_worldPos.y
grass float3(0.2, 0.5, 0.2) below 0.0; rock float3(0.4, 0.35, 0.3) up to 0.25; snow float3(0.95, 0.95, 1.0) above. Blend with smoothstep(-0.05, 0.05, h) then smoothstep(0.2, 0.3, h)
Light
normalize(float3(0.5, 0.8, 0.3)) on i_faceNormal, brightness 0.25 + 0.75 * diffuse

Helper functions provided

The toolbox has: hash(), vnoise(), fbm(). Add them above your frag function with one click.

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