Use frame_scale uniform instead of frame_shape

This commit is contained in:
Grant Sanderson 2023-01-30 15:10:41 -08:00
parent 9628adc957
commit daaaba0a67
2 changed files with 9 additions and 5 deletions

View file

@ -169,10 +169,10 @@ class Camera(object):
# Getting camera attributes
def get_pixel_size(self) -> float:
return self.frame.get_shape()[0] / self.get_pixel_shape()[0]
return self.frame.get_width() / self.get_pixel_shape()[0]
def get_pixel_shape(self) -> tuple[int, int]:
return self.draw_fbo.size
return self.fbo.size
def get_pixel_width(self) -> int:
return self.get_pixel_shape()[0]
@ -233,7 +233,7 @@ class Camera(object):
self.uniforms.update(
view=tuple(view_matrix.T.flatten()),
focal_distance=frame.get_focal_distance() / frame.get_scale(),
frame_shape=frame.get_shape(),
frame_scale=frame.get_scale(),
pixel_size=self.get_pixel_size(),
camera_position=tuple(cam_pos),
light_position=tuple(light_pos),

View file

@ -1,6 +1,7 @@
#version 330
uniform vec2 frame_shape;
uniform float frame_scale;
uniform float is_fixed_in_frame;
in vec3 point;
in vec4 stroke_rgba;
@ -20,7 +21,10 @@ const float STROKE_WIDTH_CONVERSION = 0.01;
void main(){
verts = point;
v_stroke_width = STROKE_WIDTH_CONVERSION * stroke_width * frame_shape[1] / 8.0;
v_stroke_width = STROKE_WIDTH_CONVERSION * stroke_width;
if(!bool(is_fixed_in_frame)){
v_stroke_width *= frame_scale;
}
v_joint_product = joint_product;
v_color = stroke_rgba;
v_vert_index = gl_VertexID;