Skip to content

Commit

Permalink
fix: incorrect stroke-radius when the item is fixed in frame
Browse files Browse the repository at this point in the history
  • Loading branch information
jkjkil4 committed Jun 25, 2024
1 parent fdadf16 commit 3cd2430
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions janim/anims/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ def render_all(self, ctx: mgl.Context) -> None:

set_global_uniforms(
ctx,
('JA_CAMERA_SCALED_FACTOR', camera_info.scaled_factor),
('JA_VIEW_MATRIX', camera_info.view_matrix.T.flatten()),
('JA_FIXED_DIST_FROM_PLANE', camera_info.fixed_distance_from_plane),
('JA_PROJ_MATRIX', camera_info.proj_matrix.T.flatten()),
Expand Down
1 change: 1 addition & 0 deletions janim/render/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def render(self, item: 'VItem') -> None:
self.vbo_radius.bind_to_storage_buffer(1)
self.vbo_stroke_color.bind_to_storage_buffer(2)
self.vbo_fill_color.bind_to_storage_buffer(3)
self.update_fix_in_frame(item, self.prog)
self.vao.render(mgl.TRIANGLE_STRIP)


Expand Down
5 changes: 5 additions & 0 deletions janim/render/shaders/vitem.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ in vec2 v_coord;

out vec4 f_color;

uniform float JA_CAMERA_SCALED_FACTOR;
uniform float JA_ANTI_ALIAS_RADIUS;
uniform bool JA_FIX_IN_FRAME;

const float INFINITY = uintBitsToFloat(0x7F800000);

Expand Down Expand Up @@ -34,6 +36,9 @@ bool get_isclosed(int idx) {
}

float get_radius(int idx) {
if (JA_FIX_IN_FRAME) {
return radii[idx / 4][idx % 4] * JA_CAMERA_SCALED_FACTOR;
}
return radii[idx / 4][idx % 4];
}

Expand Down

0 comments on commit 3cd2430

Please sign in to comment.