veloren/assets/voxygen/shaders/dual-downsample-frag.glsl

35 lines
925 B
Plaintext
Raw Normal View History

#version 420 core
2021-07-21 08:58:03 +00:00
layout(set = 0, binding = 0)
uniform texture2D t_src_color;
layout(set = 0, binding = 1)
uniform sampler s_src_color;
layout(set = 0, binding = 2)
2021-07-21 09:39:30 +00:00
uniform u_locals {
vec2 halfpixel;
};
2021-07-21 08:58:03 +00:00
layout(location = 0) in vec2 uv;
layout(location = 0) out vec4 tgt_color;
vec4 simplesample(vec2 uv) {
return textureLod(sampler2D(t_src_color, s_src_color), uv, 0);
}
// From: https://community.arm.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-20-66/siggraph2015_2D00_mmg_2D00_marius_2D00_notes.pdf
vec4 downsample(vec2 uv, vec2 halfpixel) {
vec4 sum = simplesample(uv) * 4.0;
sum += simplesample(uv - halfpixel.xy);
sum += simplesample(uv + halfpixel.xy);
sum += simplesample(uv + vec2(halfpixel.x, -halfpixel.y));
sum += simplesample(uv - vec2(halfpixel.x, -halfpixel.y));
return sum / 8.0;
}
void main() {
tgt_color = downsample(uv, halfpixel);
}