// 
// 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-Lite (step1, r4)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_lite_lut4
//!SAVE ravu_lite_int
//!WHEN HOOKED.w OUTPUT.w / 0.707106 < HOOKED.h OUTPUT.h / 0.707106 < *
//!COMPONENTS 4
vec4 hook() {
float luma0 = HOOKED_texOff(vec2(-3.0, -3.0)).x;
float luma1 = HOOKED_texOff(vec2(-3.0, -2.0)).x;
float luma2 = HOOKED_texOff(vec2(-3.0, -1.0)).x;
float luma3 = HOOKED_texOff(vec2(-3.0, 0.0)).x;
float luma4 = HOOKED_texOff(vec2(-3.0, 1.0)).x;
float luma5 = HOOKED_texOff(vec2(-3.0, 2.0)).x;
float luma6 = HOOKED_texOff(vec2(-3.0, 3.0)).x;
float luma7 = HOOKED_texOff(vec2(-2.0, -3.0)).x;
float luma8 = HOOKED_texOff(vec2(-2.0, -2.0)).x;
float luma9 = HOOKED_texOff(vec2(-2.0, -1.0)).x;
float luma10 = HOOKED_texOff(vec2(-2.0, 0.0)).x;
float luma11 = HOOKED_texOff(vec2(-2.0, 1.0)).x;
float luma12 = HOOKED_texOff(vec2(-2.0, 2.0)).x;
float luma13 = HOOKED_texOff(vec2(-2.0, 3.0)).x;
float luma14 = HOOKED_texOff(vec2(-1.0, -3.0)).x;
float luma15 = HOOKED_texOff(vec2(-1.0, -2.0)).x;
float luma16 = HOOKED_texOff(vec2(-1.0, -1.0)).x;
float luma17 = HOOKED_texOff(vec2(-1.0, 0.0)).x;
float luma18 = HOOKED_texOff(vec2(-1.0, 1.0)).x;
float luma19 = HOOKED_texOff(vec2(-1.0, 2.0)).x;
float luma20 = HOOKED_texOff(vec2(-1.0, 3.0)).x;
float luma21 = HOOKED_texOff(vec2(0.0, -3.0)).x;
float luma22 = HOOKED_texOff(vec2(0.0, -2.0)).x;
float luma23 = HOOKED_texOff(vec2(0.0, -1.0)).x;
float luma24 = HOOKED_texOff(vec2(0.0, 0.0)).x;
float luma25 = HOOKED_texOff(vec2(0.0, 1.0)).x;
float luma26 = HOOKED_texOff(vec2(0.0, 2.0)).x;
float luma27 = HOOKED_texOff(vec2(0.0, 3.0)).x;
float luma28 = HOOKED_texOff(vec2(1.0, -3.0)).x;
float luma29 = HOOKED_texOff(vec2(1.0, -2.0)).x;
float luma30 = HOOKED_texOff(vec2(1.0, -1.0)).x;
float luma31 = HOOKED_texOff(vec2(1.0, 0.0)).x;
float luma32 = HOOKED_texOff(vec2(1.0, 1.0)).x;
float luma33 = HOOKED_texOff(vec2(1.0, 2.0)).x;
float luma34 = HOOKED_texOff(vec2(1.0, 3.0)).x;
float luma35 = HOOKED_texOff(vec2(2.0, -3.0)).x;
float luma36 = HOOKED_texOff(vec2(2.0, -2.0)).x;
float luma37 = HOOKED_texOff(vec2(2.0, -1.0)).x;
float luma38 = HOOKED_texOff(vec2(2.0, 0.0)).x;
float luma39 = HOOKED_texOff(vec2(2.0, 1.0)).x;
float luma40 = HOOKED_texOff(vec2(2.0, 2.0)).x;
float luma41 = HOOKED_texOff(vec2(2.0, 3.0)).x;
float luma42 = HOOKED_texOff(vec2(3.0, -3.0)).x;
float luma43 = HOOKED_texOff(vec2(3.0, -2.0)).x;
float luma44 = HOOKED_texOff(vec2(3.0, -1.0)).x;
float luma45 = HOOKED_texOff(vec2(3.0, 0.0)).x;
float luma46 = HOOKED_texOff(vec2(3.0, 1.0)).x;
float luma47 = HOOKED_texOff(vec2(3.0, 2.0)).x;
float luma48 = HOOKED_texOff(vec2(3.0, 3.0)).x;
vec3 abd = vec3(0.0);
float gx, gy;
gx = (luma15-luma1)/2.0;
gy = (luma9-luma7)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
gx = (luma16-luma2)/2.0;
gy = (luma10-luma8)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma17-luma3)/2.0;
gy = (luma11-luma9)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
gx = (luma18-luma4)/2.0;
gy = (luma12-luma10)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma19-luma5)/2.0;
gy = (luma13-luma11)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
gx = (luma22-luma8)/2.0;
gy = (luma16-luma14)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma23-luma9)/2.0;
gy = (luma17-luma15)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
gx = (luma24-luma10)/2.0;
gy = (luma18-luma16)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
gx = (luma25-luma11)/2.0;
gy = (luma19-luma17)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
gx = (luma26-luma12)/2.0;
gy = (luma20-luma18)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma29-luma15)/2.0;
gy = (luma23-luma21)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
gx = (luma30-luma16)/2.0;
gy = (luma24-luma22)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
gx = (luma31-luma17)/2.0;
gy = (luma25-luma23)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06319146241026467;
gx = (luma32-luma18)/2.0;
gy = (luma26-luma24)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
gx = (luma33-luma19)/2.0;
gy = (luma27-luma25)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
gx = (luma36-luma22)/2.0;
gy = (luma30-luma28)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma37-luma23)/2.0;
gy = (luma31-luma29)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
gx = (luma38-luma24)/2.0;
gy = (luma32-luma30)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
gx = (luma39-luma25)/2.0;
gy = (luma33-luma31)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
gx = (luma40-luma26)/2.0;
gy = (luma34-luma32)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma43-luma29)/2.0;
gy = (luma37-luma35)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
gx = (luma44-luma30)/2.0;
gy = (luma38-luma36)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma45-luma31)/2.0;
gy = (luma39-luma37)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
gx = (luma46-luma32)/2.0;
gy = (luma40-luma38)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
gx = (luma47-luma33)/2.0;
gy = (luma41-luma39)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
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 = mix(mix(0.0, 1.0, lambda >= 0.004), mix(2.0, 3.0, lambda >= 0.05), lambda >= 0.016);
float coherence = mix(mix(0.0, 1.0, mu >= 0.25), 2.0, mu >= 0.5);
float coord_y = ((angle * 4.0 + strength) * 3.0 + coherence + 0.5) / 288.0;
vec4 res = vec4(0.0), w;
w = texture(ravu_lite_lut4, vec2(0.02, coord_y));
res += luma0 * w + luma48 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.06, coord_y));
res += luma1 * w + luma47 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.1, coord_y));
res += luma2 * w + luma46 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.14, coord_y));
res += luma3 * w + luma45 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.18, coord_y));
res += luma4 * w + luma44 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.22, coord_y));
res += luma5 * w + luma43 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.26, coord_y));
res += luma6 * w + luma42 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.3, coord_y));
res += luma7 * w + luma41 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.34, coord_y));
res += luma8 * w + luma40 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.38, coord_y));
res += luma9 * w + luma39 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.42, coord_y));
res += luma10 * w + luma38 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.46, coord_y));
res += luma11 * w + luma37 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.5, coord_y));
res += luma12 * w + luma36 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.54, coord_y));
res += luma13 * w + luma35 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.58, coord_y));
res += luma14 * w + luma34 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.62, coord_y));
res += luma15 * w + luma33 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.66, coord_y));
res += luma16 * w + luma32 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.7, coord_y));
res += luma17 * w + luma31 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.74, coord_y));
res += luma18 * w + luma30 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.78, coord_y));
res += luma19 * w + luma29 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.82, coord_y));
res += luma20 * w + luma28 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.86, coord_y));
res += luma21 * w + luma27 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.9, coord_y));
res += luma22 * w + luma26 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.94, coord_y));
res += luma23 * w + luma25 * w.wzyx;
w = texture(ravu_lite_lut4, vec2(0.98, coord_y));
res += luma24 * w;
res = clamp(res, 0.0, 1.0);
return res;
}
//!DESC RAVU-Lite (step2, r4)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_lite_int
//!WIDTH 2 HOOKED.w *
//!HEIGHT 2 HOOKED.h *
//!WHEN HOOKED.w OUTPUT.w / 0.707106 < HOOKED.h OUTPUT.h / 0.707106 < *
//!COMPONENTS 1
vec4 hook() {
    vec2 dir = fract(HOOKED_pos * HOOKED_size) - 0.5;
    int idx = int(dir.x > 0.0) * 2 + int(dir.y > 0.0);
    return vec4(ravu_lite_int_texOff(-dir)[idx], 0.0, 0.0, 0.0);
}
//!TEXTURE ravu_lite_lut4
//!SIZE 25 288
//!FORMAT rgba16f
//!FILTER NEAREST
[encoded data, 230400 characters]
