// 
// 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, luma, r4)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_lut4
//!SAVE ravu_int11
//!WHEN HOOKED.w 2 * OUTPUT.w / 1.414213 < HOOKED.h 2 * OUTPUT.h / 1.414213 < *
vec4 hook() {
float sample0 = HOOKED_texOff(vec2(-3.0, -3.0)).x;
float sample1 = HOOKED_texOff(vec2(-3.0, -2.0)).x;
float sample2 = HOOKED_texOff(vec2(-3.0, -1.0)).x;
float sample3 = HOOKED_texOff(vec2(-3.0, 0.0)).x;
float sample4 = HOOKED_texOff(vec2(-3.0, 1.0)).x;
float sample5 = HOOKED_texOff(vec2(-3.0, 2.0)).x;
float sample6 = HOOKED_texOff(vec2(-3.0, 3.0)).x;
float sample7 = HOOKED_texOff(vec2(-3.0, 4.0)).x;
float sample8 = HOOKED_texOff(vec2(-2.0, -3.0)).x;
float sample9 = HOOKED_texOff(vec2(-2.0, -2.0)).x;
float sample10 = HOOKED_texOff(vec2(-2.0, -1.0)).x;
float sample11 = HOOKED_texOff(vec2(-2.0, 0.0)).x;
float sample12 = HOOKED_texOff(vec2(-2.0, 1.0)).x;
float sample13 = HOOKED_texOff(vec2(-2.0, 2.0)).x;
float sample14 = HOOKED_texOff(vec2(-2.0, 3.0)).x;
float sample15 = HOOKED_texOff(vec2(-2.0, 4.0)).x;
float sample16 = HOOKED_texOff(vec2(-1.0, -3.0)).x;
float sample17 = HOOKED_texOff(vec2(-1.0, -2.0)).x;
float sample18 = HOOKED_texOff(vec2(-1.0, -1.0)).x;
float sample19 = HOOKED_texOff(vec2(-1.0, 0.0)).x;
float sample20 = HOOKED_texOff(vec2(-1.0, 1.0)).x;
float sample21 = HOOKED_texOff(vec2(-1.0, 2.0)).x;
float sample22 = HOOKED_texOff(vec2(-1.0, 3.0)).x;
float sample23 = HOOKED_texOff(vec2(-1.0, 4.0)).x;
float sample24 = HOOKED_texOff(vec2(0.0, -3.0)).x;
float sample25 = HOOKED_texOff(vec2(0.0, -2.0)).x;
float sample26 = HOOKED_texOff(vec2(0.0, -1.0)).x;
float sample27 = HOOKED_texOff(vec2(0.0, 0.0)).x;
float sample28 = HOOKED_texOff(vec2(0.0, 1.0)).x;
float sample29 = HOOKED_texOff(vec2(0.0, 2.0)).x;
float sample30 = HOOKED_texOff(vec2(0.0, 3.0)).x;
float sample31 = HOOKED_texOff(vec2(0.0, 4.0)).x;
float sample32 = HOOKED_texOff(vec2(1.0, -3.0)).x;
float sample33 = HOOKED_texOff(vec2(1.0, -2.0)).x;
float sample34 = HOOKED_texOff(vec2(1.0, -1.0)).x;
float sample35 = HOOKED_texOff(vec2(1.0, 0.0)).x;
float sample36 = HOOKED_texOff(vec2(1.0, 1.0)).x;
float sample37 = HOOKED_texOff(vec2(1.0, 2.0)).x;
float sample38 = HOOKED_texOff(vec2(1.0, 3.0)).x;
float sample39 = HOOKED_texOff(vec2(1.0, 4.0)).x;
float sample40 = HOOKED_texOff(vec2(2.0, -3.0)).x;
float sample41 = HOOKED_texOff(vec2(2.0, -2.0)).x;
float sample42 = HOOKED_texOff(vec2(2.0, -1.0)).x;
float sample43 = HOOKED_texOff(vec2(2.0, 0.0)).x;
float sample44 = HOOKED_texOff(vec2(2.0, 1.0)).x;
float sample45 = HOOKED_texOff(vec2(2.0, 2.0)).x;
float sample46 = HOOKED_texOff(vec2(2.0, 3.0)).x;
float sample47 = HOOKED_texOff(vec2(2.0, 4.0)).x;
float sample48 = HOOKED_texOff(vec2(3.0, -3.0)).x;
float sample49 = HOOKED_texOff(vec2(3.0, -2.0)).x;
float sample50 = HOOKED_texOff(vec2(3.0, -1.0)).x;
float sample51 = HOOKED_texOff(vec2(3.0, 0.0)).x;
float sample52 = HOOKED_texOff(vec2(3.0, 1.0)).x;
float sample53 = HOOKED_texOff(vec2(3.0, 2.0)).x;
float sample54 = HOOKED_texOff(vec2(3.0, 3.0)).x;
float sample55 = HOOKED_texOff(vec2(3.0, 4.0)).x;
float sample56 = HOOKED_texOff(vec2(4.0, -3.0)).x;
float sample57 = HOOKED_texOff(vec2(4.0, -2.0)).x;
float sample58 = HOOKED_texOff(vec2(4.0, -1.0)).x;
float sample59 = HOOKED_texOff(vec2(4.0, 0.0)).x;
float sample60 = HOOKED_texOff(vec2(4.0, 1.0)).x;
float sample61 = HOOKED_texOff(vec2(4.0, 2.0)).x;
float sample62 = HOOKED_texOff(vec2(4.0, 3.0)).x;
float sample63 = HOOKED_texOff(vec2(4.0, 4.0)).x;
vec3 abd = vec3(0.0);
float gx, gy;
gx = (sample17-sample1)/2.0;
gy = (sample10-sample8)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (sample18-sample2)/2.0;
gy = (-sample12+8.0*sample11-8.0*sample9+sample8)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample19-sample3)/2.0;
gy = (-sample13+8.0*sample12-8.0*sample10+sample9)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample20-sample4)/2.0;
gy = (-sample14+8.0*sample13-8.0*sample11+sample10)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample21-sample5)/2.0;
gy = (-sample15+8.0*sample14-8.0*sample12+sample11)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample22-sample6)/2.0;
gy = (sample15-sample13)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (-sample33+8.0*sample25-8.0*sample9+sample1)/12.0;
gy = (sample18-sample16)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample34+8.0*sample26-8.0*sample10+sample2)/12.0;
gy = (-sample20+8.0*sample19-8.0*sample17+sample16)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample35+8.0*sample27-8.0*sample11+sample3)/12.0;
gy = (-sample21+8.0*sample20-8.0*sample18+sample17)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample36+8.0*sample28-8.0*sample12+sample4)/12.0;
gy = (-sample22+8.0*sample21-8.0*sample19+sample18)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample37+8.0*sample29-8.0*sample13+sample5)/12.0;
gy = (-sample23+8.0*sample22-8.0*sample20+sample19)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample38+8.0*sample30-8.0*sample14+sample6)/12.0;
gy = (sample23-sample21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample41+8.0*sample33-8.0*sample17+sample9)/12.0;
gy = (sample26-sample24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample42+8.0*sample34-8.0*sample18+sample10)/12.0;
gy = (-sample28+8.0*sample27-8.0*sample25+sample24)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample43+8.0*sample35-8.0*sample19+sample11)/12.0;
gy = (-sample29+8.0*sample28-8.0*sample26+sample25)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample44+8.0*sample36-8.0*sample20+sample12)/12.0;
gy = (-sample30+8.0*sample29-8.0*sample27+sample26)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample45+8.0*sample37-8.0*sample21+sample13)/12.0;
gy = (-sample31+8.0*sample30-8.0*sample28+sample27)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample46+8.0*sample38-8.0*sample22+sample14)/12.0;
gy = (sample31-sample29)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample49+8.0*sample41-8.0*sample25+sample17)/12.0;
gy = (sample34-sample32)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample50+8.0*sample42-8.0*sample26+sample18)/12.0;
gy = (-sample36+8.0*sample35-8.0*sample33+sample32)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample51+8.0*sample43-8.0*sample27+sample19)/12.0;
gy = (-sample37+8.0*sample36-8.0*sample34+sample33)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample52+8.0*sample44-8.0*sample28+sample20)/12.0;
gy = (-sample38+8.0*sample37-8.0*sample35+sample34)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample53+8.0*sample45-8.0*sample29+sample21)/12.0;
gy = (-sample39+8.0*sample38-8.0*sample36+sample35)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample54+8.0*sample46-8.0*sample30+sample22)/12.0;
gy = (sample39-sample37)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample57+8.0*sample49-8.0*sample33+sample25)/12.0;
gy = (sample42-sample40)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample58+8.0*sample50-8.0*sample34+sample26)/12.0;
gy = (-sample44+8.0*sample43-8.0*sample41+sample40)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample59+8.0*sample51-8.0*sample35+sample27)/12.0;
gy = (-sample45+8.0*sample44-8.0*sample42+sample41)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample60+8.0*sample52-8.0*sample36+sample28)/12.0;
gy = (-sample46+8.0*sample45-8.0*sample43+sample42)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample61+8.0*sample53-8.0*sample37+sample29)/12.0;
gy = (-sample47+8.0*sample46-8.0*sample44+sample43)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample62+8.0*sample54-8.0*sample38+sample30)/12.0;
gy = (sample47-sample45)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample57-sample41)/2.0;
gy = (sample50-sample48)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (sample58-sample42)/2.0;
gy = (-sample52+8.0*sample51-8.0*sample49+sample48)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample59-sample43)/2.0;
gy = (-sample53+8.0*sample52-8.0*sample50+sample49)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample60-sample44)/2.0;
gy = (-sample54+8.0*sample53-8.0*sample51+sample50)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample61-sample45)/2.0;
gy = (-sample55+8.0*sample54-8.0*sample52+sample51)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample62-sample46)/2.0;
gy = (sample55-sample53)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
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;
float res = 0.0;
vec4 w;
w = texture(ravu_lut4, vec2(0.0625, coord_y));
res += (sample0 + sample63) * w[0];
res += (sample1 + sample62) * w[1];
res += (sample2 + sample61) * w[2];
res += (sample3 + sample60) * w[3];
w = texture(ravu_lut4, vec2(0.1875, coord_y));
res += (sample4 + sample59) * w[0];
res += (sample5 + sample58) * w[1];
res += (sample6 + sample57) * w[2];
res += (sample7 + sample56) * w[3];
w = texture(ravu_lut4, vec2(0.3125, coord_y));
res += (sample8 + sample55) * w[0];
res += (sample9 + sample54) * w[1];
res += (sample10 + sample53) * w[2];
res += (sample11 + sample52) * w[3];
w = texture(ravu_lut4, vec2(0.4375, coord_y));
res += (sample12 + sample51) * w[0];
res += (sample13 + sample50) * w[1];
res += (sample14 + sample49) * w[2];
res += (sample15 + sample48) * w[3];
w = texture(ravu_lut4, vec2(0.5625, coord_y));
res += (sample16 + sample47) * w[0];
res += (sample17 + sample46) * w[1];
res += (sample18 + sample45) * w[2];
res += (sample19 + sample44) * w[3];
w = texture(ravu_lut4, vec2(0.6875, coord_y));
res += (sample20 + sample43) * w[0];
res += (sample21 + sample42) * w[1];
res += (sample22 + sample41) * w[2];
res += (sample23 + sample40) * w[3];
w = texture(ravu_lut4, vec2(0.8125, coord_y));
res += (sample24 + sample39) * w[0];
res += (sample25 + sample38) * w[1];
res += (sample26 + sample37) * w[2];
res += (sample27 + sample36) * w[3];
w = texture(ravu_lut4, vec2(0.9375, coord_y));
res += (sample28 + sample35) * w[0];
res += (sample29 + sample34) * w[1];
res += (sample30 + sample33) * w[2];
res += (sample31 + sample32) * w[3];
res = clamp(res, 0.0, 1.0);
return vec4(res, 0.0, 0.0, 0.0);
}
//!DESC RAVU (step2, luma, r4)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_lut4
//!BIND ravu_int11
//!SAVE ravu_int10
//!WHEN HOOKED.w 2 * OUTPUT.w / 1.414213 < HOOKED.h 2 * OUTPUT.h / 1.414213 < *
vec4 hook() {
float sample0 = HOOKED_texOff(vec2(-3.0, 0.0)).x;
float sample16 = HOOKED_texOff(vec2(-2.0, -1.0)).x;
float sample9 = HOOKED_texOff(vec2(-2.0, 0.0)).x;
float sample2 = HOOKED_texOff(vec2(-2.0, 1.0)).x;
float sample32 = HOOKED_texOff(vec2(-1.0, -2.0)).x;
float sample25 = HOOKED_texOff(vec2(-1.0, -1.0)).x;
float sample18 = HOOKED_texOff(vec2(-1.0, 0.0)).x;
float sample11 = HOOKED_texOff(vec2(-1.0, 1.0)).x;
float sample4 = HOOKED_texOff(vec2(-1.0, 2.0)).x;
float sample48 = HOOKED_texOff(vec2(0.0, -3.0)).x;
float sample41 = HOOKED_texOff(vec2(0.0, -2.0)).x;
float sample34 = HOOKED_texOff(vec2(0.0, -1.0)).x;
float sample27 = HOOKED_texOff(vec2(0.0, 0.0)).x;
float sample20 = HOOKED_texOff(vec2(0.0, 1.0)).x;
float sample13 = HOOKED_texOff(vec2(0.0, 2.0)).x;
float sample6 = HOOKED_texOff(vec2(0.0, 3.0)).x;
float sample57 = HOOKED_texOff(vec2(1.0, -3.0)).x;
float sample50 = HOOKED_texOff(vec2(1.0, -2.0)).x;
float sample43 = HOOKED_texOff(vec2(1.0, -1.0)).x;
float sample36 = HOOKED_texOff(vec2(1.0, 0.0)).x;
float sample29 = HOOKED_texOff(vec2(1.0, 1.0)).x;
float sample22 = HOOKED_texOff(vec2(1.0, 2.0)).x;
float sample15 = HOOKED_texOff(vec2(1.0, 3.0)).x;
float sample59 = HOOKED_texOff(vec2(2.0, -2.0)).x;
float sample52 = HOOKED_texOff(vec2(2.0, -1.0)).x;
float sample45 = HOOKED_texOff(vec2(2.0, 0.0)).x;
float sample38 = HOOKED_texOff(vec2(2.0, 1.0)).x;
float sample31 = HOOKED_texOff(vec2(2.0, 2.0)).x;
float sample61 = HOOKED_texOff(vec2(3.0, -1.0)).x;
float sample54 = HOOKED_texOff(vec2(3.0, 0.0)).x;
float sample47 = HOOKED_texOff(vec2(3.0, 1.0)).x;
float sample63 = HOOKED_texOff(vec2(4.0, 0.0)).x;
float sample8 = ravu_int11_texOff(vec2(-3.0, -1.0)).x;
float sample1 = ravu_int11_texOff(vec2(-3.0, 0.0)).x;
float sample24 = ravu_int11_texOff(vec2(-2.0, -2.0)).x;
float sample17 = ravu_int11_texOff(vec2(-2.0, -1.0)).x;
float sample10 = ravu_int11_texOff(vec2(-2.0, 0.0)).x;
float sample3 = ravu_int11_texOff(vec2(-2.0, 1.0)).x;
float sample40 = ravu_int11_texOff(vec2(-1.0, -3.0)).x;
float sample33 = ravu_int11_texOff(vec2(-1.0, -2.0)).x;
float sample26 = ravu_int11_texOff(vec2(-1.0, -1.0)).x;
float sample19 = ravu_int11_texOff(vec2(-1.0, 0.0)).x;
float sample12 = ravu_int11_texOff(vec2(-1.0, 1.0)).x;
float sample5 = ravu_int11_texOff(vec2(-1.0, 2.0)).x;
float sample56 = ravu_int11_texOff(vec2(0.0, -4.0)).x;
float sample49 = ravu_int11_texOff(vec2(0.0, -3.0)).x;
float sample42 = ravu_int11_texOff(vec2(0.0, -2.0)).x;
float sample35 = ravu_int11_texOff(vec2(0.0, -1.0)).x;
float sample28 = ravu_int11_texOff(vec2(0.0, 0.0)).x;
float sample21 = ravu_int11_texOff(vec2(0.0, 1.0)).x;
float sample14 = ravu_int11_texOff(vec2(0.0, 2.0)).x;
float sample7 = ravu_int11_texOff(vec2(0.0, 3.0)).x;
float sample58 = ravu_int11_texOff(vec2(1.0, -3.0)).x;
float sample51 = ravu_int11_texOff(vec2(1.0, -2.0)).x;
float sample44 = ravu_int11_texOff(vec2(1.0, -1.0)).x;
float sample37 = ravu_int11_texOff(vec2(1.0, 0.0)).x;
float sample30 = ravu_int11_texOff(vec2(1.0, 1.0)).x;
float sample23 = ravu_int11_texOff(vec2(1.0, 2.0)).x;
float sample60 = ravu_int11_texOff(vec2(2.0, -2.0)).x;
float sample53 = ravu_int11_texOff(vec2(2.0, -1.0)).x;
float sample46 = ravu_int11_texOff(vec2(2.0, 0.0)).x;
float sample39 = ravu_int11_texOff(vec2(2.0, 1.0)).x;
float sample62 = ravu_int11_texOff(vec2(3.0, -1.0)).x;
float sample55 = ravu_int11_texOff(vec2(3.0, 0.0)).x;
vec3 abd = vec3(0.0);
float gx, gy;
gx = (sample17-sample1)/2.0;
gy = (sample10-sample8)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (sample18-sample2)/2.0;
gy = (-sample12+8.0*sample11-8.0*sample9+sample8)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample19-sample3)/2.0;
gy = (-sample13+8.0*sample12-8.0*sample10+sample9)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample20-sample4)/2.0;
gy = (-sample14+8.0*sample13-8.0*sample11+sample10)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample21-sample5)/2.0;
gy = (-sample15+8.0*sample14-8.0*sample12+sample11)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample22-sample6)/2.0;
gy = (sample15-sample13)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (-sample33+8.0*sample25-8.0*sample9+sample1)/12.0;
gy = (sample18-sample16)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample34+8.0*sample26-8.0*sample10+sample2)/12.0;
gy = (-sample20+8.0*sample19-8.0*sample17+sample16)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample35+8.0*sample27-8.0*sample11+sample3)/12.0;
gy = (-sample21+8.0*sample20-8.0*sample18+sample17)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample36+8.0*sample28-8.0*sample12+sample4)/12.0;
gy = (-sample22+8.0*sample21-8.0*sample19+sample18)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample37+8.0*sample29-8.0*sample13+sample5)/12.0;
gy = (-sample23+8.0*sample22-8.0*sample20+sample19)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample38+8.0*sample30-8.0*sample14+sample6)/12.0;
gy = (sample23-sample21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample41+8.0*sample33-8.0*sample17+sample9)/12.0;
gy = (sample26-sample24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample42+8.0*sample34-8.0*sample18+sample10)/12.0;
gy = (-sample28+8.0*sample27-8.0*sample25+sample24)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample43+8.0*sample35-8.0*sample19+sample11)/12.0;
gy = (-sample29+8.0*sample28-8.0*sample26+sample25)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample44+8.0*sample36-8.0*sample20+sample12)/12.0;
gy = (-sample30+8.0*sample29-8.0*sample27+sample26)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample45+8.0*sample37-8.0*sample21+sample13)/12.0;
gy = (-sample31+8.0*sample30-8.0*sample28+sample27)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample46+8.0*sample38-8.0*sample22+sample14)/12.0;
gy = (sample31-sample29)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample49+8.0*sample41-8.0*sample25+sample17)/12.0;
gy = (sample34-sample32)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample50+8.0*sample42-8.0*sample26+sample18)/12.0;
gy = (-sample36+8.0*sample35-8.0*sample33+sample32)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample51+8.0*sample43-8.0*sample27+sample19)/12.0;
gy = (-sample37+8.0*sample36-8.0*sample34+sample33)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample52+8.0*sample44-8.0*sample28+sample20)/12.0;
gy = (-sample38+8.0*sample37-8.0*sample35+sample34)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample53+8.0*sample45-8.0*sample29+sample21)/12.0;
gy = (-sample39+8.0*sample38-8.0*sample36+sample35)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample54+8.0*sample46-8.0*sample30+sample22)/12.0;
gy = (sample39-sample37)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample57+8.0*sample49-8.0*sample33+sample25)/12.0;
gy = (sample42-sample40)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample58+8.0*sample50-8.0*sample34+sample26)/12.0;
gy = (-sample44+8.0*sample43-8.0*sample41+sample40)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample59+8.0*sample51-8.0*sample35+sample27)/12.0;
gy = (-sample45+8.0*sample44-8.0*sample42+sample41)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample60+8.0*sample52-8.0*sample36+sample28)/12.0;
gy = (-sample46+8.0*sample45-8.0*sample43+sample42)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample61+8.0*sample53-8.0*sample37+sample29)/12.0;
gy = (-sample47+8.0*sample46-8.0*sample44+sample43)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample62+8.0*sample54-8.0*sample38+sample30)/12.0;
gy = (sample47-sample45)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample57-sample41)/2.0;
gy = (sample50-sample48)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (sample58-sample42)/2.0;
gy = (-sample52+8.0*sample51-8.0*sample49+sample48)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample59-sample43)/2.0;
gy = (-sample53+8.0*sample52-8.0*sample50+sample49)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample60-sample44)/2.0;
gy = (-sample54+8.0*sample53-8.0*sample51+sample50)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample61-sample45)/2.0;
gy = (-sample55+8.0*sample54-8.0*sample52+sample51)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample62-sample46)/2.0;
gy = (sample55-sample53)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
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;
float res = 0.0;
vec4 w;
w = texture(ravu_lut4, vec2(0.0625, coord_y));
res += (sample0 + sample63) * w[0];
res += (sample1 + sample62) * w[1];
res += (sample2 + sample61) * w[2];
res += (sample3 + sample60) * w[3];
w = texture(ravu_lut4, vec2(0.1875, coord_y));
res += (sample4 + sample59) * w[0];
res += (sample5 + sample58) * w[1];
res += (sample6 + sample57) * w[2];
res += (sample7 + sample56) * w[3];
w = texture(ravu_lut4, vec2(0.3125, coord_y));
res += (sample8 + sample55) * w[0];
res += (sample9 + sample54) * w[1];
res += (sample10 + sample53) * w[2];
res += (sample11 + sample52) * w[3];
w = texture(ravu_lut4, vec2(0.4375, coord_y));
res += (sample12 + sample51) * w[0];
res += (sample13 + sample50) * w[1];
res += (sample14 + sample49) * w[2];
res += (sample15 + sample48) * w[3];
w = texture(ravu_lut4, vec2(0.5625, coord_y));
res += (sample16 + sample47) * w[0];
res += (sample17 + sample46) * w[1];
res += (sample18 + sample45) * w[2];
res += (sample19 + sample44) * w[3];
w = texture(ravu_lut4, vec2(0.6875, coord_y));
res += (sample20 + sample43) * w[0];
res += (sample21 + sample42) * w[1];
res += (sample22 + sample41) * w[2];
res += (sample23 + sample40) * w[3];
w = texture(ravu_lut4, vec2(0.8125, coord_y));
res += (sample24 + sample39) * w[0];
res += (sample25 + sample38) * w[1];
res += (sample26 + sample37) * w[2];
res += (sample27 + sample36) * w[3];
w = texture(ravu_lut4, vec2(0.9375, coord_y));
res += (sample28 + sample35) * w[0];
res += (sample29 + sample34) * w[1];
res += (sample30 + sample33) * w[2];
res += (sample31 + sample32) * w[3];
res = clamp(res, 0.0, 1.0);
return vec4(res, 0.0, 0.0, 0.0);
}
//!DESC RAVU (step3, luma, r4)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_lut4
//!BIND ravu_int11
//!SAVE ravu_int01
//!WHEN HOOKED.w 2 * OUTPUT.w / 1.414213 < HOOKED.h 2 * OUTPUT.h / 1.414213 < *
vec4 hook() {
float sample8 = HOOKED_texOff(vec2(-3.0, 0.0)).x;
float sample1 = HOOKED_texOff(vec2(-3.0, 1.0)).x;
float sample24 = HOOKED_texOff(vec2(-2.0, -1.0)).x;
float sample17 = HOOKED_texOff(vec2(-2.0, 0.0)).x;
float sample10 = HOOKED_texOff(vec2(-2.0, 1.0)).x;
float sample3 = HOOKED_texOff(vec2(-2.0, 2.0)).x;
float sample40 = HOOKED_texOff(vec2(-1.0, -2.0)).x;
float sample33 = HOOKED_texOff(vec2(-1.0, -1.0)).x;
float sample26 = HOOKED_texOff(vec2(-1.0, 0.0)).x;
float sample19 = HOOKED_texOff(vec2(-1.0, 1.0)).x;
float sample12 = HOOKED_texOff(vec2(-1.0, 2.0)).x;
float sample5 = HOOKED_texOff(vec2(-1.0, 3.0)).x;
float sample56 = HOOKED_texOff(vec2(0.0, -3.0)).x;
float sample49 = HOOKED_texOff(vec2(0.0, -2.0)).x;
float sample42 = HOOKED_texOff(vec2(0.0, -1.0)).x;
float sample35 = HOOKED_texOff(vec2(0.0, 0.0)).x;
float sample28 = HOOKED_texOff(vec2(0.0, 1.0)).x;
float sample21 = HOOKED_texOff(vec2(0.0, 2.0)).x;
float sample14 = HOOKED_texOff(vec2(0.0, 3.0)).x;
float sample7 = HOOKED_texOff(vec2(0.0, 4.0)).x;
float sample58 = HOOKED_texOff(vec2(1.0, -2.0)).x;
float sample51 = HOOKED_texOff(vec2(1.0, -1.0)).x;
float sample44 = HOOKED_texOff(vec2(1.0, 0.0)).x;
float sample37 = HOOKED_texOff(vec2(1.0, 1.0)).x;
float sample30 = HOOKED_texOff(vec2(1.0, 2.0)).x;
float sample23 = HOOKED_texOff(vec2(1.0, 3.0)).x;
float sample60 = HOOKED_texOff(vec2(2.0, -1.0)).x;
float sample53 = HOOKED_texOff(vec2(2.0, 0.0)).x;
float sample46 = HOOKED_texOff(vec2(2.0, 1.0)).x;
float sample39 = HOOKED_texOff(vec2(2.0, 2.0)).x;
float sample62 = HOOKED_texOff(vec2(3.0, 0.0)).x;
float sample55 = HOOKED_texOff(vec2(3.0, 1.0)).x;
float sample0 = ravu_int11_texOff(vec2(-4.0, 0.0)).x;
float sample16 = ravu_int11_texOff(vec2(-3.0, -1.0)).x;
float sample9 = ravu_int11_texOff(vec2(-3.0, 0.0)).x;
float sample2 = ravu_int11_texOff(vec2(-3.0, 1.0)).x;
float sample32 = ravu_int11_texOff(vec2(-2.0, -2.0)).x;
float sample25 = ravu_int11_texOff(vec2(-2.0, -1.0)).x;
float sample18 = ravu_int11_texOff(vec2(-2.0, 0.0)).x;
float sample11 = ravu_int11_texOff(vec2(-2.0, 1.0)).x;
float sample4 = ravu_int11_texOff(vec2(-2.0, 2.0)).x;
float sample48 = ravu_int11_texOff(vec2(-1.0, -3.0)).x;
float sample41 = ravu_int11_texOff(vec2(-1.0, -2.0)).x;
float sample34 = ravu_int11_texOff(vec2(-1.0, -1.0)).x;
float sample27 = ravu_int11_texOff(vec2(-1.0, 0.0)).x;
float sample20 = ravu_int11_texOff(vec2(-1.0, 1.0)).x;
float sample13 = ravu_int11_texOff(vec2(-1.0, 2.0)).x;
float sample6 = ravu_int11_texOff(vec2(-1.0, 3.0)).x;
float sample57 = ravu_int11_texOff(vec2(0.0, -3.0)).x;
float sample50 = ravu_int11_texOff(vec2(0.0, -2.0)).x;
float sample43 = ravu_int11_texOff(vec2(0.0, -1.0)).x;
float sample36 = ravu_int11_texOff(vec2(0.0, 0.0)).x;
float sample29 = ravu_int11_texOff(vec2(0.0, 1.0)).x;
float sample22 = ravu_int11_texOff(vec2(0.0, 2.0)).x;
float sample15 = ravu_int11_texOff(vec2(0.0, 3.0)).x;
float sample59 = ravu_int11_texOff(vec2(1.0, -2.0)).x;
float sample52 = ravu_int11_texOff(vec2(1.0, -1.0)).x;
float sample45 = ravu_int11_texOff(vec2(1.0, 0.0)).x;
float sample38 = ravu_int11_texOff(vec2(1.0, 1.0)).x;
float sample31 = ravu_int11_texOff(vec2(1.0, 2.0)).x;
float sample61 = ravu_int11_texOff(vec2(2.0, -1.0)).x;
float sample54 = ravu_int11_texOff(vec2(2.0, 0.0)).x;
float sample47 = ravu_int11_texOff(vec2(2.0, 1.0)).x;
float sample63 = ravu_int11_texOff(vec2(3.0, 0.0)).x;
vec3 abd = vec3(0.0);
float gx, gy;
gx = (sample17-sample1)/2.0;
gy = (sample10-sample8)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (sample18-sample2)/2.0;
gy = (-sample12+8.0*sample11-8.0*sample9+sample8)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample19-sample3)/2.0;
gy = (-sample13+8.0*sample12-8.0*sample10+sample9)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample20-sample4)/2.0;
gy = (-sample14+8.0*sample13-8.0*sample11+sample10)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample21-sample5)/2.0;
gy = (-sample15+8.0*sample14-8.0*sample12+sample11)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample22-sample6)/2.0;
gy = (sample15-sample13)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (-sample33+8.0*sample25-8.0*sample9+sample1)/12.0;
gy = (sample18-sample16)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample34+8.0*sample26-8.0*sample10+sample2)/12.0;
gy = (-sample20+8.0*sample19-8.0*sample17+sample16)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample35+8.0*sample27-8.0*sample11+sample3)/12.0;
gy = (-sample21+8.0*sample20-8.0*sample18+sample17)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample36+8.0*sample28-8.0*sample12+sample4)/12.0;
gy = (-sample22+8.0*sample21-8.0*sample19+sample18)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample37+8.0*sample29-8.0*sample13+sample5)/12.0;
gy = (-sample23+8.0*sample22-8.0*sample20+sample19)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample38+8.0*sample30-8.0*sample14+sample6)/12.0;
gy = (sample23-sample21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample41+8.0*sample33-8.0*sample17+sample9)/12.0;
gy = (sample26-sample24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample42+8.0*sample34-8.0*sample18+sample10)/12.0;
gy = (-sample28+8.0*sample27-8.0*sample25+sample24)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample43+8.0*sample35-8.0*sample19+sample11)/12.0;
gy = (-sample29+8.0*sample28-8.0*sample26+sample25)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample44+8.0*sample36-8.0*sample20+sample12)/12.0;
gy = (-sample30+8.0*sample29-8.0*sample27+sample26)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample45+8.0*sample37-8.0*sample21+sample13)/12.0;
gy = (-sample31+8.0*sample30-8.0*sample28+sample27)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample46+8.0*sample38-8.0*sample22+sample14)/12.0;
gy = (sample31-sample29)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample49+8.0*sample41-8.0*sample25+sample17)/12.0;
gy = (sample34-sample32)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample50+8.0*sample42-8.0*sample26+sample18)/12.0;
gy = (-sample36+8.0*sample35-8.0*sample33+sample32)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample51+8.0*sample43-8.0*sample27+sample19)/12.0;
gy = (-sample37+8.0*sample36-8.0*sample34+sample33)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample52+8.0*sample44-8.0*sample28+sample20)/12.0;
gy = (-sample38+8.0*sample37-8.0*sample35+sample34)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04933151482066013;
gx = (-sample53+8.0*sample45-8.0*sample29+sample21)/12.0;
gy = (-sample39+8.0*sample38-8.0*sample36+sample35)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample54+8.0*sample46-8.0*sample30+sample22)/12.0;
gy = (sample39-sample37)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (-sample57+8.0*sample49-8.0*sample33+sample25)/12.0;
gy = (sample42-sample40)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (-sample58+8.0*sample50-8.0*sample34+sample26)/12.0;
gy = (-sample44+8.0*sample43-8.0*sample41+sample40)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample59+8.0*sample51-8.0*sample35+sample27)/12.0;
gy = (-sample45+8.0*sample44-8.0*sample42+sample41)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample60+8.0*sample52-8.0*sample36+sample28)/12.0;
gy = (-sample46+8.0*sample45-8.0*sample43+sample42)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.03841942237242872;
gx = (-sample61+8.0*sample53-8.0*sample37+sample29)/12.0;
gy = (-sample47+8.0*sample46-8.0*sample44+sample43)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02992107622879854;
gx = (-sample62+8.0*sample54-8.0*sample38+sample30)/12.0;
gy = (sample47-sample45)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample57-sample41)/2.0;
gy = (sample50-sample48)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
gx = (sample58-sample42)/2.0;
gy = (-sample52+8.0*sample51-8.0*sample49+sample48)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample59-sample43)/2.0;
gy = (-sample53+8.0*sample52-8.0*sample50+sample49)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample60-sample44)/2.0;
gy = (-sample54+8.0*sample53-8.0*sample51+sample50)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.0233025575973275;
gx = (sample61-sample45)/2.0;
gy = (-sample55+8.0*sample54-8.0*sample52+sample51)/12.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.018148050104365175;
gx = (sample62-sample46)/2.0;
gy = (sample55-sample53)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.011007348802298533;
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;
float res = 0.0;
vec4 w;
w = texture(ravu_lut4, vec2(0.0625, coord_y));
res += (sample0 + sample63) * w[0];
res += (sample1 + sample62) * w[1];
res += (sample2 + sample61) * w[2];
res += (sample3 + sample60) * w[3];
w = texture(ravu_lut4, vec2(0.1875, coord_y));
res += (sample4 + sample59) * w[0];
res += (sample5 + sample58) * w[1];
res += (sample6 + sample57) * w[2];
res += (sample7 + sample56) * w[3];
w = texture(ravu_lut4, vec2(0.3125, coord_y));
res += (sample8 + sample55) * w[0];
res += (sample9 + sample54) * w[1];
res += (sample10 + sample53) * w[2];
res += (sample11 + sample52) * w[3];
w = texture(ravu_lut4, vec2(0.4375, coord_y));
res += (sample12 + sample51) * w[0];
res += (sample13 + sample50) * w[1];
res += (sample14 + sample49) * w[2];
res += (sample15 + sample48) * w[3];
w = texture(ravu_lut4, vec2(0.5625, coord_y));
res += (sample16 + sample47) * w[0];
res += (sample17 + sample46) * w[1];
res += (sample18 + sample45) * w[2];
res += (sample19 + sample44) * w[3];
w = texture(ravu_lut4, vec2(0.6875, coord_y));
res += (sample20 + sample43) * w[0];
res += (sample21 + sample42) * w[1];
res += (sample22 + sample41) * w[2];
res += (sample23 + sample40) * w[3];
w = texture(ravu_lut4, vec2(0.8125, coord_y));
res += (sample24 + sample39) * w[0];
res += (sample25 + sample38) * w[1];
res += (sample26 + sample37) * w[2];
res += (sample27 + sample36) * w[3];
w = texture(ravu_lut4, vec2(0.9375, coord_y));
res += (sample28 + sample35) * w[0];
res += (sample29 + sample34) * w[1];
res += (sample30 + sample33) * w[2];
res += (sample31 + sample32) * w[3];
res = clamp(res, 0.0, 1.0);
return vec4(res, 0.0, 0.0, 0.0);
}
//!DESC RAVU (step4, luma, r4)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_int01
//!BIND ravu_int10
//!BIND ravu_int11
//!WIDTH 2 HOOKED.w *
//!HEIGHT 2 HOOKED.h *
//!OFFSET -0.500000 -0.500000
//!WHEN HOOKED.w 2 * OUTPUT.w / 1.414213 < HOOKED.h 2 * OUTPUT.h / 1.414213 < *
vec4 hook() {
    vec2 dir = fract(HOOKED_pos * HOOKED_size) - 0.5;
    if (dir.x < 0.0) {
        if (dir.y < 0.0)
            return HOOKED_texOff(-dir);
        return ravu_int01_texOff(-dir);
    } else {
        if (dir.y < 0.0)
            return ravu_int10_texOff(-dir);
        return ravu_int11_texOff(-dir);
    }
}
//!TEXTURE ravu_lut4
//!SIZE 8 648
//!FORMAT rgba16hf
//!FILTER NEAREST
[encoded data, 82944 characters]
