Capítulo 449 de 859

Chapter 449: PassNode

Core Idea

Represents a render pass (sometimes called beauty pass) in context of post processing. This pass produces a render for the given scene and camera and can provide multiple outputs via MRT for further processing.

Key Concepts

  • camera : Camera: A reference to the camera.
  • contextNode : ContextNode | null: An optional global context for the pass.
  • global : boolean: This flag is used for global cache.
  • isPassNode : boolean (readonly): This flag can be used for type testing.
  • opaque : boolean: Whether the pass is opaque.
  • options : Object: Options for the internal render target.
  • overrideMaterial : Material | null: An optional override material for the pass.
  • renderTarget : RenderTarget: The pass's render target.
  • scene : Scene: A reference to the scene.
  • scope : 'color' | 'depth': The scope of the pass. The scope determines whether the node outputs color or depth.

Code Examples

const postProcessing = new RenderPipeline( renderer );
const scenePass = pass( scene, camera );
postProcessing.outputNode = scenePass;
  • What it demonstrates: Typical usage of PassNode.

Reference Tables

Constructor

Signature
`new PassNode( scope : 'color'

Properties

PropertyDescription
.camera : CameraA reference to the camera.
`.contextNode : ContextNodenull`
.global : booleanThis flag is used for global cache.
.isPassNode : boolean (readonly)This flag can be used for type testing.
.opaque : booleanWhether the pass is opaque.
.options : ObjectOptions for the internal render target.
`.overrideMaterial : Materialnull`
.renderTarget : RenderTargetThe pass's render target.
.scene : SceneA reference to the scene.
`.scope : 'color''depth'`
.transparent : booleanWhether the pass is transparent.
.updateBeforeType : stringThe updateBeforeType is set to NodeUpdateType.FRAME since the node renders the scene once per frame in its PassNode#updateBefore method.
.COLOR : 'color'
.DEPTH : 'depth'

Methods

MethodDescription
.compileAsync( renderer : Renderer ) : Promise (async)Precompiles the pass.
.dispose()Frees internal resources. Should be called when the node is no longer in use.
.getLayers() : LayersGets the current layer configuration of the pass.
.getLinearDepthNode( name : string ) : NodeReturns a linear depth node of this pass.
.getMRT() : MRTNodeReturns the current MRT node.
.getPreviousTexture( name : string ) : TextureReturns the texture holding the data of the previous frame for the given output name.
.getPreviousTextureNode( name : string ) : TextureNodeReturns the previous texture node for the given output name.
.getResolution() : numberGets the current resolution of the pass.
.getResolutionScale() : numberGets the current resolution scale of the pass.
.getTexture( name : string ) : TextureReturns the texture for the given output name.
.getTextureNode( name : string ) : TextureNodeReturns the texture node for the given output name.
.getViewZNode( name : string ) : NodeReturns a viewZ node of this pass.
.setLayers( layers : Layers ) : PassNodeSets the layer configuration that should be used when rendering the pass.
.setMRT( mrt : MRTNode ) : PassNodeSets the given MRT node to setup MRT for this pass.
.setResolution( resolution : number ) : PassNodeSets the resolution for the pass. The resolution is a factor that is multiplied with the renderer's width and height.
.setResolutionScale( resolutionScale : number ) : PassNodeSets the resolution scale for the pass. The resolution scale is a factor that is multiplied with the renderer's width and height.
`.setScissor( x : numberVector4, y : number, width : number, height : number )`
.setSize( width : number, height : number )Sets the size of the pass's render target. Honors the pixel ratio.
`.setViewport( x : numberVector4, y : number, width : number, height : number )`
.toggleTexture( name : string )Switches current and previous textures for the given output name.

Key Takeaways

  1. PassNode extends: EventDispatcher → Node → TempNode
  2. Most relevant properties: camera, contextNode, global, isPassNode.
  3. Key methods: compileAsync, dispose, getLayers, getLinearDepthNode.

Connects To