Inheritance: EventDispatcher → Node → TempNode →
Post processing node for computing screen space reflections (SSR).
Reference: https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html
SSRNode is an addon, and must be imported explicitly, see Installation#Addons.
import { ssr } from 'three/addons/tsl/display/SSRNode.js';
Constructs a new SSR node.
colorNode
The node that represents the beauty pass.
depthNode
A node that represents the beauty pass's depth.
normalNode
A node that represents the beauty pass's normals.
options
Optional inputs for material and environment data.
Enables sub-step binary-search refinement of a detected hit. When on, a coarse crossing is bisected toward the exact intersection (sharper hits, less step aliasing) at the cost of extra depth samples. Baked into the shader as a compile-time constant; assigning a new value rebuilds the SSR material.
Default is false.
The quality of the blur. Must be an integer in the range [1,3].
Baked into the blur shader as a compile-time constant so the (size*2+1)² sample loop unrolls; assigning a new value recompiles the blur material.
Default is 2.
Only used when SSRNode#stochastic is false. When false, non-metallic surfaces are discarded for a noticeable performance gain; set true to also reflect dielectrics. Baked into the shader as a compile-time constant; assigning a new value recompiles the SSR material.
Default is false.
When true, SSR fades to zero near screen borders instead of blending toward the environment map. Hits are faded by the reflection sample UV; misses are faded by the surface pixel UV.
Baked into the shader as a compile-time constant so the unused fade branch is eliminated; assigning a new value recompiles the SSR material.
Default is false.
Non-linear step distribution exponent. 1 = uniform steps; > 1 concentrates samples near the ray origin — where most short-range reflections are missed — and spaces them out toward maxDistance, as s = (i / steps) ^ stepExponent.
Baked into the shader as a compile-time constant so pow() folds to a few multiplies; assigning a new value recompiles the SSR material. Only used by the stochastic reflection path.
Default is 2.
Whether sub-step binary-search hit refinement is enabled (compile-time constant). Assigning a new value rebuilds the SSR material.
Blur kernel size (compile-time constant). Assigning a new value recompiles the blur material.
The camera the scene is rendered with.
The node that represents the beauty pass.
A node that represents the beauty pass's depth.
A node that represents the scene's diffuse color (typically the MRT diffuseColor attachment). When null, the shader uses vec3(1).
When true, env-luminance CDF tables are built and MIS is used for environment misses. Fixed at construction time.
Intensity multiplier for the importance-sampled env contribution. Only available after setEnvMap has been called.
Intensity multiplier applied to environment-map reflections on screen-space misses and at screen edges. Defaults to π to match the former hardcoded multiplier.
Default is Math.PI.
HDR environment map for screen-space misses.
A node that represents the history texture for multi-bounce reflections.
A multiplier for the overall reflection intensity. 1 leaves the reflections unchanged, lower values dim them and higher values boost them.
Default is 1.
Controls how far a fragment can reflect. Increasing this value result in more computational overhead but also increases the reflection distance.
Absolute env luminance cap. HDR env samples above this are scaled down (hue preserved).
Default is 10.
Per-pixel metalness, used to drive the GGX reflection sampling and the non-metal early-out. When null, the shader treats surfaces as non-metallic.
Mirror bias for the stochastic GGX sampling. Concentrates the reflected rays toward the lobe's narrow (near-mirror) core, trading a small amount of bias for less noise. 0 samples the full VNDF lobe; values toward 1 tighten the cone. Range [0,1].
Default is 0.5.
A node that represents the beauty pass's normals.
This parameter controls how detailed the raymarching process works. The value ranges is [0,1] where 1 means best quality (the maximum number of raymarching iterations/samples) and 0 means no samples at all.
A quality of 0.5 is usually sufficient for most use cases. Try to keep this parameter as low as possible. Larger values result in noticeable more overhead.
Whether dielectrics are reflected in the non-stochastic path (compile-time constant). Assigning a new value rebuilds the SSR material.
The resolution scale. Valid values are in the range [0,1]. 1 means best quality but also results in more computational overhead. Setting to 0.5 means the effect is computed in half-resolution.
Default is 1.
Per-pixel roughness, used to drive the GGX reflection sampling and the blur mip selection. When null, the shader treats surfaces as fully smooth.
Screen-edge fade width, in UV units. As a screen-space hit approaches a screen border, the reflection is faded over this distance — either toward the environment reflection (SSRNode#screenEdgeFadeBlack false) or to zero intensity (true). 0 disables it.
Default is 0.2.
Whether SSR fades to black near screen borders (compile-time constant). Assigning a new value recompiles the SSR material.
Non-linear step distribution exponent (compile-time constant). See the backing field for details. Assigning a new value recompiles the SSR material.
When true, the reflection direction is varied per pixel with stochastic GGX rays (second-generation SSR). When false, a single mirror reflection is traced and roughness is softened with a blur pass (first-generation SSR).
Controls the cutoff between what counts as a possible reflection hit and what does not.
The updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().
Default is 'frame'.
Overrides: TempNode#updateBeforeType
A node that represents the velocity texture for reprojection.
Frees internal resources. This method should be called when the effect is no longer required.
Overrides: TempNode#dispose
Returns the result of the effect as a texture node.
Returns: A texture node that represents the result of the effect.
Sets the environment map for importance-sampled env lighting when screen-space rays miss. Call this whenever the scene's env map changes.
Uses ImportanceSampledEnvironment (CDF + MIS adapted from three-gpu-pathtracer).
hdr
The equirectangular HDR environment map, or null to disable.
See:
Wires the feedback inputs for multi-bounce reflections: the previous frame's denoised result (history) and the velocity buffer used to reproject it (velocity). history accepts the producing node (e.g. a RecurrentDenoiseNode) — its output render target is used — or a raw texture. Pass null for both to disable multi-bounce.
history
velocity
Sets the size of the effect.
width
The width of the effect.
height
The height of the effect.
This method is used to setup the effect's TSL code.
builder
The current node builder.
Overrides: TempNode#setup
This method is used to render the effect once per frame.
frame
The current node frame.
Overrides: TempNode#updateBefore