2015-01-29 09:28:14 +08:00
|
|
|
attribute vec4 a_position;
|
|
|
|
attribute vec3 a_normal;
|
|
|
|
|
|
|
|
varying vec3 v_reflect;
|
2019-02-15 14:30:10 +08:00
|
|
|
//uniforms
|
|
|
|
uniform mat4 u_MVPMatrix;
|
|
|
|
uniform mat4 u_MVMatrix;
|
|
|
|
uniform mat3 u_NormalMatrix;
|
2015-01-29 09:28:14 +08:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2019-02-15 14:30:10 +08:00
|
|
|
gl_Position = u_MVPMatrix * a_position;
|
2015-01-29 09:28:14 +08:00
|
|
|
|
|
|
|
// compute reflect
|
2019-02-15 14:30:10 +08:00
|
|
|
vec4 positionWorldViewSpace = u_MVMatrix * a_position;
|
2015-04-14 14:20:31 +08:00
|
|
|
vec3 vEyeVertex = normalize(positionWorldViewSpace.xyz);
|
2015-01-29 09:28:14 +08:00
|
|
|
|
2019-02-15 14:30:10 +08:00
|
|
|
vec3 v_normalVector = u_NormalMatrix * a_normal;
|
2015-04-14 14:20:31 +08:00
|
|
|
v_reflect = normalize(reflect(-vEyeVertex, v_normalVector));
|
2015-01-29 09:28:14 +08:00
|
|
|
}
|