Skip to content

Instantly share code, notes, and snippets.

@mikhailov-work
Last active February 19, 2024 22:18
Show Gist options
  • Save mikhailov-work/0d177465a8151eb6ede1768d51d476c7 to your computer and use it in GitHub Desktop.
Save mikhailov-work/0d177465a8151eb6ede1768d51d476c7 to your computer and use it in GitHub Desktop.

Revisions

  1. mikhailov-work revised this gist Aug 21, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions turbo_colormap.glsl
    Original file line number Diff line number Diff line change
    @@ -9,12 +9,12 @@
    // GLSL Approximation: Ruofei Du (ruofei@google.com)

    vec3 TurboColormap(in float x) {
    const vec4 kRedVec4 = vec4(-0.05195877, 5.18000081, -30.94853351, 81.96403246);
    const vec4 kGreenVec4 = vec4(0.16207513, 0.17712472, 15.24091500, -36.50657960);
    const vec4 kBlueVec4 = vec4(0.55305649, 3.00913185, -5.46192616, -11.11819092);
    const vec2 kRedVec2 = vec2(-86.53476570, 30.23299484);
    const vec2 kGreenVec2 = vec2(25.95549545, -5.02738237);
    const vec2 kBlueVec2 = vec2(27.81927491, -14.87899417);
    const vec4 kRedVec4 = vec4(0.13572138, 4.61539260, -42.66032258, 132.13108234);
    const vec4 kGreenVec4 = vec4(0.09140261, 2.19418839, 4.84296658, -14.18503333);
    const vec4 kBlueVec4 = vec4(0.10667330, 12.64194608, -60.58204836, 110.36276771);
    const vec2 kRedVec2 = vec2(-152.94239396, 59.28637943);
    const vec2 kGreenVec2 = vec2(4.27729857, 2.82956604);
    const vec2 kBlueVec2 = vec2(-89.90310912, 27.34824973);

    x = saturate(x);
    vec4 v4 = vec4( 1.0, x, x * x, x * x * x);
  2. mikhailov-work created this gist Aug 9, 2019.
    27 changes: 27 additions & 0 deletions turbo_colormap.glsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // Copyright 2019 Google LLC.
    // SPDX-License-Identifier: Apache-2.0

    // Polynomial approximation in GLSL for the Turbo colormap
    // Original LUT: https://gist.github.com/mikhailov-work/ee72ba4191942acecc03fe6da94fc73f

    // Authors:
    // Colormap Design: Anton Mikhailov (mikhailov@google.com)
    // GLSL Approximation: Ruofei Du (ruofei@google.com)

    vec3 TurboColormap(in float x) {
    const vec4 kRedVec4 = vec4(-0.05195877, 5.18000081, -30.94853351, 81.96403246);
    const vec4 kGreenVec4 = vec4(0.16207513, 0.17712472, 15.24091500, -36.50657960);
    const vec4 kBlueVec4 = vec4(0.55305649, 3.00913185, -5.46192616, -11.11819092);
    const vec2 kRedVec2 = vec2(-86.53476570, 30.23299484);
    const vec2 kGreenVec2 = vec2(25.95549545, -5.02738237);
    const vec2 kBlueVec2 = vec2(27.81927491, -14.87899417);

    x = saturate(x);
    vec4 v4 = vec4( 1.0, x, x * x, x * x * x);
    vec2 v2 = v4.zw * v4.z;
    return vec3(
    dot(v4, kRedVec4) + dot(v2, kRedVec2),
    dot(v4, kGreenVec4) + dot(v2, kGreenVec2),
    dot(v4, kBlueVec4) + dot(v2, kBlueVec2)
    );
    }