|
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, interleavedGradientNoise } 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, countOneBits, interleavedGradientNoise } from 'three/tsl'; |
3 | 3 |
|
4 | 4 | const _quadMesh = /*@__PURE__*/ new QuadMesh(); |
5 | 5 | const _size = /*@__PURE__*/ new Vector2(); |
@@ -435,22 +435,6 @@ class SSGINode extends TempNode { |
435 | 435 | ] |
436 | 436 | } ); |
437 | 437 |
|
438 | | - const bitCount = Fn( ( [ value ] ) => { |
439 | | - |
440 | | - const v = uint( value ); |
441 | | - v.assign( v.sub( v.shiftRight( uint( 1 ) ).bitAnd( uint( 0x55555555 ) ) ) ); |
442 | | - v.assign( v.bitAnd( uint( 0x33333333 ) ).add( v.shiftRight( uint( 2 ) ).bitAnd( uint( 0x33333333 ) ) ) ); |
443 | | - |
444 | | - return v.add( v.shiftRight( uint( 4 ) ) ).bitAnd( uint( 0xF0F0F0F ) ).mul( uint( 0x1010101 ) ).shiftRight( uint( 24 ) ); |
445 | | - |
446 | | - } ).setLayout( { |
447 | | - name: 'bitCount', |
448 | | - type: 'uint', |
449 | | - inputs: [ |
450 | | - { name: 'value', type: 'uint' } |
451 | | - ] |
452 | | - } ); |
453 | | - |
454 | 438 | const horizonSampling = Fn( ( [ directionIsRight, RADIUS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ] ) => { |
455 | 439 |
|
456 | 440 | const STEP_COUNT = this.stepCount.toConst(); |
@@ -513,7 +497,7 @@ class SSGINode extends TempNode { |
513 | 497 | currentOccludedBitfield = currentOccludedBitfield.bitAnd( globalOccludedBitfield.bitNot() ); |
514 | 498 |
|
515 | 499 | globalOccludedBitfield.assign( globalOccludedBitfield.bitOr( currentOccludedBitfield ) ); |
516 | | - const numOccludedZones = bitCount( currentOccludedBitfield ); |
| 500 | + const numOccludedZones = countOneBits( currentOccludedBitfield ); |
517 | 501 |
|
518 | 502 | // |
519 | 503 |
|
@@ -597,7 +581,7 @@ class SSGINode extends TempNode { |
597 | 581 | color.addAssign( horizonSampling( bool( true ), RADIUS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ) ); |
598 | 582 | color.addAssign( horizonSampling( bool( false ), RADIUS, viewPosition, slideDirTexelSize, initialRayStep, uvNode, viewDir, viewNormal, n ) ); |
599 | 583 |
|
600 | | - ao.addAssign( float( bitCount( globalOccludedBitfield ) ).div( float( MAX_RAY ) ) ); |
| 584 | + ao.addAssign( float( countOneBits( globalOccludedBitfield ) ).div( float( MAX_RAY ) ) ); |
601 | 585 |
|
602 | 586 | } ); |
603 | 587 |
|
|
0 commit comments