Skip to content

Commit

Permalink
add multi-sampler support
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Oct 11, 2024
1 parent 5c932e2 commit b48197c
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions src/nodes/utils/ReflectorNode.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Node from '../core/Node.js';
import TextureNode from '../accessors/TextureNode.js';
import { nodeObject } from '../tsl/TSLBase.js';
import { NodeUpdateType } from '../core/constants.js';
Expand Down Expand Up @@ -43,6 +44,57 @@ class ReflectorNode extends TextureNode {

super( _defaultRT.texture, _defaultUV );

this._reflectorBaseNode = new ReflectorBaseNode( this, parameters );

this.setUpdateMatrix( false );

}

get reflector() {

return this._reflectorBaseNode;

}

get target() {

return this._reflectorBaseNode.target;

}

setup( builder ) {

// ignore if used in post-processing
if ( ! builder.object.isQuadMesh ) this._reflectorBaseNode.build( builder );

return super.setup( builder );

}

clone() {

const texture = new this.constructor( this.reflectorNode );
texture._reflectorBaseNode = this._reflectorBaseNode;

return texture;

}

}


class ReflectorBaseNode extends Node {

static get type() {

return 'ReflectorBaseNode';

}

constructor( textureNode, parameters = {} ) {

super();

const {
target = new Object3D(),
resolution = 1,
Expand All @@ -52,6 +104,8 @@ class ReflectorNode extends TextureNode {

//

this.textureNode = textureNode;

this.target = target;
this.resolution = resolution;
this.generateMipmaps = generateMipmaps;
Expand All @@ -62,7 +116,6 @@ class ReflectorNode extends TextureNode {
this.virtualCameras = new WeakMap();
this.renderTargets = new WeakMap();


}

_updateResolution( renderTarget, renderer ) {
Expand Down Expand Up @@ -124,7 +177,7 @@ class ReflectorNode extends TextureNode {

updateBefore( frame ) {

if ( this.bounces === false && _inReflector ) return false;
if ( this.bounces === false && _inReflector ) return;

_inReflector = true;

Expand Down Expand Up @@ -209,7 +262,7 @@ class ReflectorNode extends TextureNode {

//

this.value = renderTarget.texture;
this.textureNode.value = renderTarget.texture;

material.visible = false;

Expand Down

0 comments on commit b48197c

Please sign in to comment.