#ifndef _METATEX_COLORMAP_HLSL_
#define _METATEX_COLORMAP_HLSL_

static const float3x4 Colormap_Turbo1 = float3x4
  (0.13572138,  4.61539260, -42.66032258, 132.13108234,
   0.09140261,  2.19418839,   4.84296658, -14.18503333,
   0.10667330, 12.64194608, -60.58204836, 110.36276771);

static const float3x3 Colormap_Turbo2 = float3x3
  (-152.94239396, 59.28637943, 0,
   4.27729857,  2.82956604, 0,
   -89.90310912, 27.34824973, 0);

static const float3x4 Colormap_Viridis1 = float3x4
  (0.2777273272234177, 0.1050930431085774, -0.3308618287255563, -4.634230498983486,
   0.005407344544966578, 1.404613529898575, 0.214847559468213, -5.799100973351585,
   0.3340998053353061, 1.384590162594685, 0.09509516302823659, -19.33244095627987);

static const float3x3 Colormap_Viridis2 = float3x3
  (6.228269936347081, 4.776384997670288, -5.435455855934631,
   14.17993336680509, -13.74514537774601, 4.645852612178535,
   56.69055260068105, -65.35303263337234, 26.3124352495832);

static const float3x4 Colormap_Plasma1 = float3x4
  (0.05873234392399702, 2.176514634195958, -2.689460476458034, 6.130348345893603,
   0.02333670892565664, 0.2383834171260182, -7.455851135738909, 42.3461881477227,
   0.5433401826748754, 0.7539604599784036, 3.110799939717086, -28.51885465332158);

static const float3x3 Colormap_Plasma2 = float3x3
  (-11.10743619062271, 10.02306557647065, -3.658713842777788,
   -82.66631109428045, 71.41361770095349, -22.93153465461149,
   60.13984767418263, -54.07218655560067, 18.19190778539828);

static const float3x4 Colormap_Magma1 = float3x4
  (-0.002136485053939582, 0.2516605407371642, 8.353717279216625, -27.66873308576866,
   -0.000749655052795221, 0.6775232436837668, -3.577719514958484, 14.26473078096533,
   -0.005386127855323933, 2.494026599312351, 0.3144679030132573, -13.64921318813922);

static const float3x3 Colormap_Magma2 = float3x3
  (52.17613981234068, -50.76852536473588, 18.65570506591883,
   -27.94360607168351, 29.04658282127291, -11.48977351997711,
   12.94416944238394, 4.23415299384598, -5.601961508734096);

static const float3x4 Colormap_Inferno1 = float3x4
  (0.0002189403691192265, 0.1065134194856116, 11.60249308247187, -41.70399613139459,
   0.001651004631001012, 0.5639564367884091, -3.972853965665698, 17.43639888205313,
   -0.01948089843709184, 3.932712388889277, -15.9423941062914, 44.35414519872813);

static const float3x3 Colormap_Inferno2 = float3x3
  (77.162935699427, -71.31942824499214, 25.13112622477341,
   -33.40235894210092, 32.62606426397723, -12.24266895238567,
   -81.80730925738993, 73.20951985803202, -23.07032500287172);

float3 Colormap_Calculate(in float3x4 m1, in float3x3 m2, float x)
{
    float4 v = float4(1, x, x * x, x * x * x);
    float3 rgb = mul(m1, v) + mul(m2, v.yzw * v.w);
    #ifndef UNITY_COLORSPACE_GAMMA
    rgb = GammaToLinearSpace(rgb);
    #endif
    return rgb;
}

#endif // _METATEX_COLORMAP_HLSL_
