Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved handling of VSM32 on WebGPU #5684

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/platform/graphics/graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ class GraphicsDevice extends EventHandler {
*/
textureHalfFloatRenderable;

/**
* True if filtering can be applied when sampling float textures.
*
* @type {boolean}
* @readonly
*/
textureFloatFilterable = true;

/**
* A vertex buffer representing a quad.
*
Expand Down
4 changes: 2 additions & 2 deletions src/platform/graphics/webgpu/webgpu-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
this.supportsImageBitmap = true;
this.extStandardDerivatives = true;
this.extBlendMinmax = true;
this.areaLightLutFormat = this.floatFilterable ? PIXELFORMAT_RGBA32F : PIXELFORMAT_RGBA8;
this.areaLightLutFormat = this.textureFloatFilterable ? PIXELFORMAT_RGBA32F : PIXELFORMAT_RGBA8;
this.supportsTextureFetch = true;

// WebGPU currently only supports 1 and 4 samples
Expand Down Expand Up @@ -215,7 +215,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
}
return supported;
};
this.floatFilterable = requireFeature('float32-filterable');
this.textureFloatFilterable = requireFeature('float32-filterable');
this.extCompressedTextureS3TC = requireFeature('texture-compression-bc');
this.extCompressedTextureETC = requireFeature('texture-compression-etc2');
this.extCompressedTextureASTC = requireFeature('texture-compression-astc');
Expand Down
6 changes: 4 additions & 2 deletions src/scene/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ class Light {
value = SHADOW_PCF3; // fallback from HW PCF to old PCF
}

if (value === SHADOW_VSM32 && !device.textureFloatRenderable) // fallback from vsm32 to vsm16
// fallback from vsm32 to vsm16
if (value === SHADOW_VSM32 && (!device.textureFloatRenderable || !device.textureFloatFilterable))
value = SHADOW_VSM16;

if (value === SHADOW_VSM16 && !device.textureHalfFloatRenderable) // fallback from vsm16 to vsm8
// fallback from vsm16 to vsm8
if (value === SHADOW_VSM16 && !device.textureHalfFloatRenderable)
value = SHADOW_VSM8;

this._isVsm = value >= SHADOW_VSM8 && value <= SHADOW_VSM32;
Expand Down