mpv-conf/shaders/ravu-r3-yuv.glsl

444 lines
70 KiB
Text
Raw Normal View History

2021-12-03 20:50:08 +08:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//!DESC RAVU (step1, yuv, r3, compute)
//!HOOK NATIVE
//!BIND HOOKED
//!BIND ravu_lut3
//!SAVE ravu_int11
//!WHEN HOOKED.w OUTPUT.w / 0.707106 < HOOKED.h OUTPUT.h / 0.707106 < * LUMA.w 0 > *
//!COMPUTE 32 8
shared vec3 inp0[481];
shared float inp_luma0[481];
void hook() {
ivec2 group_base = ivec2(gl_WorkGroupID) * ivec2(gl_WorkGroupSize);
int local_pos = int(gl_LocalInvocationID.x) * 13 + int(gl_LocalInvocationID.y);
for (int id = int(gl_LocalInvocationIndex); id < 481; id += int(gl_WorkGroupSize.x * gl_WorkGroupSize.y)) {
int x = id / 13, y = id % 13;
inp0[id] = HOOKED_tex(HOOKED_pt * vec2(float(group_base.x+x)+(-1.5), float(group_base.y+y)+(-1.5))).xyz;
inp_luma0[id] = inp0[id].x;
}
groupMemoryBarrier();
barrier();
{
float luma6 = inp_luma0[local_pos + 13];
float luma7 = inp_luma0[local_pos + 14];
float luma8 = inp_luma0[local_pos + 15];
float luma9 = inp_luma0[local_pos + 16];
float luma10 = inp_luma0[local_pos + 17];
float luma11 = inp_luma0[local_pos + 18];
float luma1 = inp_luma0[local_pos + 1];
float luma12 = inp_luma0[local_pos + 26];
float luma13 = inp_luma0[local_pos + 27];
float luma14 = inp_luma0[local_pos + 28];
float luma15 = inp_luma0[local_pos + 29];
float luma2 = inp_luma0[local_pos + 2];
float luma16 = inp_luma0[local_pos + 30];
float luma17 = inp_luma0[local_pos + 31];
float luma18 = inp_luma0[local_pos + 39];
float luma3 = inp_luma0[local_pos + 3];
float luma19 = inp_luma0[local_pos + 40];
float luma20 = inp_luma0[local_pos + 41];
float luma21 = inp_luma0[local_pos + 42];
float luma22 = inp_luma0[local_pos + 43];
float luma23 = inp_luma0[local_pos + 44];
float luma4 = inp_luma0[local_pos + 4];
float luma24 = inp_luma0[local_pos + 52];
float luma25 = inp_luma0[local_pos + 53];
float luma26 = inp_luma0[local_pos + 54];
float luma27 = inp_luma0[local_pos + 55];
float luma28 = inp_luma0[local_pos + 56];
float luma29 = inp_luma0[local_pos + 57];
float luma31 = inp_luma0[local_pos + 66];
float luma32 = inp_luma0[local_pos + 67];
float luma33 = inp_luma0[local_pos + 68];
float luma34 = inp_luma0[local_pos + 69];
vec3 abd = vec3(0.0);
float gx, gy;
gx = (luma13-luma1)/2.0;
gy = (luma8-luma6)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (luma14-luma2)/2.0;
gy = (-luma10+8.0*luma9-8.0*luma7+luma6)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma15-luma3)/2.0;
gy = (-luma11+8.0*luma10-8.0*luma8+luma7)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma16-luma4)/2.0;
gy = (luma11-luma9)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (-luma25+8.0*luma19-8.0*luma7+luma1)/12.0;
gy = (luma14-luma12)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma26+8.0*luma20-8.0*luma8+luma2)/12.0;
gy = (-luma16+8.0*luma15-8.0*luma13+luma12)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma27+8.0*luma21-8.0*luma9+luma3)/12.0;
gy = (-luma17+8.0*luma16-8.0*luma14+luma13)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma28+8.0*luma22-8.0*luma10+luma4)/12.0;
gy = (luma17-luma15)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma31+8.0*luma25-8.0*luma13+luma7)/12.0;
gy = (luma20-luma18)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma32+8.0*luma26-8.0*luma14+luma8)/12.0;
gy = (-luma22+8.0*luma21-8.0*luma19+luma18)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma33+8.0*luma27-8.0*luma15+luma9)/12.0;
gy = (-luma23+8.0*luma22-8.0*luma20+luma19)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma34+8.0*luma28-8.0*luma16+luma10)/12.0;
gy = (luma23-luma21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma31-luma19)/2.0;
gy = (luma26-luma24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (luma32-luma20)/2.0;
gy = (-luma28+8.0*luma27-8.0*luma25+luma24)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma33-luma21)/2.0;
gy = (-luma29+8.0*luma28-8.0*luma26+luma25)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma34-luma22)/2.0;
gy = (luma29-luma27)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
float a = abd.x, b = abd.y, d = abd.z;
float T = a + d, D = a * d - b * b;
float delta = sqrt(max(T * T / 4.0 - D, 0.0));
float L1 = T / 2.0 + delta, L2 = T / 2.0 - delta;
float sqrtL1 = sqrt(L1), sqrtL2 = sqrt(L2);
float theta = mix(mod(atan(L1 - a, b) + 3.141592653589793, 3.141592653589793), 0.0, abs(b) < 1.192092896e-7);
float lambda = sqrtL1;
float mu = mix((sqrtL1 - sqrtL2) / (sqrtL1 + sqrtL2), 0.0, sqrtL1 + sqrtL2 < 1.192092896e-7);
float angle = floor(theta * 24.0 / 3.141592653589793);
float strength = clamp(floor(log2(lambda * 2000.0 + 1.192092896e-7)), 0.0, 8.0);
float coherence = mix(mix(0.0, 1.0, mu >= 0.25), 2.0, mu >= 0.5);
float coord_y = ((angle * 9.0 + strength) * 3.0 + coherence + 0.5) / 648.0;
vec3 res = vec3(0.0);
vec4 w;
w = texture(ravu_lut3, vec2(0.1, coord_y));
res += (inp0[local_pos + 0] + inp0[local_pos + 70]) * w[0];
res += (inp0[local_pos + 1] + inp0[local_pos + 69]) * w[1];
res += (inp0[local_pos + 2] + inp0[local_pos + 68]) * w[2];
res += (inp0[local_pos + 3] + inp0[local_pos + 67]) * w[3];
w = texture(ravu_lut3, vec2(0.3, coord_y));
res += (inp0[local_pos + 4] + inp0[local_pos + 66]) * w[0];
res += (inp0[local_pos + 5] + inp0[local_pos + 65]) * w[1];
res += (inp0[local_pos + 13] + inp0[local_pos + 57]) * w[2];
res += (inp0[local_pos + 14] + inp0[local_pos + 56]) * w[3];
w = texture(ravu_lut3, vec2(0.5, coord_y));
res += (inp0[local_pos + 15] + inp0[local_pos + 55]) * w[0];
res += (inp0[local_pos + 16] + inp0[local_pos + 54]) * w[1];
res += (inp0[local_pos + 17] + inp0[local_pos + 53]) * w[2];
res += (inp0[local_pos + 18] + inp0[local_pos + 52]) * w[3];
w = texture(ravu_lut3, vec2(0.7, coord_y));
res += (inp0[local_pos + 26] + inp0[local_pos + 44]) * w[0];
res += (inp0[local_pos + 27] + inp0[local_pos + 43]) * w[1];
res += (inp0[local_pos + 28] + inp0[local_pos + 42]) * w[2];
res += (inp0[local_pos + 29] + inp0[local_pos + 41]) * w[3];
w = texture(ravu_lut3, vec2(0.9, coord_y));
res += (inp0[local_pos + 30] + inp0[local_pos + 40]) * w[0];
res += (inp0[local_pos + 31] + inp0[local_pos + 39]) * w[1];
res = clamp(res, 0.0, 1.0);
imageStore(out_image, ivec2(gl_GlobalInvocationID), vec4(res, 1.0));
}
}
//!DESC RAVU (step2, yuv, r3, compute)
//!HOOK NATIVE
//!BIND HOOKED
//!BIND ravu_lut3
//!BIND ravu_int11
//!WIDTH 2 HOOKED.w *
//!HEIGHT 2 HOOKED.h *
//!OFFSET -0.500000 -0.500000
//!WHEN HOOKED.w OUTPUT.w / 0.707106 < HOOKED.h OUTPUT.h / 0.707106 < * LUMA.w 0 > *
//!COMPUTE 64 16 32 8
shared vec3 inp0[481];
shared float inp_luma0[481];
shared vec3 inp1[481];
shared float inp_luma1[481];
void hook() {
ivec2 group_base = ivec2(gl_WorkGroupID) * ivec2(gl_WorkGroupSize);
int local_pos = int(gl_LocalInvocationID.x) * 13 + int(gl_LocalInvocationID.y);
for (int id = int(gl_LocalInvocationIndex); id < 481; id += int(gl_WorkGroupSize.x * gl_WorkGroupSize.y)) {
int x = id / 13, y = id % 13;
inp0[id] = ravu_int11_tex(ravu_int11_pt * vec2(float(group_base.x+x)+(-2.5), float(group_base.y+y)+(-2.5))).xyz;
inp_luma0[id] = inp0[id].x;
}
for (int id = int(gl_LocalInvocationIndex); id < 481; id += int(gl_WorkGroupSize.x * gl_WorkGroupSize.y)) {
int x = id / 13, y = id % 13;
inp1[id] = HOOKED_tex(HOOKED_pt * vec2(float(group_base.x+x)+(-1.5), float(group_base.y+y)+(-1.5))).xyz;
inp_luma1[id] = inp1[id].x;
}
groupMemoryBarrier();
barrier();
{
float luma12 = inp_luma0[local_pos + 15];
float luma7 = inp_luma0[local_pos + 16];
float luma2 = inp_luma0[local_pos + 17];
float luma24 = inp_luma0[local_pos + 27];
float luma19 = inp_luma0[local_pos + 28];
float luma14 = inp_luma0[local_pos + 29];
float luma9 = inp_luma0[local_pos + 30];
float luma4 = inp_luma0[local_pos + 31];
float luma31 = inp_luma0[local_pos + 40];
float luma26 = inp_luma0[local_pos + 41];
float luma21 = inp_luma0[local_pos + 42];
float luma16 = inp_luma0[local_pos + 43];
float luma11 = inp_luma0[local_pos + 44];
float luma33 = inp_luma0[local_pos + 54];
float luma28 = inp_luma0[local_pos + 55];
float luma23 = inp_luma0[local_pos + 56];
float luma18 = inp_luma1[local_pos + 14];
float luma13 = inp_luma1[local_pos + 15];
float luma8 = inp_luma1[local_pos + 16];
float luma3 = inp_luma1[local_pos + 17];
float luma25 = inp_luma1[local_pos + 27];
float luma20 = inp_luma1[local_pos + 28];
float luma15 = inp_luma1[local_pos + 29];
float luma6 = inp_luma1[local_pos + 2];
float luma10 = inp_luma1[local_pos + 30];
float luma1 = inp_luma1[local_pos + 3];
float luma32 = inp_luma1[local_pos + 40];
float luma27 = inp_luma1[local_pos + 41];
float luma22 = inp_luma1[local_pos + 42];
float luma17 = inp_luma1[local_pos + 43];
float luma34 = inp_luma1[local_pos + 54];
float luma29 = inp_luma1[local_pos + 55];
vec3 abd = vec3(0.0);
float gx, gy;
gx = (luma13-luma1)/2.0;
gy = (luma8-luma6)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (luma14-luma2)/2.0;
gy = (-luma10+8.0*luma9-8.0*luma7+luma6)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma15-luma3)/2.0;
gy = (-luma11+8.0*luma10-8.0*luma8+luma7)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma16-luma4)/2.0;
gy = (luma11-luma9)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (-luma25+8.0*luma19-8.0*luma7+luma1)/12.0;
gy = (luma14-luma12)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma26+8.0*luma20-8.0*luma8+luma2)/12.0;
gy = (-luma16+8.0*luma15-8.0*luma13+luma12)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma27+8.0*luma21-8.0*luma9+luma3)/12.0;
gy = (-luma17+8.0*luma16-8.0*luma14+luma13)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma28+8.0*luma22-8.0*luma10+luma4)/12.0;
gy = (luma17-luma15)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma31+8.0*luma25-8.0*luma13+luma7)/12.0;
gy = (luma20-luma18)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma32+8.0*luma26-8.0*luma14+luma8)/12.0;
gy = (-luma22+8.0*luma21-8.0*luma19+luma18)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma33+8.0*luma27-8.0*luma15+luma9)/12.0;
gy = (-luma23+8.0*luma22-8.0*luma20+luma19)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma34+8.0*luma28-8.0*luma16+luma10)/12.0;
gy = (luma23-luma21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma31-luma19)/2.0;
gy = (luma26-luma24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (luma32-luma20)/2.0;
gy = (-luma28+8.0*luma27-8.0*luma25+luma24)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma33-luma21)/2.0;
gy = (-luma29+8.0*luma28-8.0*luma26+luma25)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma34-luma22)/2.0;
gy = (luma29-luma27)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
float a = abd.x, b = abd.y, d = abd.z;
float T = a + d, D = a * d - b * b;
float delta = sqrt(max(T * T / 4.0 - D, 0.0));
float L1 = T / 2.0 + delta, L2 = T / 2.0 - delta;
float sqrtL1 = sqrt(L1), sqrtL2 = sqrt(L2);
float theta = mix(mod(atan(L1 - a, b) + 3.141592653589793, 3.141592653589793), 0.0, abs(b) < 1.192092896e-7);
float lambda = sqrtL1;
float mu = mix((sqrtL1 - sqrtL2) / (sqrtL1 + sqrtL2), 0.0, sqrtL1 + sqrtL2 < 1.192092896e-7);
float angle = floor(theta * 24.0 / 3.141592653589793);
float strength = clamp(floor(log2(lambda * 2000.0 + 1.192092896e-7)), 0.0, 8.0);
float coherence = mix(mix(0.0, 1.0, mu >= 0.25), 2.0, mu >= 0.5);
float coord_y = ((angle * 9.0 + strength) * 3.0 + coherence + 0.5) / 648.0;
vec3 res = vec3(0.0);
vec4 w;
w = texture(ravu_lut3, vec2(0.1, coord_y));
res += (inp0[local_pos + 3] + inp0[local_pos + 68]) * w[0];
res += (inp1[local_pos + 3] + inp1[local_pos + 54]) * w[1];
res += (inp0[local_pos + 17] + inp0[local_pos + 54]) * w[2];
res += (inp1[local_pos + 17] + inp1[local_pos + 40]) * w[3];
w = texture(ravu_lut3, vec2(0.3, coord_y));
res += (inp0[local_pos + 31] + inp0[local_pos + 40]) * w[0];
res += (inp1[local_pos + 31] + inp1[local_pos + 26]) * w[1];
res += (inp1[local_pos + 2] + inp1[local_pos + 55]) * w[2];
res += (inp0[local_pos + 16] + inp0[local_pos + 55]) * w[3];
w = texture(ravu_lut3, vec2(0.5, coord_y));
res += (inp1[local_pos + 16] + inp1[local_pos + 41]) * w[0];
res += (inp0[local_pos + 30] + inp0[local_pos + 41]) * w[1];
res += (inp1[local_pos + 30] + inp1[local_pos + 27]) * w[2];
res += (inp0[local_pos + 44] + inp0[local_pos + 27]) * w[3];
w = texture(ravu_lut3, vec2(0.7, coord_y));
res += (inp0[local_pos + 15] + inp0[local_pos + 56]) * w[0];
res += (inp1[local_pos + 15] + inp1[local_pos + 42]) * w[1];
res += (inp0[local_pos + 29] + inp0[local_pos + 42]) * w[2];
res += (inp1[local_pos + 29] + inp1[local_pos + 28]) * w[3];
w = texture(ravu_lut3, vec2(0.9, coord_y));
res += (inp0[local_pos + 43] + inp0[local_pos + 28]) * w[0];
res += (inp1[local_pos + 43] + inp1[local_pos + 14]) * w[1];
res = clamp(res, 0.0, 1.0);
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(0, 1), vec4(res, 1.0));
}
{
float luma6 = inp_luma0[local_pos + 15];
float luma1 = inp_luma0[local_pos + 16];
float luma18 = inp_luma0[local_pos + 27];
float luma13 = inp_luma0[local_pos + 28];
float luma8 = inp_luma0[local_pos + 29];
float luma3 = inp_luma0[local_pos + 30];
float luma25 = inp_luma0[local_pos + 40];
float luma20 = inp_luma0[local_pos + 41];
float luma15 = inp_luma0[local_pos + 42];
float luma10 = inp_luma0[local_pos + 43];
float luma32 = inp_luma0[local_pos + 53];
float luma27 = inp_luma0[local_pos + 54];
float luma22 = inp_luma0[local_pos + 55];
float luma17 = inp_luma0[local_pos + 56];
float luma34 = inp_luma0[local_pos + 67];
float luma29 = inp_luma0[local_pos + 68];
float luma12 = inp_luma1[local_pos + 14];
float luma7 = inp_luma1[local_pos + 15];
float luma2 = inp_luma1[local_pos + 16];
float luma24 = inp_luma1[local_pos + 26];
float luma19 = inp_luma1[local_pos + 27];
float luma14 = inp_luma1[local_pos + 28];
float luma9 = inp_luma1[local_pos + 29];
float luma4 = inp_luma1[local_pos + 30];
float luma31 = inp_luma1[local_pos + 39];
float luma26 = inp_luma1[local_pos + 40];
float luma21 = inp_luma1[local_pos + 41];
float luma16 = inp_luma1[local_pos + 42];
float luma11 = inp_luma1[local_pos + 43];
float luma33 = inp_luma1[local_pos + 53];
float luma28 = inp_luma1[local_pos + 54];
float luma23 = inp_luma1[local_pos + 55];
vec3 abd = vec3(0.0);
float gx, gy;
gx = (luma13-luma1)/2.0;
gy = (luma8-luma6)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (luma14-luma2)/2.0;
gy = (-luma10+8.0*luma9-8.0*luma7+luma6)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma15-luma3)/2.0;
gy = (-luma11+8.0*luma10-8.0*luma8+luma7)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma16-luma4)/2.0;
gy = (luma11-luma9)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (-luma25+8.0*luma19-8.0*luma7+luma1)/12.0;
gy = (luma14-luma12)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma26+8.0*luma20-8.0*luma8+luma2)/12.0;
gy = (-luma16+8.0*luma15-8.0*luma13+luma12)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma27+8.0*luma21-8.0*luma9+luma3)/12.0;
gy = (-luma17+8.0*luma16-8.0*luma14+luma13)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma28+8.0*luma22-8.0*luma10+luma4)/12.0;
gy = (luma17-luma15)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma31+8.0*luma25-8.0*luma13+luma7)/12.0;
gy = (luma20-luma18)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (-luma32+8.0*luma26-8.0*luma14+luma8)/12.0;
gy = (-luma22+8.0*luma21-8.0*luma19+luma18)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma33+8.0*luma27-8.0*luma15+luma9)/12.0;
gy = (-luma23+8.0*luma22-8.0*luma20+luma19)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.07901060453704994;
gx = (-luma34+8.0*luma28-8.0*luma16+luma10)/12.0;
gy = (luma23-luma21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma31-luma19)/2.0;
gy = (luma26-luma24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
gx = (luma32-luma20)/2.0;
gy = (-luma28+8.0*luma27-8.0*luma25+luma24)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma33-luma21)/2.0;
gy = (-luma29+8.0*luma28-8.0*luma26+luma25)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06153352068439959;
gx = (luma34-luma22)/2.0;
gy = (luma29-luma27)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04792235409415088;
float a = abd.x, b = abd.y, d = abd.z;
float T = a + d, D = a * d - b * b;
float delta = sqrt(max(T * T / 4.0 - D, 0.0));
float L1 = T / 2.0 + delta, L2 = T / 2.0 - delta;
float sqrtL1 = sqrt(L1), sqrtL2 = sqrt(L2);
float theta = mix(mod(atan(L1 - a, b) + 3.141592653589793, 3.141592653589793), 0.0, abs(b) < 1.192092896e-7);
float lambda = sqrtL1;
float mu = mix((sqrtL1 - sqrtL2) / (sqrtL1 + sqrtL2), 0.0, sqrtL1 + sqrtL2 < 1.192092896e-7);
float angle = floor(theta * 24.0 / 3.141592653589793);
float strength = clamp(floor(log2(lambda * 2000.0 + 1.192092896e-7)), 0.0, 8.0);
float coherence = mix(mix(0.0, 1.0, mu >= 0.25), 2.0, mu >= 0.5);
float coord_y = ((angle * 9.0 + strength) * 3.0 + coherence + 0.5) / 648.0;
vec3 res = vec3(0.0);
vec4 w;
w = texture(ravu_lut3, vec2(0.1, coord_y));
res += (inp1[local_pos + 2] + inp1[local_pos + 67]) * w[0];
res += (inp0[local_pos + 16] + inp0[local_pos + 67]) * w[1];
res += (inp1[local_pos + 16] + inp1[local_pos + 53]) * w[2];
res += (inp0[local_pos + 30] + inp0[local_pos + 53]) * w[3];
w = texture(ravu_lut3, vec2(0.3, coord_y));
res += (inp1[local_pos + 30] + inp1[local_pos + 39]) * w[0];
res += (inp0[local_pos + 44] + inp0[local_pos + 39]) * w[1];
res += (inp0[local_pos + 15] + inp0[local_pos + 68]) * w[2];
res += (inp1[local_pos + 15] + inp1[local_pos + 54]) * w[3];
w = texture(ravu_lut3, vec2(0.5, coord_y));
res += (inp0[local_pos + 29] + inp0[local_pos + 54]) * w[0];
res += (inp1[local_pos + 29] + inp1[local_pos + 40]) * w[1];
res += (inp0[local_pos + 43] + inp0[local_pos + 40]) * w[2];
res += (inp1[local_pos + 43] + inp1[local_pos + 26]) * w[3];
w = texture(ravu_lut3, vec2(0.7, coord_y));
res += (inp1[local_pos + 14] + inp1[local_pos + 55]) * w[0];
res += (inp0[local_pos + 28] + inp0[local_pos + 55]) * w[1];
res += (inp1[local_pos + 28] + inp1[local_pos + 41]) * w[2];
res += (inp0[local_pos + 42] + inp0[local_pos + 41]) * w[3];
w = texture(ravu_lut3, vec2(0.9, coord_y));
res += (inp1[local_pos + 42] + inp1[local_pos + 27]) * w[0];
res += (inp0[local_pos + 56] + inp0[local_pos + 27]) * w[1];
res = clamp(res, 0.0, 1.0);
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(1, 0), vec4(res, 1.0));
}
vec3 res;
res = inp0[local_pos + 42];
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(1, 1), vec4(res, 1.0));
res = inp1[local_pos + 28];
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(0, 0), vec4(res, 1.0));
}
//!TEXTURE ravu_lut3
//!SIZE 5 648
//!FORMAT rgba16hf
//!FILTER NEAREST
9c121c993f162d171199c6123b9c47216820fe1f7c21a99c621a0424c632053376241f1c000000005b118398e11aba19679a5011609e871e2e254825591c4ea1af21f92320319432312aae2500000000550a9614631d1a1d6d90a307f49472aa192b6f2de0a8b49db19854a9492dd2325b314c2600000000d70d1997e11ae31a5e960d0e7399aa1f2ca550a55d1fdd98fe1c34a45934723416a41f1d00000000990c479461145b14ef96450d62a0bf1cf79dcc9d5a1c8da0461dd6234033c633c125c71f000000002d084198421aff19869ae20674a0c9a00e265f26b59f2ba129210f26913124322c2bcf2700000000420ebe98e21ca01c14970a0dec9b471c3aa844a8e819a99ade1f35a8d834ec3416a8771f0000000054097594bb19451be293ce09349fb81c5ea78ea73913bd9e971eb4a48434bd3492a2472000000000ca099f8d331647181a983f0c2ea2bf9e5b9e679d8ea209a3f51b0d255533f933c228122400000000e911969734201620d5916611209a2410faa9f8a9e198519a6c2137aa3c354f35efa9e52100000000d70bd994671c7d1c4f11ce81629d1119aea8b7a8199d0b9f0c1e71a8df341335afa6a72200000000988637084619281cf08f0f87a6a0bc98cba5aaa5cda1ada370163fa044349b347b1f7825000000001210489884215821f08e030ccd95631b18ab6bab1a1439980522b2ab6b3588356cab7d230000000089813696c81ef71e7918538dd596841a8ea9e5a932a05a9fdb1b8daa1c355a3595a8e22400000000aa8bf38c6e19681c9c160f920898881ceda56ea631a47ca64aa43aa87334d3349a1bfa29000000002f9cd281e81d511ff8166c9ce31c9e2452abc8ab4123801aaa1658ab4f357e3507ab7d1f00000000d893ef95cc1d0b206d1aad92318d6122e2a9f2aacf9c3ea024120fac19358f35c3a8842500000000388830944a17db1cf017ef113c1e8724a0a43ca692a6d0a910aa68ac6e340b353324bb2d0000000079808f95e8210c23fa145212b29b361fb3ab3aacd88fbe9e45238aac7935cd352bac6825000000003491d3965b1d1f212a1a48180e98cf210aa928abdaa2caa2161f34ad0735c9356ca8182700000000a410d298e187bb19fd9a9b21d82184281d9ab5a51ca8fdac8bacf3af27343f35d62a4d3000000000f91432937a21bf22fd19d61aca9d2114abaa00aca1a0bda09b2346ac5035d435aaabc52500000000c517619b4a1c0c21da1bb120e09fa3214ea774ab85a56ba50623b2adc734f735e1a51727000000008414179e2f99270a6ba02c27a722dd296d231da77ba93fae2dac9eb17b33cc355e2d9830000000005c2017a0dc25d826a519ee19eaa33a2531adfdadde1e08a1b42523ad9335fe35d4ac0e2700000000961fb006f32365259121be232da394955faa7aac13a84aa53a256eac5834e3353525d21e0000000055a0619b31a0a21c2320e3283d235d28b62bcaabeaae38ab56a8b0b2fb2fe836c332e62b000000002015de971680f6126d9755164d9c4022281d1e16da21df9d82133c219832be338224251a0000000040150d06f715ba92c09a0a165ea0602163244d24d411d8a4b418401e3e2f3533cd2e6e27000000009509ff0e341b831be59eac810a9cf71dc8205f276d1fbba69aa15388432c65305431992f00000000390db097961a451b6496590f3e99cd1f29a594a59a1f3398da1c7ca4433491342ba4f71c00000000380d8f9125104214b6995a10659fb51f67a062a0781fb6a03815b61fc7323d34e726af1f000000005c0d7f95c2149e0d2c9fd90aeea2e5218f22c3235d1e1ea6ad9fb225a7301732e62d1b2b000000001c0ff799371d7d1c8094370c0a9cbd1d39a858a81b16de98bc1f6ea8c73402350ea8301f00000000930bb5959518711c73937e0c799ea720d7a71aa83096069d921cc1a65b340935dca11120000000009a829918f496431c939d3512f4a12d20e2a346a142a0f8a27ea00c1ce6326e34db29822400000000e013fb9973200720ee0c93106b9bd81a00aa18aaa39cfd992d2176aa2a356835d3a93822000000002211749a131dff1c011a928c219c7f211aa924a9f9a1909e5117eda9be34623502a63b2400000000828d7b170c9bb4215f98320d51a08a252da984a5a1a6cba026a26ba705344e35e01ff22600000000e8113e9a6c2132227c0c82115798c21e1aabadabc199529b6f210aac5435ad353eab7224000000006012a89c3c1edf1f971e2e8c2d917b2355a9b6aa65a441a2189a5eace534b135c2a675270000000062116f9b7e98241eb920f195751ab0262ba68da8d3a719a81ea882ac30348c35c223102c000000005c8d8d99e22014238e17a384ba965d2261ab36ace498929c3c205eac4835d73563ab252500000000d613429d441a5d210f1ff31849972026bba88eabeca5cca4069bbdadbc340a3685a5e828000000002916e59c939a9d971d1d8e208e1c7328959c9fa56ca821acd4a909afb833a6352c29822e000000005b17459c77217824c319ae1a0c9ebc213aaba2ac05a18aa1a022e0ac36352336e8ab2827000000005417f69c12983822611d1a21829d49278aa50face6a7b3a7ae1c57af523476367d9fa82900000000b318309b7d9aeb9ea6a183260688582872237d932ba737ae62a8bfb07132aa35682d812f000000006913c49a0d20e323691f7f1c7b9e0221cca98facdca434a27622a2acd4345436d7aa0a2700000000121c0ca0329aa120e61f6724aea1e827229e6dacb9a8a8a89a23fdaf6833e736c221d02800000000981aa8982d9d289e33a626291c9d82271028ec9ba6a5fbaeb2a0e0b145311c36102ffa2e000000007320c79d2424c12