3b1b-manim/manimlib/shaders/inserts/get_gl_Position.glsl

24 lines
675 B
Text
Raw Normal View History

uniform float is_fixed_in_frame;
2023-01-23 14:41:17 -08:00
uniform mat4 view;
uniform float focal_distance;
const float DEFAULT_FRAME_HEIGHT = 8.0;
const float ASPECT_RATIO = 16.0 / 9.0;
const float X_SCALE = 2.0 / DEFAULT_FRAME_HEIGHT / ASPECT_RATIO;
const float Y_SCALE = 2.0 / DEFAULT_FRAME_HEIGHT;
2020-06-01 16:21:18 -07:00
void emit_gl_Position(vec3 point){
2020-06-09 17:12:52 -07:00
vec4 result = vec4(point, 1.0);
if(!bool(is_fixed_in_frame)){
2023-01-23 14:41:17 -08:00
result = view * result;
2023-01-18 13:44:41 -08:00
}
// Essentially a projection matrix
result.x *= X_SCALE;
result.y *= Y_SCALE;
2023-01-13 12:41:09 -08:00
result.z /= focal_distance;
result.w = 1.0 - result.z;
2023-01-13 21:43:01 -08:00
// Flip and scale to prevent premature clipping
result.z *= -0.1;
gl_Position = result;
}