You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the WebGL2 backend of WebGPURenderer with a LinearSRGBColorSpace is used in Three.js r173, the z-buffering appears broken - i.e. objects are drawn as if no z-buffering is used, or as if depth testing/writing is turned off. The problem does not appear if any of these things is done:
an older release is used, e.g. r172
a WebGPU browser is used (thus no fallback to WebGL2 backend)
SRGBColorSpace is used instead of LinearSRGBColorSpace
A side node: is there a way to force WebGPURenderer to use WebGL2 backend for testing/debug purposes? Currently I have to switch between two browsers - Chrome for WebGPU and Firefox for WebGL2 backend.
Reproduction steps
Create a scene with two objects that intersect
Use WebGPURenderer from r173 with outputColorSpace set to LinearSRGBColorSpace
Run in a non-WebGPU browser, so the WebGL2 backend is used
One of the objects will be draw on top of the other, without expected intersection
import*asTHREEfrom"three";varcamera=newTHREE.PerspectiveCamera(60,innerWidth/innerHeight);camera.position.set(0,0,10);varscene=newTHREE.Scene();scene.add(newTHREE.Mesh(newTHREE.BoxGeometry(2,2,2),newTHREE.MeshBasicNodeMaterial({color: 'red'})),newTHREE.Mesh(newTHREE.BoxGeometry(4,1,1),newTHREE.MeshBasicNodeMaterial({color: 'tan'})));varrenderer=newTHREE.WebGPURenderer();renderer.setSize(innerWidth,innerHeight);document.body.appendChild(renderer.domElement);renderer.setAnimationLoop(animationLoop);functionanimationLoop(t){scene.rotation.y=t/1000;renderer.renderAsync(scene,camera);}// remove next line to show well intersecting boxesrenderer.outputColorSpace=THREE.LinearSRGBColorSpace;
Description
When the WebGL2 backend of
WebGPURenderer
with aLinearSRGBColorSpace
is used in Three.js r173, the z-buffering appears broken - i.e. objects are drawn as if no z-buffering is used, or as if depth testing/writing is turned off. The problem does not appear if any of these things is done:SRGBColorSpace
is used instead ofLinearSRGBColorSpace
A side node: is there a way to force
WebGPURenderer
to use WebGL2 backend for testing/debug purposes? Currently I have to switch between two browsers - Chrome for WebGPU and Firefox for WebGL2 backend.Reproduction steps
WebGPURenderer
from r173 withoutputColorSpace
set toLinearSRGBColorSpace
Code
Import maps:
JS code:
Live example
Screenshots
Wrong rendering: overlapping boxes with
LinearSRGBColorSpace
Correct rendering: intersecting boxes without
LinearSRGBColorSpace
Version
r173
Device
Desktop
Browser
Firefox
OS
Windows
The text was updated successfully, but these errors were encountered: