Capítulo 421 de 859

Chapter 421: GTAONode

Core Idea

Post processing node for applying Ground Truth Ambient Occlusion (GTAO) to a scene.

Reference: Practical Real-Time Strategies for Accurate Indirect Occlusion.

Key Concepts

  • depthNode : Node.<float>: A node that represents the scene's depth.
  • distanceExponent : UniformNode.<float>: Another option to tweak the occlusion. The recommended range is [1,2] for attenuating the AO.
  • distanceFallOff : UniformNode.<float>: The distance fall off value of the ambient occlusion. A lower value leads to a larger AO effect. The value should lie in the range [0,1].
  • normalNode : Node.<vec3>: A node that represents the scene's normals. If no normals are passed to the constructor (because MRT is not available), normals can be auto…
  • radius : UniformNode.<float>: The radius of the ambient occlusion.
  • resolution : UniformNode.<vec2>: The resolution of the effect. Can be scaled via resolutionScale.
  • resolutionScale : number: The resolution scale. By default the effect is rendered in full resolution for best quality but a value of 0.5 should be sufficient for m…
  • samples : UniformNode.<float>: How many samples are used to compute the AO. A higher value results in better quality but also in a more expensive runtime behavior.
  • scale : UniformNode.<float>: The scale of the ambient occlusion.
  • thickness : UniformNode.<float>: The thickness of the ambient occlusion.

Code Examples

const renderPipeline = new THREE.RenderPipeline( renderer );
const scenePass = pass( scene, camera );
scenePass.setMRT( mrt( {
	output: output,
	normal: normalView
} ) );
const scenePassColor = scenePass.getTextureNode( 'output' );
const scenePassNormal = scenePass.getTextureNode( 'normal' );
const scenePassDepth = scenePass.getTextureNode( 'depth' );
const aoPass = ao( scenePassDepth, scenePassNormal, camera );
const aoPassOutput = aoPass.getTextureNode();
renderPipeline.outputNode = scenePassColor.mul( vec4( vec3( aoPassOutput.r ), 1 ) );
  • What it demonstrates: Typical usage of GTAONode.

Reference Tables

Constructor

Signature
new GTAONode( depthNode : Node.<float>, normalNode : Node.<vec3>, camera : Camera )

Properties

PropertyDescription
.depthNode : Node.<float>A node that represents the scene's depth.
.distanceExponent : UniformNode.<float>Another option to tweak the occlusion. The recommended range is [1,2] for attenuating the AO.
.distanceFallOff : UniformNode.<float>The distance fall off value of the ambient occlusion. A lower value leads to a larger AO effect. The value should lie in the range [0,1].
.normalNode : Node.<vec3>A node that represents the scene's normals. If no normals are passed to the constructor (because MRT is not available), normals can be automatically reconstructed from depth values in the shader.
.radius : UniformNode.<float>The radius of the ambient occlusion.
.resolution : UniformNode.<vec2>The resolution of the effect. Can be scaled via resolutionScale.
.resolutionScale : numberThe resolution scale. By default the effect is rendered in full resolution for best quality but a value of 0.5 should be sufficient for most scenes.
.samples : UniformNode.<float>How many samples are used to compute the AO. A higher value results in better quality but also in a more expensive runtime behavior.
.scale : UniformNode.<float>The scale of the ambient occlusion.
.thickness : UniformNode.<float>The thickness of the ambient occlusion.
.updateBeforeType : stringThe updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().
.useTemporalFiltering : booleanWhether to use temporal filtering or not. Setting this property to true requires the usage of TRAANode. This will help to reduce noise although it introduces typical TAA artifacts like ghosting a…

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.
.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. GTAONode extends: EventDispatcher → Node → TempNode
  2. Most relevant properties: depthNode, distanceExponent, distanceFallOff, normalNode.
  3. Key methods: dispose, getTextureNode, setSize, setup.

Connects To