No Description

normaldebug.geom 779B

12345678910111213141516171819202122232425262728293031323334353637
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (triangles) in;
  5. layout (line_strip, max_vertices = 6) out;
  6. layout (binding = 1) uniform UBO
  7. {
  8. mat4 projection;
  9. mat4 model;
  10. } ubo;
  11. layout (location = 0) in vec3 inNormal[];
  12. layout (location = 0) out vec3 outColor;
  13. void main(void)
  14. {
  15. float normalLength = 0.02;
  16. for(int i=0; i<gl_in.length(); i++)
  17. {
  18. vec3 pos = gl_in[i].gl_Position.xyz;
  19. vec3 normal = inNormal[i].xyz;
  20. gl_Position = ubo.projection * (ubo.model * vec4(pos, 1.0));
  21. outColor = vec3(1.0, 0.0, 0.0);
  22. EmitVertex();
  23. gl_Position = ubo.projection * (ubo.model * vec4(pos + normal * normalLength, 1.0));
  24. outColor = vec3(0.0, 0.0, 1.0);
  25. EmitVertex();
  26. EndPrimitive();
  27. }
  28. }