Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/jsm/objects/Reflector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );

Expand Down
13 changes: 8 additions & 5 deletions src/materials/nodes/manager/NodeMaterialObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

}
Expand Down Expand Up @@ -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;
Expand Down
73 changes: 21 additions & 52 deletions src/nodes/lighting/ShadowFilterNode.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 );

} );
Expand Down
16 changes: 14 additions & 2 deletions src/renderers/common/RenderObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

}

Expand Down Expand Up @@ -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;

Expand Down