normalRendererGen.gp 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2020, Inria
  3. * GRAPHDECO research group, https://team.inria.fr/graphdeco
  4. * All rights reserved.
  5. *
  6. * This software is free for non-commercial, research and evaluation use
  7. * under the terms of the LICENSE.md file.
  8. *
  9. * For inquiries contact sibr@inria.fr and/or George.Drettakis@inria.fr
  10. */
  11. #version 420
  12. uniform mat4 MVPinv;
  13. layout(triangles) in;
  14. layout (triangle_strip) out;
  15. layout (max_vertices = 3) out;
  16. out vec3 GtoF_normal;
  17. void main(void) {
  18. vec3 P0 = (MVPinv *gl_in[0].gl_Position).xyz;
  19. vec3 P1 = (MVPinv *gl_in[1].gl_Position).xyz;
  20. vec3 P2 = (MVPinv *gl_in[2].gl_Position).xyz;
  21. vec3 V0 = P0 - P1;
  22. vec3 V1 = P2 - P1;
  23. vec3 N = normalize( cross(V1, V0) );
  24. int i;
  25. for (i = 0; i < gl_in.length(); i++)
  26. {
  27. GtoF_normal = N; // Specs say we need to set again output values after calling EmitVertex
  28. gl_Position = gl_in[i].gl_Position;
  29. EmitVertex();
  30. }
  31. EndPrimitive();
  32. }