Capítulo 428 de 859

Chapter 428: LensflareNode

Core Idea

Post processing node for adding a bloom-based lens flare effect. This effect requires that you extract the bloom of the scene via a bloom pass first.

References:

Key Concepts

  • downSampleRatio : number: Defines how downsampling since the effect is usually not rendered at full resolution.
  • ghostAttenuationFactorNode : Node.<float>: Defines the attenuation factor of flares/ghosts.
  • ghostSamplesNode : Node.<float>: Represents the number of flares/ghosts per bright spot which pivot around the center.
  • ghostSpacingNode : Node.<float>: Defines the spacing of the flares/ghosts.
  • ghostTintNode : Node.<vec3>: Defines the tint of the flare/ghosts.
  • textureNode : TextureNode: The texture node that represents the scene's bloom.
  • thresholdNode : Node.<float>: Controls the size and strength of the effect. A higher threshold results in smaller flares.
  • updateBeforeType : string: The updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().

Code Examples

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

Reference Tables

Constructor

Signature
new LensflareNode( textureNode : TextureNode, params : Object )

Properties

PropertyDescription
.downSampleRatio : numberDefines how downsampling since the effect is usually not rendered at full resolution.
.ghostAttenuationFactorNode : Node.<float>Defines the attenuation factor of flares/ghosts.
.ghostSamplesNode : Node.<float>Represents the number of flares/ghosts per bright spot which pivot around the center.
.ghostSpacingNode : Node.<float>Defines the spacing of the flares/ghosts.
.ghostTintNode : Node.<vec3>Defines the tint of the flare/ghosts.
.textureNode : TextureNodeThe texture node that represents the scene's bloom.
.thresholdNode : Node.<float>Controls the size and strength of the effect. A higher threshold results in smaller flares.
.updateBeforeType : stringThe updateBeforeType is set to NodeUpdateType.FRAME since the node renders its effect once per frame in updateBefore().

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. LensflareNode extends: EventDispatcher → Node → TempNode
  2. Most relevant properties: downSampleRatio, ghostAttenuationFactorNode, ghostSamplesNode, ghostSpacingNode.
  3. Key methods: dispose, getTextureNode, setSize, setup.

Connects To