From 147f3c2fa9bc3e0abb1d4949987283573f461e1f Mon Sep 17 00:00:00 2001 From: Popov72 Date: Fri, 15 Nov 2024 18:07:08 +0100 Subject: [PATCH 1/2] Fix crash when using sub-surface scattering --- .../core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx index 4030d0f7781..583a2c43df3 100644 --- a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx +++ b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx @@ -44,14 +44,13 @@ var fragData: array, SCENE_MRT_COUNT>; fragData[PREPASS_COLOR_INDEX] = vec4f(finalColor.rgb - irradiance, finalColor.a); // Split irradiance from final color #endif irradiance /= sqAlbedo; + fragData[PREPASS_IRRADIANCE_INDEX] = vec4f(clamp(irradiance, vec3f(0.), vec3f(1.)), writeGeometryInfo * uniforms.scatteringDiffusionProfile / 255.); // Irradiance + SS diffusion profile #else #ifdef PREPASS_COLOR fragData[PREPASS_COLOR_INDEX] = finalColor; // No split lighting #endif - var scatteringDiffusionProfile : f32 = 255.; + fragData[PREPASS_IRRADIANCE_INDEX] = vec4f(clamp(irradiance, vec3f(0.), vec3f(1.)), writeGeometryInfo * 1.); // Irradiance + SS diffusion profile #endif - - fragData[PREPASS_IRRADIANCE_INDEX] = vec4f(clamp(irradiance, vec3f(0.), vec3f(1.)), writeGeometryInfo * scatteringDiffusionProfile / 255.); // Irradiance + SS diffusion profile #elif defined(PREPASS_COLOR) fragData[PREPASS_COLOR_INDEX] = vec4f(finalColor.rgb, finalColor.a); #endif From 691b289ff89cafa21fa086301cbc710439182c8f Mon Sep 17 00:00:00 2001 From: Popov72 Date: Fri, 15 Nov 2024 20:54:34 +0100 Subject: [PATCH 2/2] Fix code --- .../dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx index 583a2c43df3..3cdf415a6e8 100644 --- a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx +++ b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockPrePass.fx @@ -49,7 +49,7 @@ var fragData: array, SCENE_MRT_COUNT>; #ifdef PREPASS_COLOR fragData[PREPASS_COLOR_INDEX] = finalColor; // No split lighting #endif - fragData[PREPASS_IRRADIANCE_INDEX] = vec4f(clamp(irradiance, vec3f(0.), vec3f(1.)), writeGeometryInfo * 1.); // Irradiance + SS diffusion profile + fragData[PREPASS_IRRADIANCE_INDEX] = vec4f(clamp(irradiance, vec3f(0.), vec3f(1.)), writeGeometryInfo); // Irradiance + SS diffusion profile #endif #elif defined(PREPASS_COLOR) fragData[PREPASS_COLOR_INDEX] = vec4f(finalColor.rgb, finalColor.a);