40 lines
761 B
GLSL
40 lines
761 B
GLSL
float length_(vec2 v)
|
|
{
|
|
float n = dot(v, v);
|
|
n = 1.0 / sqrt(n);
|
|
n = 1.0 / n;
|
|
return n;
|
|
}
|
|
|
|
float pow_(float x, float n)
|
|
{
|
|
x = log2(x);
|
|
x = x * n;
|
|
x = exp2(x);
|
|
return x;
|
|
}
|
|
|
|
float sin_(float x)
|
|
{
|
|
x = x * 0.159154936671257019043 + 0.5; // 48
|
|
x = fract(x); // nop
|
|
x = sin((x - 0.5) * 6.28318548202514648438); // presubtract
|
|
return x;
|
|
}
|
|
|
|
float cos_(float x)
|
|
{
|
|
x = x * 0.159154936671257019043 + 0.5; // 48
|
|
x = fract(x); // nop
|
|
x = cos((x - 0.5) * 6.28318548202514648438); // presubtract
|
|
return x;
|
|
}
|
|
|
|
vec3 palette(float d) {
|
|
vec3 v = d + vec3(0.25, 0.40625, 0.5625); // 40 45 49
|
|
v = v * 6.28318548202514648438; // (2 * pi * (1 / (2 * pi))) == 1
|
|
v = cos_(v);
|
|
v = vec3(0.5, 0.5, 0.5) * v + vec3(0.5, 0.5, 0.5); // 48
|
|
return v;
|
|
}
|