Capítulo 480 de 859

Chapter 480: SSRNode

Core Idea

Post processing node for computing screen space reflections (SSR).

Reference: https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html

Key Concepts

  • _binaryRefine : boolean: Enables sub-step binary-search refinement of a detected hit. When on, a coarse crossing is bisected toward the exact intersection (sharper …
  • _blurQuality : number: The quality of the blur. Must be an integer in the range [1,3].
  • _reflectNonMetals : boolean: Only used when SSRNode#stochastic is false. When false, non-metallic surfaces are discarded for a noticeable…
  • _screenEdgeFadeBlack : boolean: When true, SSR fades to zero near screen borders instead of blending toward the environment map. Hits are faded by the reflection sample …
  • _stepExponent : number: Non-linear step distribution exponent. 1 = uniform steps; > 1 concentrates samples near the ray origin — where most short-range reflect…
  • binaryRefine : boolean: Whether sub-step binary-search hit refinement is enabled (compile-time constant). Assigning a new value rebuilds the SSR material.
  • blurQuality : number: Blur kernel size (compile-time constant). Assigning a new value recompiles the blur material.
  • camera : Camera: The camera the scene is rendered with.
  • colorNode : Node.<vec4>: The node that represents the beauty pass.
  • depthNode : Node.<float>: A node that represents the beauty pass's depth.

Code Examples

import { ssr } from 'three/addons/tsl/display/SSRNode.js';
  • What it demonstrates: Typical usage of SSRNode.

Reference Tables

Constructor

Signature
new SSRNode( colorNode : Node.<vec4>, depthNode : Node.<float>, normalNode : Node.<vec3>, options : SSRNodeOptions )

Properties

PropertyDescription
._binaryRefine : booleanEnables 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…
._blurQuality : numberThe quality of the blur. Must be an integer in the range [1,3].
._reflectNonMetals : booleanOnly used when SSRNode#stochastic is false. When false, non-metallic surfaces are discarded for a noticeable performance gain; set true to also reflect dielectrics. B…
._screenEdgeFadeBlack : booleanWhen 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.
._stepExponent : numberNon-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…
.binaryRefine : booleanWhether sub-step binary-search hit refinement is enabled (compile-time constant). Assigning a new value rebuilds the SSR material.
.blurQuality : numberBlur kernel size (compile-time constant). Assigning a new value recompiles the blur material.
.camera : CameraThe camera the scene is rendered with.
.colorNode : Node.<vec4>The node that represents the beauty pass.
.depthNode : Node.<float>A node that represents the beauty pass's depth.
.diffuseNode : Node.<vec4>A node that represents the scene's diffuse color (typically the MRT diffuseColor attachment). When null, the shader uses vec3(1).
.envImportanceSampling : booleanWhen true, env-luminance CDF tables are built and MIS is used for environment misses. Fixed at construction time.
.envMapIntensity : UniformNode.<float>Intensity multiplier for the importance-sampled env contribution. Only available after setEnvMap has been called.
.environmentIntensity : UniformNode.<float>Intensity multiplier applied to environment-map reflections on screen-space misses and at screen edges. Defaults to π to match the former hardcoded multiplier.
.environmentNode : TextureHDR environment map for screen-space misses.
.historyTexture : TextureA node that represents the history texture for multi-bounce reflections.
.intensity : UniformNode.<float>A multiplier for the overall reflection intensity. 1 leaves the reflections unchanged, lower values dim them and higher values boost them.
.maxDistance : UniformNode.<float>Controls how far a fragment can reflect. Increasing this value result in more computational overhead but also increases the reflection distance.
.maxLuminance : UniformNode.<float>Absolute env luminance cap. HDR env samples above this are scaled down (hue preserved).
.metalnessNode : Node.<float>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.
.mirrorBias : UniformNode.<float>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…
.normalNode : Node.<vec3>A node that represents the beauty pass's normals.
.quality : UniformNode.<float>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 sa…
.reflectNonMetals : booleanWhether dielectrics are reflected in the non-stochastic path (compile-time constant). Assigning a new value rebuilds the SSR material.
.resolutionScale : numberThe 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.
.roughnessNode : Node.<float>Per-pixel roughness, used to drive the GGX reflection sampling and the blur mip selection. When null, the shader treats surfaces as fully smooth.
.screenEdgeFade : UniformNode.<float>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#screenEdgeFadeBl…
.screenEdgeFadeBlack : booleanWhether SSR fades to black near screen borders (compile-time constant). Assigning a new value recompiles the SSR material.
.stepExponent : numberNon-linear step distribution exponent (compile-time constant). See the backing field for details. Assigning a new value recompiles the SSR material.
.stochastic : booleanWhen 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 pa…
.thickness : UniformNode.<float>Controls the cutoff between what counts as a possible reflection hit and what does not.
.updateBeforeType : stringThe updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().
.velocityTexture : Node.<vec2>A node that represents the velocity texture for reprojection.

Methods

MethodDescription
.dispose()Frees internal resources. This method should be called when the effect is no longer required.
.getTextureNode() : PassTextureNodeReturns the result of the effect as a texture node.
`.setEnvMap( hdr : Texturenull )`
.setHistory( history : Texture, velocity : Node.<vec2> )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 nod…
.setSize( width : number, height : number )Sets the size of the effect.
.setup( builder : NodeBuilder ) : PassTextureNodeThis method is used to setup the effect's TSL code.
.updateBefore( frame : NodeFrame )This method is used to render the effect once per frame.

Key Takeaways

  1. SSRNode extends: EventDispatcher → Node → TempNode
  2. Most relevant properties: _binaryRefine, _blurQuality, _reflectNonMetals, _screenEdgeFadeBlack.
  3. Key methods: dispose, getTextureNode, setEnvMap, setHistory.

Connects To