|
1 | 1 | import { RenderTarget, Vector2, TempNode, QuadMesh, NodeMaterial, RendererUtils, MathUtils } from 'three/webgpu'; |
2 | | -import { clamp, normalize, reference, nodeObject, Fn, NodeUpdateType, uniform, vec4, passTexture, uv, logarithmicDepthToViewZ, viewZToPerspectiveDepth, getViewPosition, screenCoordinate, float, sub, fract, dot, vec2, rand, vec3, Loop, mul, PI, cos, sin, uint, cross, acos, sign, pow, luminance, If, max, abs, Break, sqrt, HALF_PI, div, ceil, shiftRight, convertToTexture, bool, getNormalFromDepth } from 'three/tsl'; |
| 2 | +import { clamp, normalize, reference, nodeObject, Fn, NodeUpdateType, uniform, vec4, passTexture, uv, logarithmicDepthToViewZ, viewZToPerspectiveDepth, getViewPosition, screenCoordinate, float, sub, fract, dot, vec2, rand, vec3, Loop, mul, PI, cos, sin, uint, cross, acos, sign, pow, luminance, If, max, abs, Break, sqrt, HALF_PI, div, ceil, shiftRight, convertToTexture, bool, getNormalFromDepth, interleavedGradientNoise } from 'three/tsl'; |
3 | 3 |
|
4 | 4 | const _quadMesh = /*@__PURE__*/ new QuadMesh(); |
5 | 5 | const _size = /*@__PURE__*/ new Vector2(); |
@@ -413,20 +413,6 @@ class SSGINode extends TempNode { |
413 | 413 | ] |
414 | 414 | } ); |
415 | 415 |
|
416 | | - // Interleaved gradient function from Jimenez 2014 http://goo.gl/eomGso |
417 | | - |
418 | | - const gradientNoise = Fn( ( [ position ] ) => { |
419 | | - |
420 | | - return fract( float( 52.9829189 ).mul( fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ) ); |
421 | | - |
422 | | - } ).setLayout( { |
423 | | - name: 'gradientNoise', |
424 | | - type: 'float', |
425 | | - inputs: [ |
426 | | - { name: 'position', type: 'vec2' } |
427 | | - ] |
428 | | - } ); |
429 | | - |
430 | 416 | const GTAOFastAcos = Fn( ( [ value ] ) => { |
431 | 417 |
|
432 | 418 | const outVal = abs( value ).mul( float( - 0.156583 ) ).add( HALF_PI ); |
@@ -576,7 +562,7 @@ class SSGINode extends TempNode { |
576 | 562 | // |
577 | 563 |
|
578 | 564 | const noiseOffset = spatialOffsets( screenCoordinate ); |
579 | | - const noiseDirection = gradientNoise( screenCoordinate ); |
| 565 | + const noiseDirection = interleavedGradientNoise( screenCoordinate ); |
580 | 566 | const noiseJitterIdx = this._temporalDirection.mul( 0.02 ); // Port: Add noiseJitterIdx here for slightly better noise convergence with TRAA (see #31890 for more details) |
581 | 567 | const initialRayStep = fract( noiseOffset.add( this._temporalOffset ) ).add( rand( uvNode.add( noiseJitterIdx ).mul( 2 ).sub( 1 ) ) ); |
582 | 568 |
|
|
0 commit comments