From 8581aea231c8a0c50bd84c76a4e7ef0d5d01e3c9 Mon Sep 17 00:00:00 2001 From: Martin Valigursky Date: Tue, 27 May 2025 14:36:34 +0100 Subject: [PATCH] Small chunks cleanup related to opacity --- .../glsl/chunks/standard/frag/stdDeclaration.js | 12 +++++------- .../glsl/chunks/standard/frag/stdFrontEnd.js | 12 +++++++++--- .../wgsl/chunks/standard/frag/stdDeclaration.js | 13 ++++++------- .../wgsl/chunks/standard/frag/stdFrontEnd.js | 13 +++++++++---- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/scene/shader-lib/glsl/chunks/standard/frag/stdDeclaration.js b/src/scene/shader-lib/glsl/chunks/standard/frag/stdDeclaration.js index 3d34365028f..13fc818466c 100644 --- a/src/scene/shader-lib/glsl/chunks/standard/frag/stdDeclaration.js +++ b/src/scene/shader-lib/glsl/chunks/standard/frag/stdDeclaration.js @@ -5,13 +5,11 @@ export default /* glsl */` // globals float dAlpha = 1.0; - #if defined(LIT_ALPHA_TEST) - #include "alphaTestPS" - #endif - - // dithering - #if STD_OPACITY_DITHER != NONE - #include "opacityDitherPS" + // all passes handle opacity + #if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE + #ifdef STD_OPACITY_TEXTURE_ALLOCATE + uniform sampler2D texture_opacityMap; + #endif #endif #ifdef FORWARD_PASS // ---------------- diff --git a/src/scene/shader-lib/glsl/chunks/standard/frag/stdFrontEnd.js b/src/scene/shader-lib/glsl/chunks/standard/frag/stdFrontEnd.js index cae46abc9c5..03f6ef04364 100644 --- a/src/scene/shader-lib/glsl/chunks/standard/frag/stdFrontEnd.js +++ b/src/scene/shader-lib/glsl/chunks/standard/frag/stdFrontEnd.js @@ -3,10 +3,16 @@ export default /* glsl */` // all passes handle opacity #if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE - #ifdef STD_OPACITY_TEXTURE_ALLOCATE - uniform sampler2D texture_opacityMap; - #endif #include "opacityPS" + + #if defined(LIT_ALPHA_TEST) + #include "alphaTestPS" + #endif + + // dithering + #if STD_OPACITY_DITHER != NONE + #include "opacityDitherPS" + #endif #endif #ifdef FORWARD_PASS // ---------------- diff --git a/src/scene/shader-lib/wgsl/chunks/standard/frag/stdDeclaration.js b/src/scene/shader-lib/wgsl/chunks/standard/frag/stdDeclaration.js index de47133e69d..a13fa52187b 100644 --- a/src/scene/shader-lib/wgsl/chunks/standard/frag/stdDeclaration.js +++ b/src/scene/shader-lib/wgsl/chunks/standard/frag/stdDeclaration.js @@ -5,13 +5,12 @@ export default /* wgsl */` // globals var dAlpha: f32 = 1.0; - #if defined(LIT_ALPHA_TEST) - #include "alphaTestPS" - #endif - - // dithering - #if STD_OPACITY_DITHER != NONE - #include "opacityDitherPS" + // all passes handle opacity + #if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE + #ifdef STD_OPACITY_TEXTURE_ALLOCATE + var texture_opacityMap : texture_2d; + var texture_opacityMapSampler : sampler; + #endif #endif #ifdef FORWARD_PASS // ---------------- diff --git a/src/scene/shader-lib/wgsl/chunks/standard/frag/stdFrontEnd.js b/src/scene/shader-lib/wgsl/chunks/standard/frag/stdFrontEnd.js index 75c9822afb5..a54ec2d218b 100644 --- a/src/scene/shader-lib/wgsl/chunks/standard/frag/stdFrontEnd.js +++ b/src/scene/shader-lib/wgsl/chunks/standard/frag/stdFrontEnd.js @@ -3,11 +3,16 @@ export default /* wgsl */` // all passes handle opacity #if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE - #ifdef STD_OPACITY_TEXTURE_ALLOCATE - var texture_opacityMap : texture_2d; - var texture_opacityMapSampler : sampler; - #endif #include "opacityPS" + + #if defined(LIT_ALPHA_TEST) + #include "alphaTestPS" + #endif + + // dithering + #if STD_OPACITY_DITHER != NONE + #include "opacityDitherPS" + #endif #endif #ifdef FORWARD_PASS // ----------------