Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / games / voxels / src / main / rust / shaders / bright.frag

bright.frag14 lines · 530 BRaw
1#version 450
2// Bright-pass: keep only HDR values above a threshold (feeds the bloom blur). Runs at half res, so the
3// bilinear sample also downsamples.
4layout(location=0) in vec2 vUv;
5layout(binding=0) uniform sampler2D src;
6layout(binding=1) uniform sampler2D unused;
7layout(location=0) out vec4 outColor;
8void main() {
9 vec3 c = texture(src, vUv).rgb;
10 float b = max(max(c.r, c.g), c.b);
11 const float threshold = 1.05;
12 float k = clamp((b - threshold) / max(b, 1e-4), 0.0, 1.0);
13 outColor = vec4(c * k, 1.0);
14}