Skip to content

Commit 4c8aca9

Browse files
fu5haoktomus
authored andcommitted
fix paths clipping and middle path vertex bug
Fixes paths clipping through the back side of geometry and also properly determines perp_dir in the case where the vertex is in the middle of the path.
1 parent 3d10b75 commit 4c8aca9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/appleseed.studio/resources/shaders/lightpaths.vert

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ flat out float f_thickness;
5353
flat out float f_total_thickness;
5454
flat out float f_aspect_expansion_len;
5555

56+
const float CLIPPING_PREVENTION_FACTOR = 0.01;
57+
5658
void main() {
5759
float aspect = u_res.x / u_res.y;
5860
vec2 aspect_vec = vec2(aspect, 1.0);
5961
mat4 vp = u_proj * u_view;
6062
vec4 prev_proj = vp * vec4(v_previous, 1.0);
61-
vec4 curr_proj = vp * vec4(v_position, 1.0);
63+
vec4 curr_proj = vp * vec4(v_position + v_surface_normal * CLIPPING_PREVENTION_FACTOR, 1.0);
6264
vec4 next_proj = vp * vec4(v_next, 1.0);
6365

6466
//get 2D screen space with W divide and aspect correction
@@ -80,8 +82,11 @@ void main() {
8082
}
8183
else if ((v_direction_start_end & 4) == 4)
8284
{
83-
//ending point uses (current - v_previous)
85+
//ending point uses (current - previous)
8486
dir = normalize(curr_screen - prev_screen);
87+
} else {
88+
// middle point uses (next - current)
89+
dir = normalize(next_screen - curr_screen);
8590
}
8691
vec2 perp_dir = vec2(-dir.y, dir.x);
8792

0 commit comments

Comments
 (0)