normal_visualizer.geom 470 B

12345678910111213141516171819202122
  1. layout(triangles) in;
  2. layout(line_strip, max_vertices = 6) out;
  3. in vec3 nor[];
  4. void main()
  5. {
  6. for(int i=0; i < gl_in.length(); i++)
  7. {
  8. vec4 pos = gl_in[i].gl_Position;
  9. gl_Position = pos;
  10. EmitVertex();
  11. vec3 normal = normalize(nor[i]);
  12. pos = inverse(ProjectionMatrix) * pos;
  13. pos /= pos.w;
  14. gl_Position = ProjectionMatrix * (pos + .2 * vec4(normal, 0.));
  15. EmitVertex();
  16. EndPrimitive();
  17. }
  18. }