Skip to content

Commit

Permalink
fix incorrect length of clipped line
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Jun 17, 2024
1 parent 217af7b commit 2234f66
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions GLMakie/assets/shader/lines.geom
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ bool process_clip_planes(inout vec4 p1, inout vec4 p2, inout bool[4] isvalid)
for(int i = 0; i < _num_clip_planes; i++)
{
// distance from clip planes with negative clipped
d1 = dot(p1.xyz / p1.w, clip_planes[i].xyz) - clip_planes[i].w;
d2 = dot(p2.xyz / p2.w, clip_planes[i].xyz) - clip_planes[i].w;
d1 = dot(p1.xyz, clip_planes[i].xyz) - clip_planes[i].w;
d2 = dot(p2.xyz, clip_planes[i].xyz) - clip_planes[i].w;

// both outside - clip everything
if (d1 < 0.0 && d2 < 0.0) {
Expand Down Expand Up @@ -287,6 +287,9 @@ void main(void)
clip_p2 = clip_p2 + (-clip_p2.w - clip_p2.z) / (v1.z + v1.w) * v1;
}

clip_p1 /= clip_p1.w;
clip_p2 /= clip_p2.w;

// Shorten segments to fit clip planes
// returns true if segments are fully clipped
if (process_clip_planes(clip_p1, clip_p2, isvalid))
Expand Down

0 comments on commit 2234f66

Please sign in to comment.