2023-02-11 15:38:56 +00:00
|
|
|
// VERTEX_SHADER:
|
|
|
|
// mask.glsl
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
|
|
|
|
|
|
|
vUv = vec2(aUv.x, aUv.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FRAGMENT_SHADER:
|
|
|
|
// mask.glsl
|
|
|
|
|
2023-02-14 18:44:39 +00:00
|
|
|
uniform int u_mode;
|
2023-02-11 15:38:56 +00:00
|
|
|
uniform sampler2D u_mask;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
vec4 source = GskTexture(u_source, vUv);
|
|
|
|
vec4 mask = GskTexture(u_mask, vUv);
|
2023-02-14 18:44:39 +00:00
|
|
|
float mask_value;
|
|
|
|
|
|
|
|
if (u_mode == 0)
|
|
|
|
mask_value = mask.a;
|
|
|
|
else if (u_mode == 1)
|
2023-02-17 11:26:42 +00:00
|
|
|
mask_value = 1.0 - mask.a;
|
2023-02-14 18:44:39 +00:00
|
|
|
else if (u_mode == 2)
|
|
|
|
mask_value = (0.2126 * mask.r + 0.7152 * mask.g + 0.0722 * mask.b) * mask.a;
|
|
|
|
else if (u_mode == 3)
|
2023-02-17 11:26:42 +00:00
|
|
|
mask_value = 1.0 - (0.2126 * mask.r + 0.7152 * mask.g + 0.0722 * mask.b) * mask.a;
|
2023-02-14 18:44:39 +00:00
|
|
|
else
|
2023-02-17 11:26:42 +00:00
|
|
|
mask_value = 0.0;
|
2023-02-14 18:44:39 +00:00
|
|
|
|
|
|
|
gskSetOutputColor(vec4 (source * mask_value));
|
2023-02-11 15:38:56 +00:00
|
|
|
}
|