emit_gl_Position.glsl 696 B

123456789101112131415161718192021
  1. uniform float is_fixed_in_frame;
  2. uniform mat4 view;
  3. uniform float focal_distance;
  4. uniform vec3 frame_rescale_factors;
  5. uniform vec4 clip_plane;
  6. void emit_gl_Position(vec3 point){
  7. vec4 result = vec4(point, 1.0);
  8. // This allow for smooth transitions between objects fixed and unfixed from frame
  9. result = mix(view * result, result, is_fixed_in_frame);
  10. // Essentially a projection matrix
  11. result.xyz *= frame_rescale_factors;
  12. result.w = 1.0 - result.z;
  13. // Flip and scale to prevent premature clipping
  14. result.z *= -0.1;
  15. gl_Position = result;
  16. if(clip_plane.xyz != vec3(0.0, 0.0, 0.0)){
  17. gl_ClipDistance[0] = dot(vec4(point, 1.0), clip_plane);
  18. }
  19. }