Baltor Get started

Gallery / Godot shaders

Screen-space ambient occlusion from depth only

In your harnessGodot shaderMIT

Darken creases and contacts with ambient occlusion estimated in one pass from the depth buffer: normals from position derivatives, a disc of samples scaled by distance, and a range check against far geometry.

Render of Screen-space ambient occlusion from depth only
The render its check recorded in Godot 4.7.2, 256 by 256 pixels.

What it takes and gives

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), radius (float = 0.45), intensity (float = 1.4), samples (int = 16), bias (float = 0.03), max_pixels (float = 48), shadow_tint (vec4 = 0, 0, 0.05, 1) and 1 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 with soft darkening where objects meet the floor and in corners.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/post_depth_ao_approx/

Limits. Applied after lighting, so it also darkens directly lit areas. Noisy without a blur pass (the per-pixel rotation trades banding for grain). Derivative normals break at object edges and give thin halos there. 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.

Details

Kind
Godot shader
Engine
Godot 4.3 or later
Files
11 files, 73.7 KB
Licence
MIT
Declared effects
reads files, runs commands
Checked with
Godot 4.7.2, opengl3 compatibility (Mesa llvmpipe, Xvfb)
Checks
contract static, engine run, engine log clean, shader in scene, capture written, render not uniform, shader changes pixels
Techniques
Screen-space ambient occlusion with normal-oriented hemisphere test, Golden-angle disc with per-pixel rotation, Normals from derivatives of reconstructed position, MurmurHash3 32-bit finalizer over prime-combined lattice coordinates as a hash
Tags
godot shader, spatial, post-process, ambient occlusion, ssao, depth buffer, contact shadows, full-screen
Identity
library.supply.creative_originals.e93dc66c79261a25490eb47a.30a16e9796f4cf6b
Version
30a16e9796f4cf6bfabf10ce820b252433b0cb227050885ab2bfc3cd6bda33df

The version is the SHA-256 of the item your harness downloads; every file in it names its own checksum.

Something wrong with this item, its rights or its safety? Report it on the support page, or from your harness after a download.