31 lines
828 B
Plaintext
31 lines
828 B
Plaintext
|
const float PHI = 1.61803398874989484820459; // Φ = Golden Ratio
|
||
|
const float INV_PI = 0.31830988618379067153776752674503;
|
||
|
const float INV_SQRT_OF_2PI = 0.39894228040143267793994605993439;
|
||
|
const float PI = 3.141592653589793;
|
||
|
|
||
|
float seed = 0.0;
|
||
|
vec2 xy = vec2(0.0);
|
||
|
|
||
|
// based on https://www.shadertoy.com/view/ltB3zD
|
||
|
//
|
||
|
// Gold Noise ©2015 dcerisano@standard3d.com
|
||
|
// - based on the Golden Ratio
|
||
|
// - uniform normalized distribution
|
||
|
// - fastest static noise generator function (also runs at low precision)
|
||
|
// - use with indicated fractional seeding method.
|
||
|
float gold_noise(){
|
||
|
seed += 0.1;
|
||
|
return fract(tan(distance(xy * PHI, xy) * seed)*xy.x);
|
||
|
}
|
||
|
|
||
|
void init_random_state(in vec2 st, in float s)
|
||
|
{
|
||
|
xy = st;
|
||
|
seed = s * 0.01;
|
||
|
}
|
||
|
|
||
|
float luminance(in vec3 col)
|
||
|
{
|
||
|
return dot(col, vec3(0.2126, 0.7152, 0.0722));
|
||
|
}
|