diff --git a/examples/jsm/objects/Reflector.js b/examples/jsm/objects/Reflector.js index 7a415cfe8dbd95..2cb42baf510f51 100644 --- a/examples/jsm/objects/Reflector.js +++ b/examples/jsm/objects/Reflector.js @@ -115,7 +115,7 @@ class Reflector extends Mesh { this.onBeforeRender = function ( renderer, scene, camera ) { - const reflectionCamera = this._getReflectionCamera( camera ); + const reflectionCamera = this.getReflectionCamera( camera ); reflectorWorldPosition.setFromMatrixPosition( scope.matrixWorld ); cameraWorldPosition.setFromMatrixPosition( camera.matrixWorld ); @@ -278,11 +278,10 @@ class Reflector extends Mesh { * Returns a reflection camera for the given camera. The reflection camera is used to * render the scene from the reflector's view so correct reflections can be produced. * - * @private * @param {Camera} camera - The scene's camera. * @return {Camera} The corresponding reflection camera. */ - this._getReflectionCamera = function ( camera ) { + this.getReflectionCamera = function ( camera ) { let reflectionCamera = this._reflectionCameras.get( camera ); diff --git a/src/materials/nodes/manager/NodeMaterialObserver.js b/src/materials/nodes/manager/NodeMaterialObserver.js index 089b9ed47a6826..c9ed552af35e9b 100644 --- a/src/materials/nodes/manager/NodeMaterialObserver.js +++ b/src/materials/nodes/manager/NodeMaterialObserver.js @@ -242,8 +242,8 @@ class NodeMaterialObserver { const attribute = attributes[ name ]; attributesData[ name ] = { - id: attribute.id, - version: attribute.version, + id: attribute.isInterleavedBufferAttribute ? attribute.data.uuid : attribute.id, + version: attribute.isInterleavedBufferAttribute ? attribute.data.version : attribute.version, }; } @@ -501,10 +501,13 @@ class NodeMaterialObserver { } - if ( storedAttributeData.id !== attribute.id || storedAttributeData.version !== attribute.version ) { + const id = attribute.isInterleavedBufferAttribute ? attribute.data.uuid : attribute.id; + const version = attribute.isInterleavedBufferAttribute ? attribute.data.version : attribute.version; - storedAttributeData.id = attribute.id; - storedAttributeData.version = attribute.version; + if ( storedAttributeData.id !== id || storedAttributeData.version !== version ) { + + storedAttributeData.id = id; + storedAttributeData.version = version; geometryData._equal = false; return false; diff --git a/src/nodes/lighting/ShadowFilterNode.js b/src/nodes/lighting/ShadowFilterNode.js index 7dffbed2804d52..56dde4c38948ad 100644 --- a/src/nodes/lighting/ShadowFilterNode.js +++ b/src/nodes/lighting/ShadowFilterNode.js @@ -1,4 +1,4 @@ -import { float, vec2, vec4, If, Fn } from '../tsl/TSLBase.js'; +import { float, vec2, vec4, If, Fn, ivec2 } from '../tsl/TSLBase.js'; import { reference } from '../accessors/ReferenceNode.js'; import { texture } from '../accessors/TextureNode.js'; import { mix, fract, step, max, clamp } from '../math/MathNode.js'; @@ -97,69 +97,38 @@ export const PCFShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord, */ export const PCFSoftShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord, shadow, depthLayer } ) => { - const depthCompare = ( uv, compare ) => { + const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup ); - let depth = texture( depthTexture, uv ); + const texelSize = vec2( 1 ).div( mapSize ); - if ( depthTexture.isArrayTexture ) { + const uv = shadowCoord.xy; + const f = fract( uv.mul( mapSize ).add( 0.5 ) ).toConst(); + uv.subAssign( f.sub( 0.5 ).mul( texelSize ) ); - depth = depth.depth( depthLayer ); + const gatherCompare = ( offset ) => { - } + let t = texture( depthTexture, uv ).offset( offset ).gather(); - return depth.compare( compare ); + if ( depthTexture.isArrayTexture ) { - }; + t = t.depth( depthLayer ); + } - const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup ); + return t.compare( shadowCoord.z ); - const texelSize = vec2( 1 ).div( mapSize ); - const dx = texelSize.x; - const dy = texelSize.y; + }; - const uv = shadowCoord.xy; - const f = fract( uv.mul( mapSize ).add( 0.5 ) ); - uv.subAssign( f.mul( texelSize ) ); + const c1 = gatherCompare( ivec2( - 1, 1 ) ).toConst(); + const c2 = gatherCompare( ivec2( 1, 1 ) ).toConst(); + const c3 = gatherCompare( ivec2( - 1, - 1 ) ).toConst(); + const c4 = gatherCompare( ivec2( 1, - 1 ) ).toConst(); return add( - depthCompare( uv, shadowCoord.z ), - depthCompare( uv.add( vec2( dx, 0 ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( 0, dy ) ), shadowCoord.z ), - depthCompare( uv.add( texelSize ), shadowCoord.z ), - mix( - depthCompare( uv.add( vec2( dx.negate(), 0 ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( dx.mul( 2 ), 0 ) ), shadowCoord.z ), - f.x - ), - mix( - depthCompare( uv.add( vec2( dx.negate(), dy ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( dx.mul( 2 ), dy ) ), shadowCoord.z ), - f.x - ), - mix( - depthCompare( uv.add( vec2( 0, dy.negate() ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( 0, dy.mul( 2 ) ) ), shadowCoord.z ), - f.y - ), - mix( - depthCompare( uv.add( vec2( dx, dy.negate() ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( dx, dy.mul( 2 ) ) ), shadowCoord.z ), - f.y - ), - mix( - mix( - depthCompare( uv.add( vec2( dx.negate(), dy.negate() ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( dx.mul( 2 ), dy.negate() ) ), shadowCoord.z ), - f.x - ), - mix( - depthCompare( uv.add( vec2( dx.negate(), dy.mul( 2 ) ) ), shadowCoord.z ), - depthCompare( uv.add( vec2( dx.mul( 2 ), dy.mul( 2 ) ) ), shadowCoord.z ), - f.x - ), - f.y - ) + mix( c1.x, c2.y, f.x ).add( c1.y ).add( c2.x ).mul( f.y ), + mix( c1.w, c2.z, f.x ).add( c1.z ).add( c2.w ), + mix( c3.x, c4.y, f.x ).add( c3.y ).add( c4.x ), + mix( c3.w, c4.z, f.x ).add( c3.z ).add( c4.w ).mul( f.y.oneMinus() ) ).mul( 1 / 9 ); } ); diff --git a/src/renderers/common/RenderObject.js b/src/renderers/common/RenderObject.js index 7ce552eae7fd5f..a50a9e62af6a71 100644 --- a/src/renderers/common/RenderObject.js +++ b/src/renderers/common/RenderObject.js @@ -514,7 +514,15 @@ class RenderObject { if ( attribute !== undefined ) { - attributesId[ nodeAttribute.name ] = attribute.id; + if ( attribute.isInterleavedBufferAttribute ) { + + attributesId[ nodeAttribute.name ] = attribute.data.uuid; + + } else { + + attributesId[ nodeAttribute.name ] = attribute.id; + + } } @@ -819,7 +827,11 @@ class RenderObject { const attribute = this.geometry.getAttribute( name ); - if ( attribute === undefined || attributesId[ name ] !== attribute.id ) { + if ( attribute === undefined ) return true; + + const id = attribute.isInterleavedBufferAttribute ? attribute.data.uuid : attribute.id; + + if ( attributesId[ name ] !== id ) { return true;