Files
armorpaint/Shaders/std/math.glsl
T

25 lines
535 B
GLSL
Raw Normal View History

2019-05-25 20:15:08 +02:00
#ifndef _MATH_GLSL_
#define _MATH_GLSL_
2019-08-21 11:54:38 +02:00
const float PI = 3.1415926535;
const float PI2 = PI * 2.0;
2020-05-20 13:18:22 +02:00
vec2 envMapEquirect(const vec3 normal, const float angle) {
2019-05-25 20:15:08 +02:00
const float PI = 3.1415926535;
const float PI2 = PI * 2.0;
float phi = acos(normal.z);
2020-05-20 13:18:22 +02:00
float theta = atan(-normal.y, normal.x) + PI + angle;
2019-05-25 20:15:08 +02:00
return vec2(theta / PI2, phi / PI);
}
float rand(const vec2 co) { // Unreliable
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
float attenuate(const float dist) {
return 1.0 / (dist * dist);
}
#endif