Files
armorpaint/base/shaders/histogram_pass.kong
T
luboslenco 30d52c46ba kong test
2025-03-29 21:52:27 +01:00

43 lines
979 B
Plaintext

#[set(everything)]
const tex: tex2d;
#[set(everything)]
const tex_sampler: sampler;
struct vert_in {
pos: float2;
}
struct vert_out {
pos: float4;
tex: float2;
}
const auto_exposure_speed: float = 1.0;
fun histogram_pass_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 histogram_pass_frag(input: vert_out): float4 {
var color: float4;
color.a = 0.01 * auto_exposure_speed;
color.rgb = sample_lod(tex, tex_sampler, float2(0.5, 0.5), 0.0).rgb +
sample_lod(tex, tex_sampler, float2(0.2, 0.2), 0.0).rgb +
sample_lod(tex, tex_sampler, float2(0.8, 0.2), 0.0).rgb +
sample_lod(tex, tex_sampler, float2(0.2, 0.8), 0.0).rgb +
sample_lod(tex, tex_sampler, float2(0.8, 0.8), 0.0).rgb;
color.rgb /= 5.0;
return color;
}
#[pipe]
struct pipe {
vertex = histogram_pass_vert;
fragment = histogram_pass_frag;
}