audio-vis/shaders/sphere.vert

19 lines
469 B
GLSL
Raw Normal View History

2020-04-05 15:28:22 +02:00
#version 300 es
in vec4 a_position;
uniform mat4 u_matrix;
uniform vec3 u_lightPos;
uniform float u_pointSize;
2020-04-07 21:44:46 +02:00
out vec4 fragNormal;
2020-04-05 15:28:22 +02:00
out vec3 v_surfaceToLight;
void main() {
// convert the position from pixels to 0.0 to 1.0
vec4 pos = a_position * u_matrix;
gl_Position = pos;
gl_PointSize = u_pointSize;
2020-04-07 21:44:46 +02:00
fragNormal = normalize(pos);
vec3 surfaceWorldPosition = (u_matrix * pos).xyz;
2020-04-05 15:28:22 +02:00
v_surfaceToLight = u_lightPos - surfaceWorldPosition;
}