showNormals_optimized.vert 468 B

123456789101112131415161718192021
  1. #version 330
  2. #pragma debug(on)
  3. in layout(location = 0) vec3 a_positions;
  4. in layout(location = 1) vec3 a_normals;
  5. uniform mat4 u_modelTransform; //just model view
  6. out vec3 v_normals;
  7. void main()
  8. {
  9. gl_Position = u_modelTransform * vec4(a_positions, 1);
  10. //v_normals = (u_modelTransform * vec4(a_normals,0)).xyz; //uniform scale
  11. v_normals = mat3(transpose(inverse(mat3(u_modelTransform)))) * a_normals; //non uniform scale
  12. v_normals = normalize(v_normals);
  13. }