|
@@ -21,7 +21,7 @@ class ViewportDepthNode extends Node {
|
|
|
|
|
|
|
|
const { scope } = this;
|
|
const { scope } = this;
|
|
|
|
|
|
|
|
- if ( scope === ViewportDepthNode.DEPTH ) {
|
|
|
|
|
|
|
+ if ( scope === ViewportDepthNode.DEPTH_BASE ) {
|
|
|
|
|
|
|
|
return builder.getFragDepth();
|
|
return builder.getFragDepth();
|
|
|
|
|
|
|
@@ -34,43 +34,43 @@ class ViewportDepthNode extends Node {
|
|
|
setup( { camera } ) {
|
|
setup( { camera } ) {
|
|
|
|
|
|
|
|
const { scope } = this;
|
|
const { scope } = this;
|
|
|
- const texture = this.valueNode;
|
|
|
|
|
|
|
+ const value = this.valueNode;
|
|
|
|
|
|
|
|
let node = null;
|
|
let node = null;
|
|
|
|
|
|
|
|
- if ( scope === ViewportDepthNode.DEPTH ) {
|
|
|
|
|
|
|
+ if ( scope === ViewportDepthNode.DEPTH_BASE ) {
|
|
|
|
|
|
|
|
- if ( texture !== null ) {
|
|
|
|
|
|
|
+ if ( value !== null ) {
|
|
|
|
|
|
|
|
- node = depthBase().assign( texture );
|
|
|
|
|
|
|
+ node = depthBase().assign( value );
|
|
|
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if ( camera.isPerspectiveCamera ) {
|
|
|
|
|
|
|
+ } else if ( scope === ViewportDepthNode.DEPTH ) {
|
|
|
|
|
|
|
|
- node = viewZToPerspectiveDepth( positionView.z, cameraNear, cameraFar );
|
|
|
|
|
|
|
+ if ( camera.isPerspectiveCamera ) {
|
|
|
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ node = viewZToPerspectiveDepth( positionView.z, cameraNear, cameraFar );
|
|
|
|
|
|
|
|
- node = viewZToOrthographicDepth( positionView.z, cameraNear, cameraFar );
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ node = viewZToOrthographicDepth( positionView.z, cameraNear, cameraFar );
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else if ( scope === ViewportDepthNode.LINEAR_DEPTH ) {
|
|
} else if ( scope === ViewportDepthNode.LINEAR_DEPTH ) {
|
|
|
|
|
|
|
|
- if ( texture !== null ) {
|
|
|
|
|
|
|
+ if ( value !== null ) {
|
|
|
|
|
|
|
|
if ( camera.isPerspectiveCamera ) {
|
|
if ( camera.isPerspectiveCamera ) {
|
|
|
|
|
|
|
|
- const viewZ = perspectiveDepthToViewZ( texture, cameraNear, cameraFar );
|
|
|
|
|
|
|
+ const viewZ = perspectiveDepthToViewZ( value, cameraNear, cameraFar );
|
|
|
|
|
|
|
|
node = viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
node = viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
- node = texture;
|
|
|
|
|
|
|
+ node = value;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -104,12 +104,13 @@ export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ )
|
|
|
// maps perspective depth in [ 0, 1 ] to viewZ
|
|
// maps perspective depth in [ 0, 1 ] to viewZ
|
|
|
export const perspectiveDepthToViewZ = ( depth, near, far ) => near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) );
|
|
export const perspectiveDepthToViewZ = ( depth, near, far ) => near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) );
|
|
|
|
|
|
|
|
|
|
+ViewportDepthNode.DEPTH_BASE = 'depthBase';
|
|
|
ViewportDepthNode.DEPTH = 'depth';
|
|
ViewportDepthNode.DEPTH = 'depth';
|
|
|
ViewportDepthNode.LINEAR_DEPTH = 'linearDepth';
|
|
ViewportDepthNode.LINEAR_DEPTH = 'linearDepth';
|
|
|
|
|
|
|
|
export default ViewportDepthNode;
|
|
export default ViewportDepthNode;
|
|
|
|
|
|
|
|
-const depthBase = nodeProxy( ViewportDepthNode, ViewportDepthNode.DEPTH );
|
|
|
|
|
|
|
+const depthBase = nodeProxy( ViewportDepthNode, ViewportDepthNode.DEPTH_BASE );
|
|
|
|
|
|
|
|
export const depth = nodeImmutable( ViewportDepthNode, ViewportDepthNode.DEPTH );
|
|
export const depth = nodeImmutable( ViewportDepthNode, ViewportDepthNode.DEPTH );
|
|
|
export const linearDepth = nodeProxy( ViewportDepthNode, ViewportDepthNode.LINEAR_DEPTH );
|
|
export const linearDepth = nodeProxy( ViewportDepthNode, ViewportDepthNode.LINEAR_DEPTH );
|