fix hqx shaders

This commit is contained in:
hunterk 2016-08-09 09:14:03 -05:00
parent 99b786a13c
commit 744aea4918
2 changed files with 16 additions and 8 deletions

View file

@ -99,10 +99,10 @@ void main()
vec3 w8 = yuv * texture(Source, t3.yw).rgb; vec3 w8 = yuv * texture(Source, t3.yw).rgb;
vec3 w9 = yuv * texture(Source, t3.zw).rgb; vec3 w9 = yuv * texture(Source, t3.zw).rgb;
vec3 pattern_1 = vec3(diff(w5, w1), diff(w5, w4), diff(w5, w7)); vec3 pattern_1 = vec3(diff(w5, w1), diff(w5, w2), diff(w5, w3));
vec3 pattern_2 = vec3(diff(w5, w2), false, diff(w5, w8)); vec3 pattern_2 = vec3(diff(w5, w4), false, diff(w5, w6));
vec3 pattern_3 = vec3(diff(w5, w3), diff(w5, w6), diff(w5, w9)); vec3 pattern_3 = vec3(diff(w5, w7), diff(w5, w8), diff(w5, w9));
vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8)); vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8));
vec2 index; vec2 index;
index.x = dot(pattern_1, vec3(1, 2, 4)) + index.x = dot(pattern_1, vec3(1, 2, 4)) +

View file

@ -36,7 +36,7 @@ layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor; layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source; layout(set = 0, binding = 2) uniform sampler2D Source;
layout(set = 0, binding = 3) uniform sampler2D LUT; layout(set = 0, binding = 3) uniform sampler2D LUT;
layout(set = 0, binding = 4) uniform samlper2D Original; layout(set = 0, binding = 4) uniform sampler2D Original;
void main() void main()
{ {
@ -50,7 +50,11 @@ void main()
vec3 p2 = texture(Original, vTexCoord + vec2(dx, dy) * quad).rgb; vec3 p2 = texture(Original, vTexCoord + vec2(dx, dy) * quad).rgb;
vec3 p3 = texture(Original, vTexCoord + vec2(dx, 0.0) * quad).rgb; vec3 p3 = texture(Original, vTexCoord + vec2(dx, 0.0) * quad).rgb;
vec3 p4 = texture(Original, vTexCoord + vec2(0.0, dy) * quad).rgb; vec3 p4 = texture(Original, vTexCoord + vec2(0.0, dy) * quad).rgb;
mat3x4 pixels = mat3x4(p1, p2, p3, p4); vec3 pixels[4];
pixels[0] = p1.xyz;
pixels[1] = p2.xyz;
pixels[2] = p3.xyz;
pixels[3] = p4.xyz;
vec2 index = texture(Source, vTexCoord).xy * vec2(255.0, 15.0 * (SCALE * SCALE)); vec2 index = texture(Source, vTexCoord).xy * vec2(255.0, 15.0 * (SCALE * SCALE));
index.y += dot(floor(fp * SCALE), vec2(1.0, SCALE)); index.y += dot(floor(fp * SCALE), vec2(1.0, SCALE));
@ -59,7 +63,11 @@ void main()
vec2 offset = step / 2.0; vec2 offset = step / 2.0;
vec4 weights = texture(LUT, index * step + offset); vec4 weights = texture(LUT, index * step + offset);
float sum = dot(weights, vec4(1.0)); float sum = dot(weights, vec4(1.0));
vec3 res = transpose(pixels) * (weights / sum); vec4 tmp = vec4(float((weights/sum).x), float((weights/sum).y), float((weights/sum).z), float((weights/sum).w));
vec3 res = tmp.x * pixels[0];
res = res + tmp.y * pixels[1];
res = res + tmp.z * pixels[2];
res = res + tmp.w * pixels[3];
FragColor = vec4(res, 1.0); FragColor = vec4(res.xyz, 1.0);
} }