1uniform mat4 g_ViewMatrix; 2uniform mat4 g_ProjectionMatrix; 3uniform mat4 g_WorldMatrix; 4 5uniform vec3 m_NormalScale; 6 7attribute vec3 inPosition; 8attribute vec3 inNormal; 9 10varying vec3 direction; 11 12void main(){ 13 // set w coordinate to 0 14 vec4 pos = vec4(inPosition, 0.0); 15 16 // compute rotation only for view matrix 17 pos = g_ViewMatrix * pos; 18 19 // now find projection 20 pos.w = 1.0; 21 gl_Position = g_ProjectionMatrix * pos; 22 23 vec4 normal = vec4(inNormal * m_NormalScale, 0.0); 24 direction = normalize( (g_WorldMatrix * normal).xyz ); 25} 26