Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer: Align depth range of WebGPU and WebGL backends #28065

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions examples/jsm/nodes/display/ViewportDepthNode.js
Expand Up @@ -3,7 +3,7 @@ import { nodeImmutable, nodeProxy } from '../shadernode/ShaderNode.js';
import { cameraNear, cameraFar } from '../accessors/CameraNode.js';
import { positionView } from '../accessors/PositionNode.js';
import { viewportDepthTexture } from './ViewportDepthTextureNode.js';

import { WebGLCoordinateSystem } from 'three';
class ViewportDepthNode extends Node {

constructor( scope, valueNode = null ) {
Expand Down Expand Up @@ -31,7 +31,7 @@ class ViewportDepthNode extends Node {

}

setup( /*builder*/ ) {
setup( builder ) {

const { scope } = this;

Expand All @@ -52,7 +52,16 @@ class ViewportDepthNode extends Node {

if ( this.valueNode !== null ) {

node = depthPixelBase().assign( this.valueNode );
let depth = this.valueNode;

// WebGL: Conversion [ -1, 0 ] to [ 0, 1 ], without EXT_depth_clamp extension WebGL internally clamps these values to the range [0, 1] during the rasterization process
if ( builder.renderer.coordinateSystem === WebGLCoordinateSystem ) {

depth = depth.add( 1 ).div( 2 );

}

node = depthPixelBase().assign( depth );

}

Expand Down