float3 catmullRom(float3 r, float3 g, float3 b, float3 a, float x, float t0) {
float t1 = t0 + 1.0 / 3.0;
float t2 = t1 + 1.0 / 3.0;
float t3 = t2 + 1.0 / 3.0;
float t = x;
float3 D0 = r;
float3 D1 = g;
float3 D2 = b;
float3 D3 = a;
float3 C1 = (t1-t)/(t1-t0)*D0 + (t-t0)/(t1-t0)*D1;
float3 C2 = (t2-t)/(t2-t1)*D1 + (t-t1)/(t2-t1)*D2;
float3 C3 = (t3-t)/(t3-t2)*D2 + (t-t2)/(t3-t2)*D3;
float3 B1 = (t2-t)/(t2-t0)*C1 + (t-t0)/(t2-t0)*C2;
float3 B2 = (t3-t)/(t3-t1)*C2 + (t-t1)/(t3-t1)*C3;
float3 A = (t2-t)/(t2-t1)*B1 + (t-t1)/(t2-t1)*B2;
return A;
}
float3 gradientCatmullRom(float3 r, float3 g, float3 b, float x) {
return select(select(catmullRom(b, r, g, b, x, -1.0 / 3.0),
catmullRom(r, g, b, r, x, 0),
x > 1.0 / 3.0),
catmullRom(g, b, r, g, x, 1.0 / 3.0),
x > 2.0 / 3.0);
}
Post #170
112

Сверху катмулл-ром, снизу - линейная интерполяция
- ❤ 1