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-r4.hook

233 lines
234 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, 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
cdd62e37a650b737dd8719b950a8d038d9d96c39bbdc73bafb218d3ad9d79fb95340343ae847f4b99d82a739465c3cbaa8950cbae80da6b9031f4e393097ca39a6660dba43f5453ae07d30bad92c9739ede35fba28a8c2393f0a68b934474c3a05420ab82f19183630e50839a60dd2b8b6ac35394a30273a9ba72cba84c30ab80a59c93a684edeb86f99f5b8b5d887ba3a7f6d397fd63ebba945253b628d633a4d86873b7abe803b80fab83ae447943ae2a33bbbb06a823963e2323a6ce62c3b94e797b80077c53a5cb68cbad42f88b8af334f3a2d613d398aabe3b8e83745ba3344a03a331b3b3a88de74ba3a8a94bacb1d8e3a17c9373baab65bbbdfaaec3890ccff3c64552ebc183348bca30cc3bb2b819a3d84459a3db42dfdbdd1a0fcbdd6172dbcce6cff3c0379c0bb81ae49bc9d8c353bfbfd9d3a0a7178b848105bbbee67413a6265a63a55629dbaaf1778ba3ae50db993168139f162d8b97eb5e4b72e56983be64a5e3ab7aa933bbfe6053addc9993d2f3ffcbdd31b993d072afcbd397e8a3fbc8a8a3fbc8a8a3f397e8a3f6fdc0b3812cb0e39ad3277b8cd9905b96880cbb9642dfc39e4701cb9d3eeb33851d9003bd1096bba8ac8253a10a206bb296de7b99462b5b60aaeaeb9fcb63fb9883df5b9ab10f53a65160fbb9aead83962bb19b9092cc4b93155ee391e29a2384a388a3960eec7380eeedab818528db936fd00bb618ca0baccf97b3a2273163b9ce631bba6435aba809fc23a51ad2a3b025ed2baf54802bc45f70e3ca569103b988f95bac660bcba6f21d63b4a45de3b59c408bcd55108bbd698313b0763173cecab2cbae12e18bba8ba1f3b27b0a03a6681d2bae31b12bb9aaf153bbcfde33a9eee563b34525f3b3a5c55bb0ef95abb81983a3b5c09ef3be90ff4bb3185acba2c67383d932414bc3e4b94bcc2796fbc11cfaf3d92aeab3d43ec07be765808bec7fe00bcd9fa3e3d410484bc5235a0bc5bfa183cb66c723b18b54abb6e3011bcc4df923bdcb9b03b09dca2bbb3dca3bb47064e3a2ec78b3a609c07bb57e38fbaa8916a3b7c0ca33b7ef2533a4dde8f3ac546af3d1d4607bedf76aa3dd98d09bef64c8a3f3e7e8a3f3e7e8a3ff64c8a3f994c47394bd9a6b864912a3633c7d3b8d606fbb900f2943ab01d87ba0e08a439cb2b2b3bf0f1d9b916c265398e2b28bbf1e6423a671eda3a4765f9ba725bbcba8ca253bac1d92d3b6b5a19bbd4bb90398488003b9a123fba1785fd371b75b8ba923477b8eb269339fe4c21b9d6da76b8b16902bbd1b084ba9ed2f23a292a843a2e4ae7bb87c72a39f6a6ac3a955bcd3b8440cd398f2f64bc8235753c07df29b92c11adbb121cdebb4e85263c1878323ce16880bce93b2b3a138f623a3d23833ca93da1ba2a9020bc9513173c8bcd523bd98c26bbb2ee1dbb67e90d3b1ea43b3b8709533be7199b3afddcfeba9c4f07bb63c3723ba4303f3cbcb846bcb669b2ba9381473d6f3806bc241785bc1767a2bcd689ac3dbb2cad3db19f07be614707be0fb205bb4a445b3dae94d8bc8d33afbcfc5ca93c2b6a453c721625bce8e2b1bc230ab13beaf8dc3bf14dd2bb344dbcbb7c31733bdc16f33af8db28bb7d4a90bb5c106c3b791e6a3cee2b1bbc05db1e3ace83c23d966309be6ca8ae3d962b13be45318a3f97848a3f97848a3f45318a3fc5593cbaf82a9cb86fc2973916d7f239fdcf433a23e317ba68d30b39db6088b9d1f8a0b936b85bbaf5aae739ec4724397203fc394c6ec439c514b7baaefd35baf30111b963ad5e384536073990b92cba6e663dbaa894493a438d08baf501ee3920df5b39907902ba4446f639049e83b959b5dbbadc22c438dceab0b813f2f13a68e76bba97207839ebafaf3a375bb8b91dba8fbb9ad294bbfde5ef3b034e243bbb3e05bca9be03bcb157713cbcd5713c0b44c0bb1a18a9bbd940553b6ef2113cea6982391b57cfbabcb6f139eccaa93af5138bba522d06bba45afb3a9f3bc43a5921623b568ee03a5d750fbb41e551bb2dbd82bb2b1ad63b39ff83bb43dc183b0dbe263d01aa81bc176cbbbc37d7b03ae992eb3d1e5ae23d966224be264f23beb1ce80bcc60b3e3d159e06bbb7ecd2bcd3220f3cd0ce29bbbd85933a424ed4bbfc7a5a3bbc379c3b680085bbf40b90bb7abb3f39e835433a480423bbfcda57ba5371e1bbc4f4833cc6940cbc1caa643c4367fe3d4d532bbee08ef03dc2472ebe41c0893f144e8a3f144e8a3f41c0893f0fbc27baccaf9e3699825b3ac8724cb92eadff3ac7c50d3a274bf4baada420ba5a9cfdbaafcfbdbab6ed093b46e18b3a7168043b616eef3a376c3fbbce4d0cbbd81fd6b9a7ce62ba1e723b391caa273ac3cea2395fd10f3ba8da50baa70eefbac80d093a9baf0aba30c7c8b9c2c1a63984fe63ba9e2821b8c9a9faba23dc343bf39299ba76560cbb234bad3b121709bb880d96bbd1ce42babfd2123bdf17653b90be0dbc42e514bc21b38b3c906b5d3cf5dcd6bb989eb4bbf261a63b4af3073c40b01fbb4343d0bb1377203b6bf4e03b468097bb2ab88ebbcf77cf3b53b5513b9f5d4f3ab9de75ba8196213b1d51f3bad1ea02bc1780d93b324496bb8dafe93b538c263d89dc98bcbca5a6bc46e42d3b7c56e93d887fd83d104a22be270d1fbed3a635bc444c593d2e5defbb30b801bdf49f813ca4cb7e3a642e49bb5fc257bc039b1a3cb7725b3c834f50bcff382cbc03b2e33b3cc9e43b905a2bbcbd25ccbb62deaeba8166b13c70124ebcd9fdd83ba089063e824f28be7c55e63d0d7934be7372893f659f8a3f659f8a3f7372893fb48a14b8f6bc93b9ac8b5f3908e6113909083fb9aa93233a645aebb9d8dc01389c95173a90dc60ba8772153ac2d3c2b