96 lines
27 KiB
Text
96 lines
27 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 (r2, compute)
|
||
|
//!HOOK LUMA
|
||
|
//!BIND HOOKED
|
||
|
//!BIND ravu_lite_lut2
|
||
|
//!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[340];
|
||
|
void hook() {
|
||
|
ivec2 group_base = ivec2(gl_WorkGroupID) * ivec2(gl_WorkGroupSize);
|
||
|
int local_pos = int(gl_LocalInvocationID.x) * 10 + int(gl_LocalInvocationID.y);
|
||
|
for (int id = int(gl_LocalInvocationIndex); id < 340; id += int(gl_WorkGroupSize.x * gl_WorkGroupSize.y)) {
|
||
|
int x = id / 10, y = id % 10;
|
||
|
inp[id] = HOOKED_tex(HOOKED_pt * vec2(float(group_base.x+x)+(-0.5), float(group_base.y+y)+(-0.5))).x;
|
||
|
}
|
||
|
groupMemoryBarrier();
|
||
|
barrier();
|
||
|
vec3 abd = vec3(0.0);
|
||
|
float gx, gy;
|
||
|
gx = (inp[local_pos + 10]-inp[local_pos + 0]);
|
||
|
gy = (inp[local_pos + 1]-inp[local_pos + 0]);
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
|
||
|
gx = (inp[local_pos + 11]-inp[local_pos + 1]);
|
||
|
gy = (inp[local_pos + 2]-inp[local_pos + 0])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
|
||
|
gx = (inp[local_pos + 12]-inp[local_pos + 2]);
|
||
|
gy = (inp[local_pos + 2]-inp[local_pos + 1]);
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
|
||
|
gx = (inp[local_pos + 20]-inp[local_pos + 0])/2.0;
|
||
|
gy = (inp[local_pos + 11]-inp[local_pos + 10]);
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
|
||
|
gx = (inp[local_pos + 21]-inp[local_pos + 1])/2.0;
|
||
|
gy = (inp[local_pos + 12]-inp[local_pos + 10])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.13080118386382833;
|
||
|
gx = (inp[local_pos + 22]-inp[local_pos + 2])/2.0;
|
||
|
gy = (inp[local_pos + 12]-inp[local_pos + 11]);
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
|
||
|
gx = (inp[local_pos + 20]-inp[local_pos + 10]);
|
||
|
gy = (inp[local_pos + 21]-inp[local_pos + 20]);
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
|
||
|
gx = (inp[local_pos + 21]-inp[local_pos + 11]);
|
||
|
gy = (inp[local_pos + 22]-inp[local_pos + 20])/2.0;
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
|
||
|
gx = (inp[local_pos + 22]-inp[local_pos + 12]);
|
||
|
gy = (inp[local_pos + 22]-inp[local_pos + 21]);
|
||
|
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
|
||
|
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_lut2, vec2(0.1, coord_y));
|
||
|
res += inp[local_pos + 0] * w + inp[local_pos + 22] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut2, vec2(0.3, coord_y));
|
||
|
res += inp[local_pos + 1] * w + inp[local_pos + 21] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut2, vec2(0.5, coord_y));
|
||
|
res += inp[local_pos + 2] * w + inp[local_pos + 20] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut2, vec2(0.7, coord_y));
|
||
|
res += inp[local_pos + 10] * w + inp[local_pos + 12] * w.wzyx;
|
||
|
w = texture(ravu_lite_lut2, vec2(0.9, coord_y));
|
||
|
res += inp[local_pos + 11] * 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_lut2
|
||
|
//!SIZE 5 288
|
||
|
//!FORMAT rgba16hf
|
||
|
//!FILTER NEAREST
|
||
|
8e28b7a155a28f990d2d092df4aff1af92a19628b39998a22c2d08b0272d0bb0533c533c533c533c602762a005a4c91d972da52d41b03bb0c29fa527ef1c5da4222e70b0f22d7cb0513c523c523c513c3526029fefa34821ad2dd12d53b03eb0b8150328711a46a6492f8ab0432e0ab14e3c4e3c4e3c4e3c5628eba133a55221502e302e8db090b0a4a1a7288820aaa5f02ec8b0a32eddb04e3c503c503c4e3cbc26fea044a581246f2e3c2e9ab08eb07d99a6289d20aca7e12feeb0e62e50b14b3c503c503c4b3cbd242ba405a14026262ee22d72b063b0611ed029f39698a84c304db0782dbbb14a3c503c503c4a3c8e28379f2aa80f244a2ff82ef4b0e1b0259bac29792128a9a630a3b13530e3b1473c4d3c4d3c473cdf255c9840a74425a62e182ea3b07fb0d423592a9b93baaa2b3146b1972f55b2443c4f3c4f3c443c429c85a75a1de029a52d092d35b0f6af9f29fd2c2aa8f8ac3132b7ae002b68b3443c543c543c443c5328f819d9a961250f30642f5eb127b17f24742b3e1c72acc8310eb27f30dab2423c533c533c423c3a235021d5a61c24432fef2d08b178b08e2a802c59a74dad513264b06b2d28b3373c5e3c5e3c373c97ac3aadad2c952ea02d072b55b097ae36305331ccaf96b15f351527bfad9ab52a3c6d3c6d3c2a3c72284aa159a26d98fc2c0a2df2afe9afaca09328449be3a2732d1ab05c2d35b0543c523c523c543cd12726a024a46e1c322d6d2d2eb003b0509c81284c17c6a5b12e5db0a92db3b0503c533c533c503cfb2190a5f4966926c42c1f2df5afa3afca27922ba6a6c1aaae30d2afed2c13b24c3c523c523c4c3c05289fa26ba4f521652e1d2e99b086b0c6a127296f1f44a63d2fc2b0692eebb04d3c513c513c4d3c6c24b6a373a264269e2e142ea8b083b05618d229da19f2a86530a6b0052e9bb1473c533c533c473c1693dca7b11e9429bc2ee62da3b079b02024a32b91a275aa153191af372c6ab2453c543c543c453cc326eea069a66025bd2fb12e13b1d8b0389aa82aa41fd7a9033181b1ae2f06b2413c533c533c413c1010dba337a0d828532f9b2dd1b063b05b267f2c73a383ac42329ab06e2d04b3373c5c3c5c3c373c02a993aabc28c72cdd2eb12c9cb0f8af512b932e5caa6daed03394acaa1f4eb4333c623c623c333c4e21799f2da686288430be2ea9b1ffb03927052d9f9fbbade13265b1962e6db3313c643c643c313c84a76da2b023c029f82fd92a24b1eeaeee2c9b2fb9ab14b0a53417ad21a086b40b3c893c893c0b3cfcae4cacea2e4d2e4a2f689ff6b0cdaa3c2f7131f2ae6db10d372c2ce2b17bb6c43bb63cb63cc43b66289ea176a1b699f42c172d09b0d0af34a19928019858a36c2d1eb0302d19b0533c543c543c533c6b2727a2aaa13d1df12c612d2bb0b4afc40c61298f9c70a7e82e76b0c22dc0b0503c533c533c503c702189a6c91c3826c52d782d86b0e3af2821d22b04a57da9bc3033b05e2d0fb24a3c553c553c4a3c92271aa391a34622862e0a2ea1b084b021a26a29a81e7da6542fafb0242ee6b04b3c533c533c4b3c4c2175a40b9f7727032fed2dbfb086b0e3148b2a000454a9a33093b0982db2b1433c563c563c433c19a00fa8ab212d2a4f2fce2dc7b08db03b22152ccea2a1aa6c31aeafd72b85b23f3c5a3c5a3c3f3c0f2579a2d4a474261e30922e3ab1e1b0269e2e2b7b202eaa3c3167b10c2f09b23b3c583c583c3b3cb7a2a0a40016da291330352d03b15bb0a025072dd4a3e3acc43285b0772c21b32b3c663c663c2b3cc8a9a9a9d828b32c01306b2ce7b008b05929722e19a90aaefb337dada51e25b4243c6f3c6f3c243c6897cba141a373291331392e02b2f1b0a824522db91601ae593364b1862d60b3203c743c743c203c60aa5aa1db27572a9d30d92682b19fadbf2b1430f2a950b0443505ae83a87fb4c33bb13cb13cc33b49ae9da4c62d402b4a2f28ace2b0c01ebe2c483182ac3eb13137159e91b1b6b5593bec3cec3c593b832848a1d2a17f9b092d0c2d0bb0d4afc4a170282990ffa2522d16b02c2d11b0533c543c543c533c3527c1a2b5a04a1d402d892d50b0e1af549a162924893aa7db2e6eb0a32dadb0503c533c533c503cac22e5a57798a826092e532d9db0c7afb29d172c299b21aa063173b0452d0cb24b3c553c553c4b3c5e2769a3b8a23922a92efb2dabb084b01fa36729262076a64d2fa8b0f42dd2b04a3c543c543c4a3c0d1f3aa4039dab27732fcd2dcbb09bb0de9ae52aec8c35a9b0309fb0652d95b1403c593c593c403c8ea2cfa60621492a0330ba2de7b0b7b0c31c022ccca03aaa74311bb0152c52b23a3c5e3c5e3c3a3cd92300a3c6a304276830722e60b1f3b05aa2a42b6b2116aa58316db1a42eebb1353c5e3c5e3c353c98a517a4e11e182a9230e32c36b16fb0b622672d82a2f0ace832bfb0172cdab2213c6f3c6f3c213c0faa51a84e285f2c9030672c30b132b05f263b2e94a77badbc3320af182598b3193c783c783c193ca7a07fa233a1182abf31c72d56b206b13394662d7a24ecad9b338fb1dd2c20b3123c823c823c123c36ac36980b294f2a3331b622ccb120ada92814303fa64eb0843518b0c6a82fb4983bc53cc53c983bc3aded15b72c58296b2e2dacb2b07626932b1531a9aa3fb12737b1ac83b020b5353bfa3cfa3c353b922857a1a1a17b9c152d222d17b0ddafd6a27a287514eea2402d19b01d2dfbaf543c533c533c543c8127b8a28aa0c31a402d5b2d50b0b0afcca159291b1cdfa6f52e81b0a22da1b0513c523c523c513c5720f2a5bf197c26c02ea92debb012b0b6a6962c27a039a8ed309db05f2dccb14c3c543c543c4c3c432719a352a2c72
|