50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
|
|
#[set(everything)]
|
|
const constants: {
|
|
screen_size_inv: float2;
|
|
};
|
|
|
|
#[set(everything)]
|
|
const sampler_linear: sampler;
|
|
|
|
#[set(everything)]
|
|
const tex: tex2d;
|
|
|
|
struct vert_in {
|
|
pos: float2;
|
|
}
|
|
|
|
struct vert_out {
|
|
pos: float4;
|
|
tex: float2;
|
|
}
|
|
|
|
fun supersample_resolve_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 supersample_resolve_frag(input: vert_out): float4 {
|
|
// 4X resolve
|
|
var tex_step: float2 = constants.screen_size_inv / 4.0;
|
|
var col: float4 = sample(tex, sampler_linear, input.tex);
|
|
col += sample(tex, sampler_linear, input.tex + float2(1.5, 0.0) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(-1.5, 0.0) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(0.0, 1.5) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(0.0, -1.5) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(1.5, 1.5) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(-1.5, -1.5) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(1.5, -1.5) * tex_step);
|
|
col += sample(tex, sampler_linear, input.tex + float2(-1.5, 1.5) * tex_step);
|
|
return col / 9.0;
|
|
}
|
|
|
|
#[pipe]
|
|
struct pipe {
|
|
vertex = supersample_resolve_vert;
|
|
fragment = supersample_resolve_frag;
|
|
}
|