Capítulo 499 de 859

Chapter 499: TRAANode

Core Idea

A special node that applies TRAA (Temporal Reprojection Anti-Aliasing).

References:

Note: MSAA must be disabled when TRAA is in use.

Key Concepts

  • beautyNode : TextureNode: The texture node that represents the input of the effect.
  • camera : Camera: The camera the scene is rendered with.
  • depthNode : TextureNode: A node that represents the scene's velocity.
  • depthThreshold : number: When the difference between the current and previous depth goes above this threshold, the history is considered invalid.
  • edgeDepthDiff : number: The depth difference within the 3×3 neighborhood to consider a pixel as an edge.
  • isTRAANode : boolean (readonly): This flag can be used for type testing.
  • maxVelocityLength : number: The history becomes invalid as the pixel length of the velocity approaches this value.
  • updateBeforeType : string: The updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().
  • useSubpixelCorrection : boolean: Whether to decrease the weight on the current frame when the velocity is more subpixel. This reduces blurriness under motion, but can intro…
  • velocityNode : TextureNode: A node that represents the scene's velocity.

Code Examples

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

Reference Tables

Constructor

Signature
new TRAANode( beautyNode : TextureNode, depthNode : TextureNode, velocityNode : TextureNode, camera : Camera )

Properties

PropertyDescription
.beautyNode : TextureNodeThe texture node that represents the input of the effect.
.camera : CameraThe camera the scene is rendered with.
.depthNode : TextureNodeA node that represents the scene's velocity.
.depthThreshold : numberWhen the difference between the current and previous depth goes above this threshold, the history is considered invalid.
.edgeDepthDiff : numberThe depth difference within the 3×3 neighborhood to consider a pixel as an edge.
.isTRAANode : boolean (readonly)This flag can be used for type testing.
.maxVelocityLength : numberThe history becomes invalid as the pixel length of the velocity approaches this value.
.updateBeforeType : stringThe updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().
.useSubpixelCorrection : booleanWhether to decrease the weight on the current frame when the velocity is more subpixel. This reduces blurriness under motion, but can introduce a square pattern artifact.
.velocityNode : TextureNodeA node that represents the scene's velocity.

Methods

MethodDescription
.clearViewOffset()Clears the view offset from the scene's camera.
.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.
.setSize( width : number, height : number )Sets the size of the effect.
.setViewOffset( width : number, height : number )Defines the TRAA's current jitter as a view offset to the scene's camera.
.setup( builder : NodeBuilder ) : PassTextureNodeThis method is used to setup the effect's render targets and TSL code.
.updateBefore( frame : NodeFrame )This method is used to render the effect once per frame.

Key Takeaways

  1. TRAANode extends: EventDispatcher → Node → TempNode
  2. Most relevant properties: beautyNode, camera, depthNode, depthThreshold.
  3. Key methods: clearViewOffset, dispose, getTextureNode, setSize.

Connects To