소스 검색

Merge branch 'dev' into devtools

Mr.doob 10 달 전
부모
커밋
af8504284e
3개의 변경된 파일46개의 추가작업 그리고 13개의 파일을 삭제
  1. 8 6
      examples/webgl_clipping_advanced.html
  2. 22 4
      src/renderers/webgpu/nodes/WGSLNodeBuilder.js
  3. 16 3
      src/renderers/webgpu/utils/WebGPUBindingUtils.js

+ 8 - 6
examples/webgl_clipping_advanced.html

@@ -208,18 +208,20 @@
 					clipShadows: true
 				} );
 
-				object = new THREE.Group();
-
+				const count = 5 * 5 * 5;
 				const geometry = new THREE.BoxGeometry( 0.18, 0.18, 0.18 );
+				object = new THREE.InstancedMesh( geometry, clipMaterial, count );
+				object.castShadow = true;
+
+				let i = 0;
+				const matrix = new THREE.Matrix4();
 
 				for ( let z = - 2; z <= 2; ++ z )
 					for ( let y = - 2; y <= 2; ++ y )
 						for ( let x = - 2; x <= 2; ++ x ) {
 
-							const mesh = new THREE.Mesh( geometry, clipMaterial );
-							mesh.position.set( x / 5, y / 5, z / 5 );
-							mesh.castShadow = true;
-							object.add( mesh );
+							matrix.setPosition( x / 5, y / 5, z / 5 );
+							object.setMatrixAt( i ++, matrix );
 
 						}
 

+ 22 - 4
src/renderers/webgpu/nodes/WGSLNodeBuilder.js

@@ -534,20 +534,30 @@ class WGSLNodeBuilder extends NodeBuilder {
 	 */
 	generateTextureLoad( texture, textureProperty, uvIndexSnippet, depthSnippet, levelSnippet = '0u' ) {
 
+		let snippet;
+
 		if ( texture.isVideoTexture === true || texture.isStorageTexture === true ) {
 
-			return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
+			snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
 
 		} else if ( depthSnippet ) {
 
-			return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
+			snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
 
 		} else {
 
-			return `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
+			snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, u32( ${ levelSnippet } ) )`;
+
+			if ( this.renderer.backend.compatibilityMode && texture.isDepthTexture ) {
+
+				snippet += '.x';
+
+			}
 
 		}
 
+		return snippet;
+
 	}
 
 	/**
@@ -1668,7 +1678,15 @@ ${ flowData.code }
 
 				} else if ( texture.isDepthTexture === true ) {
 
-					textureType = `texture_depth${ multisampled }_2d${ texture.isDepthArrayTexture === true ? '_array' : '' }`;
+					if ( this.renderer.backend.compatibilityMode && texture.compareFunction === null ) {
+
+						textureType = `texture${ multisampled }_2d<f32>`;
+
+					} else {
+
+						textureType = `texture_depth${ multisampled }_2d${ texture.isDepthArrayTexture === true ? '_array' : '' }`;
+
+					}
 
 				} else if ( texture.isVideoTexture === true ) {
 

+ 16 - 3
src/renderers/webgpu/utils/WebGPUBindingUtils.js

@@ -1,5 +1,6 @@
 import {
-	GPUTextureAspect, GPUTextureViewDimension, GPUTextureSampleType, GPUBufferBindingType, GPUStorageTextureAccess
+	GPUTextureAspect, GPUTextureViewDimension, GPUTextureSampleType, GPUBufferBindingType, GPUStorageTextureAccess,
+	GPUSamplerBindingType
 } from './WebGPUConstants.js';
 
 import { FloatType, IntType, UnsignedIntType } from '../../../constants.js';
@@ -100,7 +101,11 @@ class WebGPUBindingUtils {
 
 					if ( binding.texture.compareFunction !== null ) {
 
-						sampler.type = 'comparison';
+						sampler.type = GPUSamplerBindingType.Comparison;
+
+					} else if ( backend.compatibilityMode ) {
+
+						sampler.type = GPUSamplerBindingType.NonFiltering;
 
 					}
 
@@ -155,7 +160,15 @@ class WebGPUBindingUtils {
 
 				if ( binding.texture.isDepthTexture ) {
 
-					texture.sampleType = GPUTextureSampleType.Depth;
+					if ( backend.compatibilityMode && binding.texture.compareFunction === null ) {
+
+						texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
+
+					} else {
+
+						texture.sampleType = GPUTextureSampleType.Depth;
+
+					}
 
 				} else if ( binding.texture.isDataTexture || binding.texture.isDataArrayTexture || binding.texture.isData3DTexture ) {
 

粤ICP备19079148号