-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmask_depth.frag
50 lines (42 loc) · 1.52 KB
/
mask_depth.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#version 460
#extension GL_GOOGLE_include_directive : require
#extension GL_EXT_nonuniform_qualifier : require
#extension GL_EXT_shader_16bit_storage : require
#extension GL_EXT_shader_8bit_storage : require
#define FRAGMENT_SHADER
#include "indexing.glsl"
#include "types.glsl"
#define HAS_VARIADIC_IN HAS_BASE_COLOR_TEXTURE || HAS_COLOR_ALPHA_ATTRIBUTE
layout (constant_id = 0) const bool BASE_COLOR_TEXTURE_TRANSFORM = false;
layout (location = 0) flat in uint inNodeIndex;
layout (location = 1) flat in uint inMaterialIndex;
#if HAS_VARIADIC_IN
layout (location = 2) in FRAG_VARIADIC_IN {
#if HAS_BASE_COLOR_TEXTURE
vec2 baseColorTexcoord;
#endif
#if HAS_COLOR_ALPHA_ATTRIBUTE
float colorAlpha;
#endif
} variadic_in;
#endif
layout (location = 0) out uint outNodeIndex;
layout (set = 0, binding = 5, std430) readonly buffer MaterialBuffer {
Material materials[];
};
layout (set = 0, binding = 6) uniform sampler2D textures[];
void main(){
float baseColorAlpha = MATERIAL.baseColorFactor.a;
#if HAS_BASE_COLOR_TEXTURE
vec2 baseColorTexcoord = variadic_in.baseColorTexcoord;
if (BASE_COLOR_TEXTURE_TRANSFORM) {
baseColorTexcoord = mat2(MATERIAL.baseColorTextureTransform) * baseColorTexcoord + MATERIAL.baseColorTextureTransform[2];
}
baseColorAlpha *= texture(textures[uint(MATERIAL.baseColorTextureIndex)], baseColorTexcoord).a;
#endif
#if HAS_COLOR_ALPHA_ATTRIBUTE
baseColorAlpha *= variadic_in.colorAlpha;
#endif
if (baseColorAlpha < MATERIAL.alphaCutoff) discard;
outNodeIndex = inNodeIndex;
}