You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vertices 6+ are called `join` vertices in the code, however they are used for
76
+
Vertices 6+ are called `join` vertices in the code, but they are used for
77
77
both `joins` and `caps`. Their computation will depend on the type of `join` or
78
-
`cap` used. Here, a`round` cap is shown. It is important to note their
78
+
`cap` used. Here, an (incomplete)`round` cap is shown. It is important to note their
79
79
distribution. Just like the 4 core vertices 2-5, they are distributed CCW
80
80
progressively further away from their respective core vertex. This makes it
81
81
possible to dynamically vary the number of segments in the joins, while using
82
82
the same index buffer. Each join vertex is identified by:
83
83
84
-
-`coreVertexIndex` which core vertex it belongs to (`v2,v6,v10=0`,
85
-
`v3,v7,v11=1` etc.)
86
-
-`joinVertexIndex` number of vertices away from the core vertex (`v2=0`,
87
-
`v6=1`, `v10=2`)
84
+
-`coreVertexIndex` which core vertex it belongs to
85
+
-`joinVertexIndex` number of vertices away from the core vertex
88
86
89
87
```ts
90
-
coreVertexIndex= (vertexIndex-2) %4;
91
-
joinVertexIndex= (vertexIndex-2) /4;
88
+
constcoreVertexIndex = (vertexIndex-2) %4;
89
+
constjoinVertexIndex = (vertexIndex-2) /4;
92
90
```
93
91
94
-
NOTE: instead of the slow `% 4` and `/ 4`, real code uses `& 0b11` and `>> 2`.
95
-
Probably can be optimized away by wgsl compilers, but you never know.
92
+
NOTE: real code uses `& 0b11` and `>> 2` instead of div.
96
93
97
-
Cap functions can then use `joinVertexIndex` and `maxJoinCount` to compute the
94
+
Cap functions can then use `joinVertexIndex / MAX_JOIN_COUNT` to compute the
98
95
final position of each join vertex.
99
96
100
97
If all you want to do is render single line segments, you should use
101
-
`singleLineSegmentVariableWidth(A, B)` function. It does exactly what we just
98
+
`lineVariableWidth(A, B, vertexIndex, MAX_JOIN_COUNT)` function. It does exactly what we just
102
99
discussed and nothing more.
103
100
104
-
## Joining Line Segments
101
+
## Polylines
102
+
103
+
Easy part is done. Joining segments into polylines is what makes line rendering interesting! First, lets consider how in theory the joining should work. A polyline consists of many joined segments. Each segment's geometry depends on its two neighboring segments. This is why the function accepts 4 consecutive control points $A, B, C, D$ with radii $r_A, r_B, r_C, r_D$.
Easy part is done. Joining segments is where the difficulties and edge cases
107
-
start. First, lets consider how in theory the joining should work:
107
+
The segment that actually gets drawn is $BC$, shaded in $\color{blue} blue$. The function needs $A$ and $D$ in order to compute the join geometry, but it does not create the red shaded regions. Darker shaded regions highlight the join area. Notice that only half the join is handled by each segment.
0 commit comments