70 lines
1.5 KiB
Plaintext
70 lines
1.5 KiB
Plaintext
|
|
#[set(everything)]
|
|
const constants: {
|
|
empty: float4;
|
|
channel: int;
|
|
};
|
|
|
|
#[set(everything)]
|
|
const sampler_linear: sampler;
|
|
|
|
#[set(everything)]
|
|
const tex: tex2d;
|
|
|
|
struct vert_in {
|
|
pos: float2;
|
|
tex: float2;
|
|
col: float4;
|
|
}
|
|
|
|
struct vert_out {
|
|
pos: float4;
|
|
tex: float2;
|
|
col: float4;
|
|
}
|
|
|
|
fun layer_view_vert(input: vert_in): vert_out {
|
|
var output: vert_out;
|
|
output.pos = float4(input.pos, 0.0, 1.0);
|
|
output.tex = input.tex;
|
|
output.col = input.col;
|
|
return output;
|
|
}
|
|
|
|
fun layer_view_frag(input: vert_out): float4 {
|
|
if (constants.channel == 1) {
|
|
return sample_lod(tex, sampler_linear, input.tex, 0.0).rrra * input.col;
|
|
}
|
|
if (constants.channel == 2) {
|
|
return sample_lod(tex, sampler_linear, input.tex, 0.0).ggga * input.col;
|
|
}
|
|
if (constants.channel == 3) {
|
|
return sample_lod(tex, sampler_linear, input.tex, 0.0).bbba * input.col;
|
|
}
|
|
if (constants.channel == 4) {
|
|
return sample_lod(tex, sampler_linear, input.tex, 0.0).aaaa * input.col;
|
|
}
|
|
if (constants.channel == 5) {
|
|
return sample_lod(tex, sampler_linear, input.tex, 0.0).rgba * input.col;
|
|
}
|
|
if (constants.channel == 6) {
|
|
// Apply mask as red area
|
|
var tex_sample: float4 = sample_lod(tex, sampler_linear, input.tex, 0.0);
|
|
if (tex_sample.r < 0.9) {
|
|
discard;
|
|
}
|
|
return float4(1.0, 0.0, 0.0, 1.0);
|
|
}
|
|
// else {
|
|
var tex_sample: float4 = sample_lod(tex, sampler_linear, input.tex, 0.0);
|
|
tex_sample.rgb = tex_sample.rgb * tex_sample.a;
|
|
return tex_sample * input.col;
|
|
// }
|
|
}
|
|
|
|
#[pipe]
|
|
struct pipe {
|
|
vertex = layer_view_vert;
|
|
fragment = layer_view_frag;
|
|
}
|