Files
armorpaint/paint/shaders/layer_view.kong
T

70 lines
1.5 KiB
Plaintext
Raw Normal View History

2025-03-31 18:31:49 +02:00
#[set(everything)]
const constants: {
2026-04-29 07:31:24 +02:00
empty: float4;
2025-03-31 18:31:49 +02:00
channel: int;
};
2025-04-18 09:28:41 +02:00
#[set(everything)]
2025-04-24 22:19:44 +02:00
const sampler_linear: sampler;
2025-04-18 09:28:41 +02:00
#[set(everything)]
2025-04-24 22:19:44 +02:00
const tex: tex2d;
2025-04-18 09:28:41 +02:00
2025-03-31 18:31:49 +02:00
struct vert_in {
2025-04-21 19:38:23 +02:00
pos: float2;
2026-04-29 07:31:24 +02:00
tex: float2;
col: float4;
2025-03-31 18:31:49 +02:00
}
struct vert_out {
pos: float4;
tex: float2;
col: float4;
}
fun layer_view_vert(input: vert_in): vert_out {
var output: vert_out;
2025-04-21 19:38:23 +02:00
output.pos = float4(input.pos, 0.0, 1.0);
2026-04-29 07:31:24 +02:00
output.tex = input.tex;
output.col = input.col;
2025-03-31 18:31:49 +02:00
return output;
}
fun layer_view_frag(input: vert_out): float4 {
if (constants.channel == 1) {
2025-04-19 12:29:49 +02:00
return sample_lod(tex, sampler_linear, input.tex, 0.0).rrra * input.col;
2025-03-31 18:31:49 +02:00
}
if (constants.channel == 2) {
2025-04-19 12:29:49 +02:00
return sample_lod(tex, sampler_linear, input.tex, 0.0).ggga * input.col;
2025-03-31 18:31:49 +02:00
}
if (constants.channel == 3) {
2025-04-19 12:29:49 +02:00
return sample_lod(tex, sampler_linear, input.tex, 0.0).bbba * input.col;
2025-03-31 18:31:49 +02:00
}
if (constants.channel == 4) {
2025-04-19 12:29:49 +02:00
return sample_lod(tex, sampler_linear, input.tex, 0.0).aaaa * input.col;
2025-03-31 18:31:49 +02:00
}
if (constants.channel == 5) {
2025-04-19 12:29:49 +02:00
return sample_lod(tex, sampler_linear, input.tex, 0.0).rgba * input.col;
2025-03-31 18:31:49 +02:00
}
2025-11-18 18:46:15 +01:00
if (constants.channel == 6) {
// Apply mask as red area
var tex_sample: float4 = sample_lod(tex, sampler_linear, input.tex, 0.0);
2026-06-15 11:09:01 +02:00
if (tex_sample.r < 0.9 || tex_sample.g < 0.9 || tex_sample.b < 0.9) {
return float4(1.0, 0.0, 0.0, 1.0);
2025-11-18 18:46:15 +01:00
}
2026-06-15 11:09:01 +02:00
discard;
2025-11-18 18:46:15 +01:00
}
2025-03-31 18:31:49 +02:00
// else {
2025-04-19 12:29:49 +02:00
var tex_sample: float4 = sample_lod(tex, sampler_linear, input.tex, 0.0);
2025-06-08 21:44:05 +02:00
tex_sample.rgb = tex_sample.rgb * tex_sample.a;
2025-03-31 18:31:49 +02:00
return tex_sample * input.col;
// }
}
#[pipe]
struct pipe {
vertex = layer_view_vert;
fragment = layer_view_frag;
}