184 lines
122 KiB
Text
184 lines
122 KiB
Text
|
//
|
||
|
// 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 (r4, compute)
|
||
|
//!HOOK LUMA
|
||
|
//!BIND HOOKED
|
||
|
//!BIND ravu_lite_lut4
|
||
|
//!WIDTH 2 HOOKED.w *
|
||
|
//!HEIGHT 2 HOOKED.h *
|
||
|
//!WHEN HOOKED.w OUTPUT.w / 0.707106 < HOOKED.h OUTPUT.h / 0.707106 < *
|
||
|
//!COMPUTE 64 16 32 8
|
||
|
shared float inp[532];
|
||
|
void hook() {
|
||
|
ivec2 group_base = ivec2(gl_WorkGroupID) * ivec2(gl_WorkGroupSize);
|
||
|
int local_pos = int(gl_LocalInvocationID.x) * 14 + int(gl_LocalInvocationID.y);
|
||
|
for (int id = int(gl_LocalInvocationIndex); id < 532; id += int(gl_WorkGroupSize.x * gl_WorkGroupSize.y)) {
|
||
|
int x = id / 14, y = id % 14;
|
||
|
inp[id] = HOOKED_tex(HOOKED_pt * vec2(float(group_base.x+x)+(-2.5), float(group_base.y+y)+(-2.5))).x;
|
||
|
}
|
||
|
groupMemoryBarrier();
|
||
|
barrier();
|
||
|
vec3 abd = vec3(0.0);
|
||
|
float gx, gy;
|
||
|
gx = (inp[local_pos + 29]-inp[local_pos + 1])/2.0;
|
||
|
gy = (inp[local_pos + 16]-inp[local_pos + 14])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
|
||
|
gx = (inp[local_pos + 30]-inp[local_pos + 2])/2.0;
|
||
|
gy = (inp[local_pos + 17]-inp[local_pos + 15])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 31]-inp[local_pos + 3])/2.0;
|
||
|
gy = (inp[local_pos + 18]-inp[local_pos + 16])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
|
||
|
gx = (inp[local_pos + 32]-inp[local_pos + 4])/2.0;
|
||
|
gy = (inp[local_pos + 19]-inp[local_pos + 17])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 33]-inp[local_pos + 5])/2.0;
|
||
|
gy = (inp[local_pos + 20]-inp[local_pos + 18])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
|
||
|
gx = (inp[local_pos + 43]-inp[local_pos + 15])/2.0;
|
||
|
gy = (inp[local_pos + 30]-inp[local_pos + 28])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 44]-inp[local_pos + 16])/2.0;
|
||
|
gy = (inp[local_pos + 31]-inp[local_pos + 29])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
|
||
|
gx = (inp[local_pos + 45]-inp[local_pos + 17])/2.0;
|
||
|
gy = (inp[local_pos + 32]-inp[local_pos + 30])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
|
||
|
gx = (inp[local_pos + 46]-inp[local_pos + 18])/2.0;
|
||
|
gy = (inp[local_pos + 33]-inp[local_pos + 31])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
|
||
|
gx = (inp[local_pos + 47]-inp[local_pos + 19])/2.0;
|
||
|
gy = (inp[local_pos + 34]-inp[local_pos + 32])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 57]-inp[local_pos + 29])/2.0;
|
||
|
gy = (inp[local_pos + 44]-inp[local_pos + 42])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
|
||
|
gx = (inp[local_pos + 58]-inp[local_pos + 30])/2.0;
|
||
|
gy = (inp[local_pos + 45]-inp[local_pos + 43])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
|
||
|
gx = (inp[local_pos + 59]-inp[local_pos + 31])/2.0;
|
||
|
gy = (inp[local_pos + 46]-inp[local_pos + 44])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.06319146241026467;
|
||
|
gx = (inp[local_pos + 60]-inp[local_pos + 32])/2.0;
|
||
|
gy = (inp[local_pos + 47]-inp[local_pos + 45])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
|
||
|
gx = (inp[local_pos + 61]-inp[local_pos + 33])/2.0;
|
||
|
gy = (inp[local_pos + 48]-inp[local_pos + 46])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
|
||
|
gx = (inp[local_pos + 71]-inp[local_pos + 43])/2.0;
|
||
|
gy = (inp[local_pos + 58]-inp[local_pos + 56])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 72]-inp[local_pos + 44])/2.0;
|
||
|
gy = (inp[local_pos + 59]-inp[local_pos + 57])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
|
||
|
gx = (inp[local_pos + 73]-inp[local_pos + 45])/2.0;
|
||
|
gy = (inp[local_pos + 60]-inp[local_pos + 58])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.055766269846849466;
|
||
|
gx = (inp[local_pos + 74]-inp[local_pos + 46])/2.0;
|
||
|
gy = (inp[local_pos + 61]-inp[local_pos + 59])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.04921356040854137;
|
||
|
gx = (inp[local_pos + 75]-inp[local_pos + 47])/2.0;
|
||
|
gy = (inp[local_pos + 62]-inp[local_pos + 60])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 85]-inp[local_pos + 57])/2.0;
|
||
|
gy = (inp[local_pos + 72]-inp[local_pos + 70])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.02324683987829437;
|
||
|
gx = (inp[local_pos + 86]-inp[local_pos + 58])/2.0;
|
||
|
gy = (inp[local_pos + 73]-inp[local_pos + 71])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 87]-inp[local_pos + 59])/2.0;
|
||
|
gy = (inp[local_pos + 74]-inp[local_pos + 72])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.038327559383903906;
|
||
|
gx = (inp[local_pos + 88]-inp[local_pos + 60])/2.0;
|
||
|
gy = (inp[local_pos + 75]-inp[local_pos + 73])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.033823952439922346;
|
||
|
gx = (inp[local_pos + 89]-inp[local_pos + 61])/2.0;
|
||
|
gy = (inp[local_pos + 76]-inp[local_pos + 74])/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 += inp[local_pos + 0] * w + inp[local_pos + 90] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.06, coord_y));
|
||
|
res += inp[local_pos + 1] * w + inp[local_pos + 89] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.1, coord_y));
|
||
|
res += inp[local_pos + 2] * w + inp[local_pos + 88] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.14, coord_y));
|
||
|
res += inp[local_pos + 3] * w + inp[local_pos + 87] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.18, coord_y));
|
||
|
res += inp[local_pos + 4] * w + inp[local_pos + 86] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.22, coord_y));
|
||
|
res += inp[local_pos + 5] * w + inp[local_pos + 85] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.26, coord_y));
|
||
|
res += inp[local_pos + 6] * w + inp[local_pos + 84] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.3, coord_y));
|
||
|
res += inp[local_pos + 14] * w + inp[local_pos + 76] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.34, coord_y));
|
||
|
res += inp[local_pos + 15] * w + inp[local_pos + 75] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.38, coord_y));
|
||
|
res += inp[local_pos + 16] * w + inp[local_pos + 74] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.42, coord_y));
|
||
|
res += inp[local_pos + 17] * w + inp[local_pos + 73] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.46, coord_y));
|
||
|
res += inp[local_pos + 18] * w + inp[local_pos + 72] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.5, coord_y));
|
||
|
res += inp[local_pos + 19] * w + inp[local_pos + 71] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.54, coord_y));
|
||
|
res += inp[local_pos + 20] * w + inp[local_pos + 70] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.58, coord_y));
|
||
|
res += inp[local_pos + 28] * w + inp[local_pos + 62] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.62, coord_y));
|
||
|
res += inp[local_pos + 29] * w + inp[local_pos + 61] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.66, coord_y));
|
||
|
res += inp[local_pos + 30] * w + inp[local_pos + 60] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.7, coord_y));
|
||
|
res += inp[local_pos + 31] * w + inp[local_pos + 59] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.74, coord_y));
|
||
|
res += inp[local_pos + 32] * w + inp[local_pos + 58] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.78, coord_y));
|
||
|
res += inp[local_pos + 33] * w + inp[local_pos + 57] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.82, coord_y));
|
||
|
res += inp[local_pos + 34] * w + inp[local_pos + 56] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.86, coord_y));
|
||
|
res += inp[local_pos + 42] * w + inp[local_pos + 48] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.9, coord_y));
|
||
|
res += inp[local_pos + 43] * w + inp[local_pos + 47] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.94, coord_y));
|
||
|
res += inp[local_pos + 44] * w + inp[local_pos + 46] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut4, vec2(0.98, coord_y));
|
||
|
res += inp[local_pos + 45] * w;
|
||
|
res = clamp(res, 0.0, 1.0);
|
||
|
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(0, 0), vec4(res[0], 0.0, 0.0, 0.0));
|
||
|
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(0, 1), vec4(res[1], 0.0, 0.0, 0.0));
|
||
|
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(1, 0), vec4(res[2], 0.0, 0.0, 0.0));
|
||
|
imageStore(out_image, ivec2(gl_GlobalInvocationID) * 2 + ivec2(1, 1), vec4(res[3], 0.0, 0.0, 0.0));
|
||
|
}
|
||
|
//!TEXTURE ravu_lite_lut4
|
||
|
//!SIZE 25 288
|
||
|
//!FORMAT rgba16hf
|
||
|
//!FILTER NEAREST
|
||
|
af006f01cc888506670b9f936914ff8ca211a28f3c0de3916590308d710a550e6b9030128491b90cff92150e408b62122982260047089086ad093a1165912b824b16f286ad873f946c0bf7992a191c133c1c061cc815a214dd99130c97116719bf842c16669441847a12eb091d872a920215d911a793a4947114be19de9a6507fe2773a142a2189ed42cd22ce9afe5af69a1fb27049e4da2ac19f014e283d99a0b123315eb94c1936f88090cc38ec981c31cf2129d1c2f10ce2ce2afc92ce1af543c543c543c543c2f027608dd832d885c8ee10fe4889f05071858932e1135983b8f5b80758dfe89aa8fa9177998c70ece88218e730f1105520c3f06d7866b8c08980495e013b4188f99d29215165519939612a078208318ac94e395b11ef21e46a043988d19bb206591c198fe18061594969198ad182017b71afb1aab9ad89ad519781fa09f6495c329a1a0a2a47ca37e2d5d2d3fb043b008a0f82920a402a5c820931b569a8aa0971c861d179d1f9d70125e143d987f94551b181da0127f147a2d3ab0542d4cb0523c543c543c523c3a0a37852b009e86d88fa8143994200d5919d08e2e0b41991712d116cb97e3959d926f19cb98860c0418f991fb01c495dd83990c0a89db8313982694971721143a9f560965156b1e6a0e21a3aa234f89699df19e3421942103a45a11141319240a9505a1b920961a3499ef986f18dd19981ad914f7973a98961bfa2136a293953c2a32a029a413a5642d692d3db03ab02e98da2ac5a67aa54b252b2229a18fa5881de81e929ee29d9a1b99174799829c611b5123d9a0f710142e4bb0752d99b0523c543c543c523ce391e184be0c970f1e12bf905f08438c088dde923d0f2209e00f230eb995b09188887b033a086691eb914d124490700fdf0a1490b20f1d8cde962106878590175f93c10b7d15c38d7e9ca79c7f1f22192aa01ea08b238f23029e499daa1a9020130c7b968e0f4e1559943198db172216111b04177c988f9a169cb11e209cc71836290da4dba587155d2f132f23b11ab106a4f029359897a679204e999c14a29ed41ae21c289c809cfe091a121899bf920c9f202465a02523f32f5bb1842f72b14e3c523c523c4e3c3e914f00dc12648afd176e10a2970591ed97ee954f185f1423187b17fb996298b18e1693dc093d11160d7f188792789748105590468e360d20938582d597a719cd9463986a1d4998b09c16929718291b6ea0a7a05e24eb22b79ea59d331d4020fe98829e0419081fbc9c769c7c1e8e1a7b12af930d199b9717a0cc1eb29c4d1f3429c7a435a56f194b2fc42e12b1f8b0ada1ca2a7b9f0ea80d24f613499abea2d520dc2282a262a11e1f261f5ba1619e77958b2571a2c81e343042b1332fa4b14c3c553c553c4c3c52829e8cfc0a8f08f8891d115b8f0702bd100793ac10178e360b2e145995a19093121b1202940d945f107010bb907591440ac907758960895417c61822990699570e291adc997a9661935899431d6695af9c109c3a21b6200ba1fa9eb01e1a224b9f4ba1f3209d2089a1b3a1dd210a2236a292a21223df2265a3169bd41c1424e02833a5f3a22f13592ef22da0b08db010945e2b54a52ca84d279a2491a45ca74827e82792a7eda79e272c27e8a78fa7a8258527e2a54da4922f7ab0ca2d57b14e3c563c563c4e3c58805614df93f680d112e8084c8d72916b0feb89ec8dbb83b4194a19159cca9bd912b715e0922997d30c0516b195c88e1413658641093f935292269aed18f315449c3e135a11a919369ae8981720d09808a6c3a5ef27c427449de19d26138b214c037c9e311cf218389b08962918861acd1a20160e985299f79bd32098986e9a122859a6d2a6ec25ca30733015b217b214a6c529e32220a81e233b9a549b379fee18831e529d429b901dab9c7e18009f7fa73f292da8d42868318eb2f030beb2483c523c523c483cbc0a1d15f98ca894520e55933e848511828f15894810db0772140811de981d93d911590e6785e095da8e86164d940c8c04191614b9961b9876996295e48c511c6f18af942319489b2c9ae41ac9031994a9a2e4a143257224dd9a3fa0571db21fff9c1e9bbc16ce1f809f81a02a21081fd1113c950318f88ef4a03f1d821bae15732562a78ea487273f306a2f85b15cb1c6a34a2ac21ddda87325331a7da131a32d22a1240ca478a34d23711dfca02da38ca4fd29e3a89326af3126b27b30f8b2443c573c573c443c7894f00ac016de91cd18ba0a5199f008939a6198e31a5018781894182f9906996a96b0990a15da19c011141a6a8fd19a9718c711cf9972913d1cba1cdea18414661b7c0a751f6aa22b20582373a4f89ecb9ea6a02d245f212112421cd1882d9b26a210a448209825aba564a52127dc244aa712a7c9281226dba618a323239827a319fda925210729252f652ef9b0c1b039a049294e9dfaa6b829fa2772a74caa782b2e2c52ac92ab152c572cddacceabe928042b22aac3a72631b1b0762eb1b2483c583c583c483c5401bc0c848d2f0bb81200142990ec958f1821904998df0de31d161e22a0739ffa165a19f88c649c520f461699987801de146a10cb8ab3955194099108153110519a0e990816421c6d9f97153421429c91a831a895296b294b993ca28a13a123b79a169d3a1d8d1a8e99eb99ea181e1be418fe94d79590102f9c48226d12bda0942765a716a86d286931e930a7b299b292a67d2a152579a9a724289cc1a0da9cd091251e0798e59a1c212da1e11e9ca156a9e52a99a95a2a0a32f3b2453146b3443c533c533c443c970e681339915390c8815803e880af842c08e794d80f5f12fc19d819589df79a14183b176595559a9a18311a949a499
|