Skip to content

Commit 95a994c

Browse files
ycwsunag
andauthored
WebGPUBackend: Fix Occlusion Query Logic (#30288)
* fix * Update WebGLBackend.js * Update webgpu_occlusion.html --------- Co-authored-by: sunag <[email protected]>
1 parent 055364a commit 95a994c

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

examples/webgpu_occlusion.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
const plane = new THREE.Mesh( planeGeometry, new THREE.MeshPhongNodeMaterial( { color: 0x00ff00, side: THREE.DoubleSide } ) );
9393
const sphere = new THREE.Mesh( sphereGeometry, new THREE.MeshPhongNodeMaterial( { color: 0xffff00 } ) );
9494

95-
const instanceUniform = nodeObject( new OcclusionNode( sphere, new THREE.Color( 0x00ff00 ), new THREE.Color( 0x0000ff ) ) );
95+
const instanceUniform = nodeObject( new OcclusionNode( sphere, new THREE.Color( 0x0000ff ), new THREE.Color( 0x00ff00 ) ) );
9696

9797
plane.material.colorNode = instanceUniform;
9898

@@ -107,11 +107,6 @@
107107
renderer = new THREE.WebGPURenderer( { antialias: true } );
108108
renderer.setPixelRatio( window.devicePixelRatio );
109109
renderer.setSize( window.innerWidth, window.innerHeight );
110-
111-
// ensure shaders/pipelines are all complete before rendering
112-
113-
await renderer.compileAsync( scene, camera );
114-
115110
renderer.setAnimationLoop( render );
116111
document.body.appendChild( renderer.domElement );
117112

src/renderers/webgl-fallback/WebGLBackend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ class WebGLBackend extends Backend {
611611

612612
if ( gl.getQueryParameter( query, gl.QUERY_RESULT_AVAILABLE ) ) {
613613

614-
if ( gl.getQueryParameter( query, gl.QUERY_RESULT ) > 0 ) occluded.add( currentOcclusionQueryObjects[ i ] );
614+
if ( gl.getQueryParameter( query, gl.QUERY_RESULT ) === 0 ) occluded.add( currentOcclusionQueryObjects[ i ] );
615615

616616
currentOcclusionQueries[ i ] = null;
617617
gl.deleteQuery( query );

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class WebGPUBackend extends Backend {
787787

788788
for ( let i = 0; i < currentOcclusionQueryObjects.length; i ++ ) {
789789

790-
if ( results[ i ] !== BigInt( 0 ) ) {
790+
if ( results[ i ] === BigInt( 0 ) ) {
791791

792792
occluded.add( currentOcclusionQueryObjects[ i ] );
793793

0 commit comments

Comments
 (0)