diff --git a/assets/voxygen/shaders/antialias/hqx.glsl b/assets/voxygen/shaders/antialias/hqx.glsl index 0eb950877f..6e7d9e2139 100644 --- a/assets/voxygen/shaders/antialias/hqx.glsl +++ b/assets/voxygen/shaders/antialias/hqx.glsl @@ -1,4 +1,4 @@ -const float THRESHOLD = 0.05; +const float THRESHOLD = 0.025; const float DEPTH_THRESHOLD = 0.05; bool diag( @@ -9,22 +9,21 @@ bool diag( vec2 uv, const vec2 p1, const vec2 p2, - const float aa_scale, - const uvec2 src_sz + const float aa_scale ) { - vec4 v1 = texelFetch(sampler2D(tex, smplr), ivec2(uv + p1 * 0.5), 0); - vec4 v2 = texelFetch(sampler2D(tex, smplr), ivec2(uv + p2 * 0.5), 0); + vec4 v1 = texelFetch(sampler2D(tex, smplr), ivec2(uv + vec2(p1.x, p1.y)), 0); + vec4 v2 = texelFetch(sampler2D(tex, smplr), ivec2(uv + vec2(p2.x, p2.y)), 0); float d1 = 1.0 / texelFetch(sampler2D(depth_tex, depth_smplr), ivec2(uv + vec2(p1.x, p1.y)), 0).x; float d2 = 1.0 / texelFetch(sampler2D(depth_tex, depth_smplr), ivec2(uv + vec2(p2.x, p2.y)), 0).x; - if (length((normalize(v1) - normalize(v2)).rgb) > THRESHOLD || abs(d1 - d2) > d1 * DEPTH_THRESHOLD + 3.0) { - return false; + if (length((v1 - v2).rb) < THRESHOLD && abs(d1 - d2) < d1 * DEPTH_THRESHOLD + 3.0) { + vec2 dir = p2 - p1; + vec2 lp = uv - (floor(uv + p1) + 0.5); + dir = normalize(vec2(dir.y, -dir.x)); + float l = clamp((line_thickness - dot(lp, dir)) * aa_scale, 0.0, 1.0); + sum = mix(sum, (v1 + v2) * 0.5, l); + return true; } - vec2 dir = p2 - p1; - vec2 lp = uv - (floor(uv + p1) + 0.5); - dir = normalize(vec2(dir.y, -dir.x)); - float l = clamp((line_thickness - dot(lp, dir)) * aa_scale, 0.0, 1.0); - sum = mix(sum, (v1 + v2) * 0.5, l); - return true; + return false; } vec4 aa_apply( @@ -39,26 +38,25 @@ vec4 aa_apply( vec2 ip = fragCoord / upscale; //start with nearest pixel as 'background' vec4 s = texelFetch(sampler2D(tex, smplr), ivec2(ip), 0); - //vec4 s = texture(sampler2D(tex, smplr), fragCoord / resolution); - float aa_scale = upscale.x * 0.5; + float aa_scale = upscale.x * 1.5; //draw anti aliased diagonal lines of surrounding pixels as 'foreground' - if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(-1, 0), vec2(0, 1), aa_scale, src_sz)) { - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, 0), vec2(1, 1), aa_scale, src_sz); - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, -1), vec2(0, 1), aa_scale, src_sz); + if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(-1, 0), vec2(0, 1), aa_scale)) { + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, 0), vec2(1, 1), aa_scale); + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, -1), vec2(0, 1), aa_scale); } - if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(0, 1), vec2(1, 0), aa_scale, src_sz)) { - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(0, 1), vec2(1, -1), aa_scale, src_sz); - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, 1), vec2(1, 0), aa_scale, src_sz); + if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(0, 1), vec2(1, 0), aa_scale)) { + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(0, 1), vec2(1, -1), aa_scale); + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(-1, 1), vec2(1, 0), aa_scale); } - if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(1, 0), vec2(0, -1), aa_scale, src_sz)) { - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, 0), vec2(-1, -1), aa_scale, src_sz); - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, 1), vec2(0, -1), aa_scale, src_sz); + if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(1, 0), vec2(0, -1), aa_scale)) { + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, 0), vec2(-1, -1), aa_scale); + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, 1), vec2(0, -1), aa_scale); } - if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(0, -1), vec2(-1, 0), aa_scale, src_sz)) { - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(0, -1), vec2(-1, 1), aa_scale, src_sz); - diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, -1), vec2(-1, 0), aa_scale, src_sz); + if (diag(tex, smplr, depth_tex, depth_smplr, 0.4, s, ip, vec2(0, -1), vec2(-1, 0), aa_scale)) { + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(0, -1), vec2(-1, 1), aa_scale); + diag(tex, smplr, depth_tex, depth_smplr, 0.3, s, ip, vec2(1, -1), vec2(-1, 0), aa_scale); } return s; diff --git a/assets/voxygen/shaders/postprocess-frag.glsl b/assets/voxygen/shaders/postprocess-frag.glsl index c7c7ddaf83..18b4086385 100644 --- a/assets/voxygen/shaders/postprocess-frag.glsl +++ b/assets/voxygen/shaders/postprocess-frag.glsl @@ -43,7 +43,7 @@ uniform u_locals { }; #ifdef BLOOM_FACTOR -layout(set = 1, binding = 5) +layout(set = 1, binding = 3) uniform texture2D t_src_bloom; #endif