โ† All examples

godot shaders

Noise terrain with height and slope splatting

Turn a subdivided plane into terrain: fractal noise displaces the vertices, a sea level flattens water, and the fragment stage paints sand, grass, rock and snow by height and slope.

Recorded render of Noise terrain with height and slope splatting

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • demo.tscn
  • inspect_shader.py
  • material.tres
  • preview.png
  • terrain_slope_height.gdshader
  • test_package.py
  • verification/native.json

How it works

Shader type
spatial
Parameters
height_scale (float = 1.4), frequency (float = 0.45), noise_octaves (int = 5), sea_level (float = 0.38), water_color (vec4 = 0.12, 0.35, 0.55, 1), sand_color (vec4 = 0.82, 0.74, 0.52, 1), grass_color (vec4 = 0.25, 0.48, 0.18, 1), rock_color (vec4 = 0.42, 0.38, 0.34, 1) and 4 more
Use it on
A subdivided PlaneMesh; the demo uses 128 x 128 subdivisions on 8 x 8 metres.
Result
Rolling green islands with beaches, rocky slopes and snowy peaks in a flat blue sea.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/terrain_slope_height/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • contract_static
  • engine_run
  • engine_log_clean
  • shader_in_scene
  • capture_written
  • render_not_uniform
  • shader_changes_pixels

Limits to consider

Collision and gameplay height must be computed separately on the CPU with the same noise. Normals come from finite differences with a fixed step and lose detail on very rough settings. Water is flat colour with no waves. Each vertex samples the fBm three times.