diff --git a/examples/jsm/renderers/webgpu/WebGPUTextures.js b/examples/jsm/renderers/webgpu/WebGPUTextures.js index a21b333dce3933..c27511f27fab4a 100644 --- a/examples/jsm/renderers/webgpu/WebGPUTextures.js +++ b/examples/jsm/renderers/webgpu/WebGPUTextures.js @@ -2,7 +2,7 @@ import { GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension } import { VideoTexture, CubeTexture, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, RepeatWrapping, MirroredRepeatWrapping, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthTexture, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, - RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format + RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType } from 'three'; import WebGPUTextureUtils from './WebGPUTextureUtils.js'; @@ -806,7 +806,26 @@ class WebGPUTextures { break; case DepthFormat: - formatGPU = GPUTextureFormat.Depth32Float; + + switch ( type ) { + + case UnsignedShortType: + formatGPU = GPUTextureFormat.Depth16Unorm; + break; + + case UnsignedIntType: + formatGPU = GPUTextureFormat.Depth24Plus; + break; + + case FloatType: + formatGPU = GPUTextureFormat.Depth32Float; + break; + + default: + console.error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type ); + + } + break; default: diff --git a/examples/jsm/renderers/webgpu/constants.js b/examples/jsm/renderers/webgpu/constants.js index cb8b70b5deba6d..a80a1cd594750a 100644 --- a/examples/jsm/renderers/webgpu/constants.js +++ b/examples/jsm/renderers/webgpu/constants.js @@ -138,6 +138,10 @@ export const GPUTextureFormat = { Depth24PlusStencil8: 'depth24plus-stencil8', Depth32Float: 'depth32float', + // 'depth32float-stencil8' extension + + Depth32FloatStencil8: 'depth32float-stencil8', + // BC compressed formats usable if 'texture-compression-bc' is both // supported by the device/user agent and enabled in requestDevice. @@ -202,14 +206,6 @@ export const GPUTextureFormat = { ASTC12x12Unorm: 'astc-12x12-unorm', ASTC12x12UnormSRGB: 'astc-12x12-unorm-srgb', - // 'depth24unorm-stencil8' extension - - Depth24UnormStencil8: 'depth24unorm-stencil8', - - // 'depth32float-stencil8' extension - - Depth32FloatStencil8: 'depth32float-stencil8', - }; export const GPUAddressMode = { diff --git a/examples/webgpu_depth_texture.html b/examples/webgpu_depth_texture.html index 883b04196e715e..8caf557f1f7297 100644 --- a/examples/webgpu_depth_texture.html +++ b/examples/webgpu_depth_texture.html @@ -26,7 +26,7 @@