2017-10-04 18:40:15 +02:00
|
|
|
//! type library
|
|
|
|
|
2017-10-04 19:06:50 +02:00
|
|
|
|
|
|
|
const float PI = 3.14159265;
|
|
|
|
|
|
|
|
|
2017-10-04 18:40:15 +02:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2017-10-04 19:06:50 +02:00
|
|
|
float M_Hash(
|
|
|
|
in vec2 p )
|
2017-10-04 18:40:15 +02:00
|
|
|
{
|
|
|
|
p = fract(p * vec2(5.3987, 5.4421));
|
|
|
|
p += dot(p.yx, p.xy + vec2(21.5351, 14.3137));
|
|
|
|
return fract(p.x * p.y * 95.4307);
|
|
|
|
}
|
|
|
|
|
2017-10-04 19:06:50 +02:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
float M_Luminosity(
|
|
|
|
in vec3 color )
|
|
|
|
{
|
|
|
|
return dot( color , vec3( .3 , .6 , .1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 M_NormalizeColor(
|
|
|
|
in vec3 color )
|
|
|
|
{
|
|
|
|
const float l = M_Luminosity( color );
|
|
|
|
return l > 0 ? ( color / l ) : vec3( 1 );
|
|
|
|
}
|