VertShader.vsh 538 B

1234567891011121314151617181920
  1. attribute highp vec3 inVertex;
  2. attribute mediump vec3 inNormal;
  3. uniform highp mat4 MVPMatrix;
  4. uniform mediump mat3 ModelWorld;
  5. uniform mediump vec3 EyePosModel;
  6. varying mediump vec3 ReflectDir;
  7. void main()
  8. {
  9. // Transform position
  10. gl_Position = MVPMatrix * vec4(inVertex, 1.0);
  11. // Calculate eye direction in model space
  12. mediump vec3 eyeDir = normalize(inVertex - EyePosModel);
  13. // reflect eye direction over normal and transform to world space
  14. ReflectDir = ModelWorld * reflect(eyeDir, inNormal);
  15. }