Created
February 21, 2021 18:35
-
-
Save morisil/b5a6c83bfb7f7406bb43904258f26cec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// spectral_zucconi6 by Alan Zucconi rewritten from GLSL to JS by Kazik Pogoda | |
// GLSL: https://www.shadertoy.com/view/ls2Bz1 | |
const ONE_IN_3D = [1, 1, 1]; | |
const c1 = [3.54585104, 2.93225262, 2.41593945]; | |
const x1 = [0.69549072, 0.49228336, 0.27699880]; | |
const y1 = [0.02312639, 0.15225084, 0.52607955]; | |
const c2 = [3.90307140, 3.21182957, 3.96587128]; | |
const x2 = [0.11748627, 0.86755042, 0.66077860]; | |
const y2 = [0.84897130, 0.88445281, 0.73949448]; | |
const saturate = (x) => Math.min(Math.max(x, 0), 1); | |
const to3d = (x) => [x, x, x]; | |
const add3d = (x, y) => [x[0] + y[0], x[1] + y[1], x[2] + y[2]]; | |
const subtract3d = (x, y) => [x[0] - y[0], x[1] - y[1], x[2] - y[2]]; | |
const multiply3d = (x, y) => [x[0] * y[0], x[1] * y[1], x[2] * y[2]]; | |
const pow23d = (x) => multiply3d(x, x); | |
const saturate3d = (x) => [saturate(x[0]), saturate(x[1]), saturate(x[2])]; | |
const bump3y = (x, yoffset) => saturate3d(subtract3d(subtract3d(ONE_IN_3D, pow23d(x)), yoffset)); | |
const spectral_zucconi6 = (x) => add3d(bump3y(multiply3d(c1, subtract3d(to3d(x), x1)), y1), bump3y(multiply3d(c2, subtract3d(to3d(x), x2)), y2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment