Skip to content

Commit af85042

Browse files
committed
Merge branch 'dev' into devtools
2 parents 68bf958 + 2cb9218 commit af85042

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

examples/webgl_clipping_advanced.html

+8-6
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,20 @@
208208
clipShadows: true
209209
} );
210210

211-
object = new THREE.Group();
212-
211+
const count = 5 * 5 * 5;
213212
const geometry = new THREE.BoxGeometry( 0.18, 0.18, 0.18 );
213+
object = new THREE.InstancedMesh( geometry, clipMaterial, count );
214+
object.castShadow = true;
215+
216+
let i = 0;
217+
const matrix = new THREE.Matrix4();
214218

215219
for ( let z = - 2; z <= 2; ++ z )
216220
for ( let y = - 2; y <= 2; ++ y )
217221
for ( let x = - 2; x <= 2; ++ x ) {
218222

219-
const mesh = new THREE.Mesh( geometry, clipMaterial );
220-
mesh.position.set( x / 5, y / 5, z / 5 );
221-
mesh.castShadow = true;
222-
object.add( mesh );
223+
matrix.setPosition( x / 5, y / 5, z / 5 );
224+
object.setMatrixAt( i ++, matrix );
223225

224226
}
225227

src/renderers/webgpu/nodes/WGSLNodeBuilder.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -534,20 +534,30 @@ class WGSLNodeBuilder extends NodeBuilder {
534534
*/
535535
generateTextureLoad( texture, textureProperty, uvIndexSnippet, depthSnippet, levelSnippet = '0u' ) {
536536

537+
let snippet;
538+
537539
if ( texture.isVideoTexture === true || texture.isStorageTexture === true ) {
538540

539-
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
541+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
540542

541543
} else if ( depthSnippet ) {
542544

543-
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
545+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
544546

545547
} else {
546548

547-
return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
549+
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
550+
551+
if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {
552+
553+
snippet += '.x';
554+
555+
}
548556

549557
}
550558

559+
return snippet;
560+
551561
}
552562

553563
/**
@@ -1668,7 +1678,15 @@ ${ flowData.code }
16681678

16691679
} else if ( texture.isDepthTexture === true ) {
16701680

1671-
textureType = `texture_depth${ multisampled }_2d${ texture.isDepthArrayTexture === true ? '_array' : '' }`;
1681+
if ( this.renderer.backend.compatibilityMode && texture.compareFunction === null ) {
1682+
1683+
textureType = `texture${ multisampled }_2d<f32>`;
1684+
1685+
} else {
1686+
1687+
textureType = `texture_depth${ multisampled }_2d${ texture.isDepthArrayTexture === true ? '_array' : '' }`;
1688+
1689+
}
16721690

16731691
} else if ( texture.isVideoTexture === true ) {
16741692

src/renderers/webgpu/utils/WebGPUBindingUtils.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
2-
GPUTextureAspect, GPUTextureViewDimension, GPUTextureSampleType, GPUBufferBindingType, GPUStorageTextureAccess
2+
GPUTextureAspect, GPUTextureViewDimension, GPUTextureSampleType, GPUBufferBindingType, GPUStorageTextureAccess,
3+
GPUSamplerBindingType
34
} from './WebGPUConstants.js';
45

56
import { FloatType, IntType, UnsignedIntType } from '../../../constants.js';
@@ -100,7 +101,11 @@ class WebGPUBindingUtils {
100101

101102
if ( binding.texture.compareFunction !== null ) {
102103

103-
sampler.type = 'comparison';
104+
sampler.type = GPUSamplerBindingType.Comparison;
105+
106+
} else if ( backend.compatibilityMode ) {
107+
108+
sampler.type = GPUSamplerBindingType.NonFiltering;
104109

105110
}
106111

@@ -155,7 +160,15 @@ class WebGPUBindingUtils {
155160

156161
if ( binding.texture.isDepthTexture ) {
157162

158-
texture.sampleType = GPUTextureSampleType.Depth;
163+
if ( backend.compatibilityMode && binding.texture.compareFunction === null ) {
164+
165+
texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
166+
167+
} else {
168+
169+
texture.sampleType = GPUTextureSampleType.Depth;
170+
171+
}
159172

160173
} else if ( binding.texture.isDataTexture || binding.texture.isDataArrayTexture || binding.texture.isData3DTexture ) {
161174

0 commit comments

Comments
 (0)