This repository has been archived on 2021-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/home/.config/mpv/shaders/ravu-lite-r2.hook

105 lines
49 KiB
Plaintext
Raw Normal View History

2020-02-16 13:03:20 +01: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-Lite (step1, r2)
//!HOOK LUMA
//!BIND HOOKED
//!BIND ravu_lite_lut2
//!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(-1.0, -1.0)).x;
float luma1 = HOOKED_texOff(vec2(-1.0, 0.0)).x;
float luma2 = HOOKED_texOff(vec2(-1.0, 1.0)).x;
float luma3 = HOOKED_texOff(vec2(0.0, -1.0)).x;
float luma4 = HOOKED_texOff(vec2(0.0, 0.0)).x;
float luma5 = HOOKED_texOff(vec2(0.0, 1.0)).x;
float luma6 = HOOKED_texOff(vec2(1.0, -1.0)).x;
float luma7 = HOOKED_texOff(vec2(1.0, 0.0)).x;
float luma8 = HOOKED_texOff(vec2(1.0, 1.0)).x;
vec3 abd = vec3(0.0);
float gx, gy;
gx = (luma3-luma0);
gy = (luma1-luma0);
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
gx = (luma4-luma1);
gy = (luma2-luma0)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
gx = (luma5-luma2);
gy = (luma2-luma1);
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
gx = (luma6-luma0)/2.0;
gy = (luma4-luma3);
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
gx = (luma7-luma1)/2.0;
gy = (luma5-luma3)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.13080118386382833;
gx = (luma8-luma2)/2.0;
gy = (luma5-luma4);
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
gx = (luma6-luma3);
gy = (luma7-luma6);
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.1018680644198163;
gx = (luma7-luma4);
gy = (luma8-luma6)/2.0;
abd += vec3(gx * gx, gx * gy, gy * gy) * 0.11543163961422666;
gx = (luma8-luma5);
gy = (luma8-luma7);
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 += luma0 * w + luma8 * w.wzyx;
w = texture(ravu_lite_lut2, vec2(0.3, coord_y));
res += luma1 * w + luma7 * w.wzyx;
w = texture(ravu_lite_lut2, vec2(0.5, coord_y));
res += luma2 * w + luma6 * w.wzyx;
w = texture(ravu_lite_lut2, vec2(0.7, coord_y));
res += luma3 * w + luma5 * w.wzyx;
w = texture(ravu_lite_lut2, vec2(0.9, coord_y));
res += luma4 * w;
res = clamp(res, 0.0, 1.0);
return res;
}
//!DESC RAVU-Lite (step2, r2)
//!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_lut2
//!SIZE 5 288
//!FORMAT rgba16f
//!FILTER NEAREST
a7ca113dc4d036bce1a84abc5bea31bbd9a7a13d5919a13dfe79febd3b27febd413532bcfac2123d7d6836bb8f0153bcea82a53d68fc00be04efa43da85201be296f8a3fb56e8a3fb56e8a3f296f8a3fd1f5eb3c034d0cbcc3ae80bc1b27b93b62d5b23de39bb43dda1608bee95607bec937f8bb69aff43cb8e19d3b4ba98bbc1e4ac43db7f50dbe5d40be3d62760fbe8e258a3f803e8a3f803e8a3f8e258a3f37a6c63cb645e0bb44ec7dbc68fd283c06a7b53d411fba3d7f680abe19ca07be6104b73a6a56003da4264e3bedb3c8bc5a2ce93df64d11be0d58c83db04d21be3bbe893fa8c1893fa8c1893f3bbe893f5bc10a3d2d513dbc606aa6bc834b2a3c1dfcc93d18fbc53d5f9b11be400312be1a7834bc1de0143d7606113c3447b5bc8207de3daa0c19bee054d43d58921bbeb2c5893f23fb893f23fb893fb2c5893f1185d73c60cc1fbc3386a8bc091f903c5adccd3dd874c73dbc3313be44c111be7fa92fbbb3cb143dcd97133ce37ef5bce225fc3dc9cc1dbe53b5dc3de6f429beaf65893f73f1893f73f1893faf65893f4d9e973c425f85bcfba620bc11f0c73cb4c2c43d703bbc3d733c0ebe31600cbe361ccc3b86f3393d265edebae9f212bd0882093ef2a609be20f3ae3dae5837bed847893f10088a3f10088a3fd847893f39cb113df3dbe6bba64a05bde2d7813c364ae93dca05df3d87701ebe26211cbed29264bbe284353de61d2f3c5bf524bd92c3143ec15f34bea5ae063e46663cbe5ae6883f059a893f059a893f5ae6883f49e7bb3cfb8d0bbb13f3e7bcee84a83cebcbd43da3fec23ddc5814bef0eb0fbe687a7a3cee154b3d7e6873ba734957bdde60253e07b928be75d1f23dc7904abec389883f08ef893f08ef893fc389883fe53a88bb3492f0bc0436ab3b48f53b3d11a5b43d9623a13d56ab06be80b3febda9e6333dac979f3d113b05bdecff9ebde41e463ebed1d6bd8103603d6bf96cbea974883f8a758a3f8a758a3fa974883f67590a3d58003f3bc4153bbd1414ac3c46e9013e0487ec3d85c32bbeacef24be53e98f3cc7786e3dd8bc873b564d8ebd210b393e57cc41beecd50f3e99305bbe3741883fbd6a8a3fbd6a8a3f3741883fc24a673c84fb293c019bdabc0e71833c0256e83d76eebd3d0afc20be1bf40ebea8cd513de403903de42cebbc30aba9bdc1104a3e3d8f0cbec85fad3d240365be10e4863fccb98b3fccb98b3f10e4863fe6d792bd8d43a7bd7797953d5791d23d4df4b33da1d7603dbe960abec5d9d2bd09be063e625a2a3ecb72f9bdf6bb32be45e7ab3ee0a0e23cb9dab7bd994fb3be074b853f80998d3f80998d3f074b853f723d0e3d683b29bced1c4bbc63960dbb728c9f3d8746a13d5748febd852efdbd338115bcc758123d528a68bb74645cbc6361ae3d9b4403be138aab3dc7ac06be5b828a3f2b4a8a3f2b4a8a3f5b828a3fc322fa3c51b004bcf18384bc1ac48d3b5e3ca63dbaa2ad3de3bd05beac5a00be49f889bbdf1a103d0376e93aaccfb8bc3920d63d44a30bbe1a24b53d715a16bebe078a3ff05f8a3ff05f8a3fbe078a3fbe503f3c240eb2bcb487deba391dcd3c4374983d74eda33dff9dfebd435bf4bdb042f93cc334723d81cad4bc202158bd14c3153e5043fabdbe9b9d3d775b42be6d7a893fc7368a3fc7368a3f6d7a893f85a7003d3ed953bcb76a8dbcaba53e3cb497cc3dabacc33d241013be3ec910be4ac138bcb6e5243d5cdeed3b457cc8bcd1abe73ddc3418beed24cd3d4d5a1dbec290893fed238a3fed238a3fc290893f137a8d3c02c876bc095f4ebc648acc3c3dcad33d4b82c23da7f514be135f10be50b10a3be33b3a3dab493b3bc2451ebdf1a80c3e13c114be9396c03d806e33bea5ec883fd35f8a3fd35f8a3fa5ec883f47b562ba2f7cfbbc401dd63b008a323d7d8cd73d11bebc3da75714be3c240fbe1409843c8f65743d7e2452bc9aa04ebd1c90223eb813f2bd73df863da33d4dbe59ae883ff68a8a3ff68a8a3f59ae883f8e59d83cf5bf1dbccc1fcdbc87f5ab3c4598f73dbf2ed63d555422beb10f1bbe31fd46bb93ff543d4c72f43b18e73abdc466203eb91330bed4b2f53d11bc40be891b883f77618a3f77618a3f891b883f4ef3013ade507bbc0ee006bc7a001b3d2868ea3d1b6db33d21131abed8540cbef550cb3c7bd78f3dca5d6ebc9e5790bd9a47483e334813be43bead3d988d60bec3dc863f8e7a8b3f8e7a8b3fc3dc863fc14f20bdf86f52bd9982173d7aec983dd6a2db3d402b963dec7c13be0af4febdae136a3d0256d23d987a4bbd5ea0cdbdadf9793e5a7b92bd4c4df53bfbb889be7f61863fd54a8c3fd54a8c3f7f61863ff0c5293c2d1fefbb7594c5bc5bce103d9c70103e37cfd73d592c35becfe31fbea117e73c9e93a03d60d3f3bb5a68b7bdbe105c3e98a72cbe56c4d23d4b9d6dbe1716863f61848c3f61848c3f1716863f2689f0bcac974dbcef00763c8401383d5505ff3dba1c5b3d307624bec8c8ddbdc5b39d3dc467f33d4a2b77bdf08302be5a9d943e21e9a2bd0f2704bcdbb590be5367813fb519913fb519913f5367813f9775dfbd227889bd0535dd3d87a7c93d553be93d76f4ecbbcccb1ebeb5aa59bdb677e73dad162e3e2e46debda59d2dbebaaee13e4b85853d7d393cbef562cfbe268c783f02cb963f02cb963f268c783f74be0c3dfeb033bcfbba2ebc72b236bb938d9e3d89e9a23dc71101be990cfabd7a7e26bc4419133d112200bb34fe6abcb374ad3dccb003bef007a63db41c03be9d5c8a3f53758a3f53758a3f9d5c8a3fb657ed3c7adf44bc633a35bc72a7a73bfd1f9e3d1024ac3d126a05bed883f6bd018c9839a7292c3dafe691bb9e0ceeb