Skip to content

Commit eaf1852

Browse files
mvaligurskyMartin Valigursky
andauthored
Small chunks cleanup related to opacity (#7721)
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
1 parent f899921 commit eaf1852

4 files changed

Lines changed: 29 additions & 21 deletions

File tree

‎src/scene/shader-lib/glsl/chunks/standard/frag/stdDeclaration.js‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ export default /* glsl */`
55
// globals
66
float dAlpha = 1.0;
77
8-
#if defined(LIT_ALPHA_TEST)
9-
#include "alphaTestPS"
10-
#endif
11-
12-
// dithering
13-
#if STD_OPACITY_DITHER != NONE
14-
#include "opacityDitherPS"
8+
// all passes handle opacity
9+
#if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE
10+
#ifdef STD_OPACITY_TEXTURE_ALLOCATE
11+
uniform sampler2D texture_opacityMap;
12+
#endif
1513
#endif
1614
1715
#ifdef FORWARD_PASS // ----------------

‎src/scene/shader-lib/glsl/chunks/standard/frag/stdFrontEnd.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ export default /* glsl */`
33
44
// all passes handle opacity
55
#if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE
6-
#ifdef STD_OPACITY_TEXTURE_ALLOCATE
7-
uniform sampler2D texture_opacityMap;
8-
#endif
96
#include "opacityPS"
7+
8+
#if defined(LIT_ALPHA_TEST)
9+
#include "alphaTestPS"
10+
#endif
11+
12+
// dithering
13+
#if STD_OPACITY_DITHER != NONE
14+
#include "opacityDitherPS"
15+
#endif
1016
#endif
1117
1218
#ifdef FORWARD_PASS // ----------------

‎src/scene/shader-lib/wgsl/chunks/standard/frag/stdDeclaration.js‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ export default /* wgsl */`
55
// globals
66
var<private> dAlpha: f32 = 1.0;
77
8-
#if defined(LIT_ALPHA_TEST)
9-
#include "alphaTestPS"
10-
#endif
11-
12-
// dithering
13-
#if STD_OPACITY_DITHER != NONE
14-
#include "opacityDitherPS"
8+
// all passes handle opacity
9+
#if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE
10+
#ifdef STD_OPACITY_TEXTURE_ALLOCATE
11+
var texture_opacityMap : texture_2d<f32>;
12+
var texture_opacityMapSampler : sampler;
13+
#endif
1514
#endif
1615
1716
#ifdef FORWARD_PASS // ----------------

‎src/scene/shader-lib/wgsl/chunks/standard/frag/stdFrontEnd.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ export default /* wgsl */`
33
44
// all passes handle opacity
55
#if LIT_BLEND_TYPE != NONE || defined(LIT_ALPHA_TEST) || defined(LIT_ALPHA_TO_COVERAGE) || STD_OPACITY_DITHER != NONE
6-
#ifdef STD_OPACITY_TEXTURE_ALLOCATE
7-
var texture_opacityMap : texture_2d<f32>;
8-
var texture_opacityMapSampler : sampler;
9-
#endif
106
#include "opacityPS"
7+
8+
#if defined(LIT_ALPHA_TEST)
9+
#include "alphaTestPS"
10+
#endif
11+
12+
// dithering
13+
#if STD_OPACITY_DITHER != NONE
14+
#include "opacityDitherPS"
15+
#endif
1116
#endif
1217
1318
#ifdef FORWARD_PASS // ----------------

0 commit comments

Comments
 (0)