normals_optimized.vert 691 B

1234567891011121314151617181920212223242526272829
  1. #version 330
  2. #pragma debug(on)
  3. in layout(location = 0) vec3 a_positions;
  4. in layout(location = 1) vec3 a_normals;
  5. in layout(location = 2) vec2 a_texCoord;
  6. uniform mat4 u_transform; //full model view projection
  7. uniform mat4 u_modelTransform; //just model view
  8. out vec3 v_normals;
  9. out vec3 v_position;
  10. out vec2 v_texCoord;
  11. void main()
  12. {
  13. gl_Position = u_transform * vec4(a_positions, 1.f);
  14. v_position = (u_modelTransform * vec4(a_positions,1)).xyz;
  15. //v_normals = (u_modelTransform * vec4(a_normals,0)).xyz; //uniform scale
  16. v_normals = mat3(transpose(inverse(mat3(u_modelTransform)))) * a_normals; //non uniform scale
  17. v_normals = normalize(v_normals);
  18. v_texCoord = a_texCoord;
  19. }