|
1 | 1 | import ShadowNode from './ShadowNode.js'; |
2 | 2 | import { uniform } from '../core/UniformNode.js'; |
3 | | -import { float, vec3, If, Fn, nodeObject } from '../tsl/TSLBase.js'; |
| 3 | +import { float, vec2, If, Fn, nodeObject } from '../tsl/TSLBase.js'; |
4 | 4 | import { reference } from '../accessors/ReferenceNode.js'; |
5 | 5 | import { cubeTexture } from '../accessors/CubeTextureNode.js'; |
6 | 6 | import { renderGroup } from '../core/UniformGroupNode.js'; |
@@ -51,17 +51,17 @@ export const PointShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, bd3D, dp, s |
51 | 51 | const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup ); |
52 | 52 |
|
53 | 53 | const texelSize = float( 1 ).div( mapSize.x ); |
54 | | - const offset = radius.mul( texelSize ); |
55 | | - |
56 | | - return cubeTexture( depthTexture, bd3D.add( vec3( offset, offset, offset ) ) ).compare( dp ) |
57 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset, offset, offset.negate() ) ) ).compare( dp ) ) |
58 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset, offset.negate(), offset ) ) ).compare( dp ) ) |
59 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset, offset.negate(), offset.negate() ) ) ).compare( dp ) ) |
60 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset.negate(), offset, offset ) ) ).compare( dp ) ) |
61 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset.negate(), offset, offset.negate() ) ) ).compare( dp ) ) |
62 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset.negate(), offset.negate(), offset ) ) ).compare( dp ) ) |
63 | | - .add( cubeTexture( depthTexture, bd3D.add( vec3( offset.negate(), offset.negate(), offset.negate() ) ) ).compare( dp ) ) |
| 54 | + const offset = vec2( - 1.0, 1.0 ).mul( radius ).mul( texelSize ); |
| 55 | + |
| 56 | + return cubeTexture( depthTexture, bd3D.add( offset.xyy ) ).compare( dp ) |
| 57 | + .add( cubeTexture( depthTexture, bd3D.add( offset.yyy ) ).compare( dp ) ) |
| 58 | + .add( cubeTexture( depthTexture, bd3D.add( offset.xyx ) ).compare( dp ) ) |
| 59 | + .add( cubeTexture( depthTexture, bd3D.add( offset.yyx ) ).compare( dp ) ) |
64 | 60 | .add( cubeTexture( depthTexture, bd3D ).compare( dp ) ) |
| 61 | + .add( cubeTexture( depthTexture, bd3D.add( offset.xxy ) ).compare( dp ) ) |
| 62 | + .add( cubeTexture( depthTexture, bd3D.add( offset.yxy ) ).compare( dp ) ) |
| 63 | + .add( cubeTexture( depthTexture, bd3D.add( offset.xxx ) ).compare( dp ) ) |
| 64 | + .add( cubeTexture( depthTexture, bd3D.add( offset.yxx ) ).compare( dp ) ) |
65 | 65 | .mul( 1.0 / 9.0 ); |
66 | 66 |
|
67 | 67 | } ); |
|
0 commit comments