โ† All examples

godot shaders

Underwater camera view

Make the camera look underwater: wavy screen distortion, wavelength-dependent absorption by distance from the depth buffer (red fades first), a blue-green scattering colour, brighter light from above and a vignette.

Recorded render of Underwater camera view

What this component contains

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

How it works

Shader type
spatial
Render modes
unshaded, cull_disabled, depth_test_disabled, depth_draw_never, skip_vertex_transform, fog_disabled
Parameters
screen_texture (sampler2D), depth_texture (sampler2D), water_color (vec4 = 0.04, 0.28, 0.38, 1), absorption (float = 0.22), red_absorption (float = 3), distortion (float = 0.006), wave_frequency (float = 18), wave_speed (float = 1.5) and 2 more
Use it on
A MeshInstance3D with a 2 x 2 QuadMesh, `material.tres` as its material override and a large extra cull margin, as in `demo.tscn`.
Result
The scene tinted deep teal and fading into murk with distance, gently wavering.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/post_underwater_view/

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

Sky pixels are clamped to 200 metres of water. The wobble is screen-space and the same at all depths. No caustics or particles (see `underwater_caustics` for surface caustics). The pass reads Godot's screen texture after opaque geometry, so transparent objects drawn after it are not processed and its order among other transparent passes is not controlled.