Skip to content

Commit

Permalink
LensflareNode, OutlineNode: Added *Node suffix (#29719)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag authored Oct 21, 2024
1 parent cdc33fe commit 9aa74de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions examples/jsm/tsl/display/LensflareNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class LensflareNode extends TempNode {
downSampleRatio = 4
} = params;

this.ghostTint = ghostTint;
this.threshold = threshold;
this.ghostSamples = ghostSamples;
this.ghostSpacing = ghostSpacing;
this.ghostAttenuationFactor = ghostAttenuationFactor;
this.ghostTintNode = nodeObject( ghostTint );
this.thresholdNode = nodeObject( threshold );
this.ghostSamplesNode = nodeObject( ghostSamples );
this.ghostSpacingNode = nodeObject( ghostSpacing );
this.ghostAttenuationFactorNode = nodeObject( ghostAttenuationFactor );
this.downSampleRatio = downSampleRatio;

this.updateBeforeType = NodeUpdateType.FRAME;
Expand Down Expand Up @@ -109,13 +109,13 @@ class LensflareNode extends TempNode {

// ghosts are positioned along this vector

const ghostVec = sub( vec2( 0.5 ), texCoord ).mul( this.ghostSpacing ).toVar();
const ghostVec = sub( vec2( 0.5 ), texCoord ).mul( this.ghostSpacingNode ).toVar();

// sample ghosts

const result = vec4().toVar();

Loop( { start: int( 0 ), end: int( this.ghostSamples ), type: 'int', condition: '<' }, ( { i } ) => {
Loop( { start: int( 0 ), end: int( this.ghostSamplesNode ), type: 'int', condition: '<' }, ( { i } ) => {

// use fract() to ensure that the texture coordinates wrap around

Expand All @@ -124,13 +124,13 @@ class LensflareNode extends TempNode {
// reduce contributions from samples at the screen edge

const d = distance( sampleUv, vec2( 0.5 ) );
const weight = pow( d.oneMinus(), this.ghostAttenuationFactor );
const weight = pow( d.oneMinus(), this.ghostAttenuationFactorNode );

// accumulate

let sample = this.textureNode.uv( sampleUv ).rgb;

sample = max( sample.sub( this.threshold ), vec3( 0 ) ).mul( this.ghostTint );
sample = max( sample.sub( this.thresholdNode ), vec3( 0 ) ).mul( this.ghostTintNode );

result.addAssign( sample.mul( weight ) );

Expand Down
8 changes: 4 additions & 4 deletions examples/jsm/tsl/display/OutlineNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class OutlineNode extends TempNode {
this.scene = scene;
this.camera = camera;
this.selectedObjects = selectedObjects;
this.edgeThicknessNode = nodeObject( edgeThickness );
this.edgeGlowNode = nodeObject( edgeGlow );
this.downSampleRatio = downSampleRatio;
this.edgeThickness = edgeThickness;
this.edgeGlow = edgeGlow;

this.updateBeforeType = NodeUpdateType.FRAME;

Expand Down Expand Up @@ -360,7 +360,7 @@ class OutlineNode extends TempNode {

} );

this._separableBlurMaterial.fragmentNode = seperableBlur( this.edgeThickness );
this._separableBlurMaterial.fragmentNode = seperableBlur( this.edgeThicknessNode );
this._separableBlurMaterial.needsUpdate = true;

this._separableBlurMaterial2.fragmentNode = seperableBlur( MAX_RADIUS );
Expand All @@ -374,7 +374,7 @@ class OutlineNode extends TempNode {
const edgeValue2 = this._edge2TextureUniform;
const maskColor = this._maskTextureUniform;

const edgeValue = edgeValue1.add( edgeValue2.mul( this.edgeGlow ) );
const edgeValue = edgeValue1.add( edgeValue2.mul( this.edgeGlowNode ) );

return maskColor.r.mul( edgeValue );

Expand Down

0 comments on commit 9aa74de

Please sign in to comment.