45 lines
850 B
Plaintext
45 lines
850 B
Plaintext
|
|
#[set(everything)]
|
|
const constants: {
|
|
mask_opacity: float;
|
|
};
|
|
|
|
#[set(everything)]
|
|
const sampler_linear: sampler;
|
|
|
|
#[set(everything)]
|
|
const tex0: tex2d;
|
|
|
|
#[set(everything)]
|
|
const texa: tex2d;
|
|
|
|
struct vert_in {
|
|
pos: float2;
|
|
}
|
|
|
|
struct vert_out {
|
|
pos: float4;
|
|
tex: float2;
|
|
}
|
|
|
|
fun mask_apply_vert(input: vert_in): vert_out {
|
|
var output: vert_out;
|
|
output.tex = input.pos.xy * 0.5 + 0.5;
|
|
output.tex.y = 1.0 - output.tex.y;
|
|
output.pos = float4(input.pos.xy, 0.0, 1.0);
|
|
return output;
|
|
}
|
|
|
|
fun mask_apply_frag(input: vert_out): float4 {
|
|
var col0: float4 = sample_lod(tex0, sampler_linear, input.tex, 0.0);
|
|
var mask: float = sample_lod(texa, sampler_linear, input.tex, 0.0).r;
|
|
mask = lerp(1.0, mask, constants.mask_opacity);
|
|
return float4(col0.rgb, col0.a * mask);
|
|
}
|
|
|
|
#[pipe]
|
|
struct pipe {
|
|
vertex = mask_apply_vert;
|
|
fragment = mask_apply_frag;
|
|
}
|