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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#version 300 es
#define ALLOW_INCLUDES
#extension GL_ARB_shading_language_include : enable
#include "defines.h"
precision highp float;
in vec2 v_texcoord;
uniform sampler2D tex;
#if USE_BLUR
uniform vec2 uvSize;
uniform vec2 uvOffset;
uniform sampler2D blurredBG;
#endif
uniform float alpha;
#if USE_DISCARD
uniform bool discardOpaque;
uniform bool discardAlpha;
uniform float discardAlphaValue;
#endif
#if USE_TINT
uniform vec3 tint;
#endif
#if USE_ROUNDING
uniform float radius;
uniform float roundingPower;
uniform vec2 topLeft;
uniform vec2 fullSize;
#include "rounding.glsl"
#endif
#if USE_CM
uniform int sourceTF; // eTransferFunction
uniform int targetTF; // eTransferFunction
#if USE_TONEMAP || USE_SDR_MOD
uniform mat3 targetPrimariesXYZ;
#else
const mat3 targetPrimariesXYZ = mat3(0.0);
#endif
#include "CM.glsl"
#endif
layout(location = 0) out vec4 fragColor;
#if USE_MIRROR
layout(location = 1) out vec4 mirrorColor;
#endif
void main() {
#if USE_RGBA
vec4 pixColor = texture(tex, v_texcoord);
#else
vec4 pixColor = vec4(texture(tex, v_texcoord).rgb, 1.0);
#endif
#if USE_DISCARD && !USE_BLUR
if (discardOpaque && pixColor.a * alpha == 1.0)
discard;
if (discardAlpha && pixColor.a <= discardAlphaValue)
discard;
#endif
#if USE_CM
#if USE_MIRROR
vec4[2] pixColors =
#else
pixColor =
#endif
doColorManagement(pixColor, sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
#if USE_ICC
,
iccLut3D, iccLutSize
#else
#if USE_TONEMAP || USE_SDR_MOD
,
targetPrimariesXYZ
#endif
#if USE_TONEMAP
,
maxLuminance, dstMaxLuminance, dstRefLuminance, srcRefLuminance
#endif
#if USE_SDR_MOD
,
sdrSaturation, sdrBrightnessMultiplier
#endif
#endif
);
#endif
#if USE_MIRROR
pixColor = pixColors[0];
mirrorColor = pixColors[1];
#endif
#if USE_TINT
pixColor.rgb = pixColor.rgb * tint;
#endif
#if USE_ROUNDING
pixColor = rounding(pixColor, radius, roundingPower, topLeft, fullSize);
#endif
pixColor *= alpha;
#if USE_BLUR
#if USE_DISCARD
pixColor = mix(pixColor, vec4(mix(texture(blurredBG, v_texcoord * uvSize + uvOffset).rgb, pixColor.rgb, pixColor.a), 1.0),
discardAlpha && (pixColor.a <= discardAlphaValue) ? 0.0 : 1.0);
#else
pixColor = vec4(mix(texture(blurredBG, v_texcoord * uvSize + uvOffset).rgb, pixColor.rgb, pixColor.a), 1.0);
#endif
#endif
fragColor = pixColor;
#if USE_MIRROR
#if USE_TINT
mirrorColor.rgb = mirrorColor.rgb * tint;
#endif
#if USE_ROUNDING
mirrorColor = rounding(mirrorColor, radius, roundingPower, topLeft, fullSize);
#endif
mirrorColor = mirrorColor * alpha;
#if USE_BLUR
#if USE_DISCARD
mirrorColor = mix(mirrorColor, vec4(mix(texture(blurredBG, v_texcoord * uvSize + uvOffset).rgb, mirrorColor.rgb, mirrorColor.a), 1.0),
discardAlpha && (mirrorColor.a <= discardAlphaValue) ? 0.0 : 1.0);
#else
mirrorColor = vec4(mix(texture(blurredBG, v_texcoord * uvSize + uvOffset).rgb, mirrorColor.rgb, mirrorColor.a), 1.0);
#endif
#endif
#endif
}
|