Skip to content

Commit 4e1e0d1

Browse files
authored
SSGINode: Distinct between uv and direction sampling. (#31865)
* SSGINode: Distinct between uv and direction sampling. * SSGINode: Remove comment.
1 parent 1aeae99 commit 4e1e0d1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/jsm/tsl/display/SSGINode.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ class SSGINode extends TempNode {
472472

473473
stepRadius.divAssign( float( STEP_COUNT ).add( 1 ) );
474474
const radiusVS = max( 1, float( STEP_COUNT.sub( 1 ) ) ).mul( stepRadius );
475-
const samplingDirection = directionIsRight.equal( true ).select( vec2( 1, - 1 ), vec2( - 1, 1 ) ); // Port note: Because of different uv conventions, uv-y has a different sign
475+
const uvDirection = directionIsRight.equal( true ).select( vec2( 1, - 1 ), vec2( - 1, 1 ) ); // Port note: Because of different uv conventions, uv-y has a different sign
476+
const samplingDirection = directionIsRight.equal( true ).select( 1, - 1 );
476477

477478
const color = vec3( 0 );
478479
const occludedBitfield = uint( globalOccludedBitfield ).toVar();
@@ -483,7 +484,7 @@ class SSGINode extends TempNode {
483484

484485
const offset = pow( abs( mul( stepRadius, float( i ).add( initialRayStep ) ).div( radiusVS ) ), EXP_FACTOR ).mul( radiusVS ).toConst();
485486
const uvOffset = slideDirTexelSize.mul( max( offset, float( i ).add( 1 ) ) ).toConst();
486-
const sampleUV = uvNode.add( uvOffset.mul( samplingDirection ) ).toConst();
487+
const sampleUV = uvNode.add( uvOffset.mul( uvDirection ) ).toConst();
487488

488489
If( sampleUV.x.lessThanEqual( 0 ).or( sampleUV.y.lessThanEqual( 0 ) ).or( sampleUV.x.greaterThanEqual( 1 ) ).or( sampleUV.y.greaterThanEqual( 1 ) ), () => {
489490

@@ -498,7 +499,7 @@ class SSGINode extends TempNode {
498499

499500
let frontBackHorizon = vec2( dot( pixelToSample, viewDir ), dot( pixelToSampleBackface, viewDir ) );
500501
frontBackHorizon = GTAOFastAcos( clamp( frontBackHorizon, - 1, 1 ) );
501-
frontBackHorizon = clamp( div( mul( samplingDirection, vec2( frontBackHorizon.x.negate(), frontBackHorizon.y ) ).sub( n.sub( HALF_PI ) ), PI ) ); // Port note: This line also required an update because of different uv conventions
502+
frontBackHorizon = clamp( div( mul( samplingDirection, frontBackHorizon.negate() ).sub( n.sub( HALF_PI ) ), PI ) );
502503
frontBackHorizon = directionIsRight.equal( true ).select( frontBackHorizon.yx, frontBackHorizon.xy ); // Front/Back get inverted depending on angle
503504

504505
const result = computeOccludedBitfield( frontBackHorizon.x, frontBackHorizon.y, occludedBitfield );

0 commit comments

Comments
 (0)