Skip to content

Commit b5015f8

Browse files
committed
Modify the document according to latest implementation.
1 parent 47b31c8 commit b5015f8

File tree

3 files changed

+68
-12
lines changed

3 files changed

+68
-12
lines changed

proposals/LineStyle/README.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Introduction
2-
USD already has primitives to render 3D curve-like geometries, such as hair or grass. In practice, we also need curves in sketch or CAD document. The curve has uniform width, and its width will not change when we rotate or zoom the sketch. The curve may also have dash-dot patterns. We will provide a schema which is for patterned lines or polylines. The primitive will have uniform screen-width, and can have dash-dot patterns.
2+
USD already has primitives to render 3D curve-like geometries, such as hair or grass. In practice, there are requirements for curves with dash-dot patterns. The curve has uniform width, and its width will not change when we rotate or zoom the sketch. One common example is that when you do selection, you will see a rectangle that highlights the selection area, and the edge of the rectangle will have a dash pattern. Another common example is that in a CAD design document, the dash-dot lines can be used to show hidden lines.
3+
In this proposal, we will provide a schema which is for patterned lines or polylines. The primitive will have uniform screen-width, and can have dash-dot patterns.
34

4-
Here is a picture of common dash dot patterns.
5+
Here is a picture of common dash-dot patterns.
56

67
![image of curve patterns](linePatterns.jpg)
78

@@ -26,16 +27,14 @@ The line joint is the shape at the joint of two lines, or at the joint of a poly
2627
### Dash-dot Pattern
2728
A dash-dot pattern is a composite of dashes and dots and the composition is periodic.
2829

29-
You can also define other type of patterns.
30-
3130
# The implementation of DashDot line style
3231
Our implementation will introduce a new type of primitive, the DashDotLines. It inherits from Curves. The primitive is a list of line segments or polylines. The width of the line will be uniform, and it will not change when camera changes. There can be no pattern in the line. Or there can be dash-dot pattern.
3332

34-
The detail of the pattern will be put in the DashDotPatternAPI.
33+
The detail of the dash-dot pattern will be put in the DashDotPatternAPI.
3534

36-
We also add a new rprim for the DashDotLines. We add a new shader file, the dashDotLines.glslfx, which includes both vertex and fragment shader.
35+
We also add a new rprim for the DashDotLines. We add a two shader files, the dashDotLines.glslfx, which includes both vertex and fragment shader, and dashDotFallbackMaterialNetwork.glslfx, which is a default material for the DashDotLines.
3736

38-
In the implementation, we also create special geometry for the primitive. Each line segment is converted to a rectangle which is composed from two triangles.
37+
We provide two different implementations. In the "allDetails" implementation, we create special geometry for the primitive. Each line segment is converted to a rectangle which is composed from two triangles. The dash-dot pattern and the line width are implemented in the shader. In the "noCapJoint" implementation, the line segments or polylines are rendered as line lists, and in each part of line, we will check if the pixel is within the dash or the gap. For this implementation, the caps and joints will be ignored. And the line width is implemented in the GPU pipeline configuration, such as using glLineWidth().
3938

4039
### The DashDotLines schema
4140
A new primitive DashDotLines is added, which inherits from Curves. It inherits properties from Curves.
@@ -48,8 +47,10 @@ These are properties which inherited from Curves:
4847
- widths. Widths are now interpreted as the widths in screen space.
4948

5049
The DashDotLines has the following new properties:
51-
- startCapType. A token uniform. It is the shape of the line cap at the start of the line. It can be "round", "triangle" or "square". The default value is "round".
52-
- endCapType. A token uniform. It is the shape of the line cap at the end of the line. It can be "round", "triangle" or "square". The default value is "round".
50+
- shapeDetail. A token uniform. It implies if the caps and joints are rendered or not. Currently it can be "allDetails" or "noCapJoint". The default value is "allDetails", which means the startCap, endCap and the joint will be rendered. If this value is "noCapJoint", the startCapType, endCapType and jointType will be ignored.
51+
- startCapType. A token uniform. It is valid when shapeDetail is "allDetails". It is the shape of the line cap at the start of the line. It can be "round", "triangle" or "square". The default value is "round".
52+
- endCapType. A token uniform. It is valid when shapeDetail is "allDetails". It is the shape of the line cap at the end of the line. It can be "round", "triangle" or "square". The default value is "round".
53+
- jointType. A token uniform. It is valid when shapeDetail is "allDetails". It is the shape at the joint of two lines, or at the joint of a polyline. Currently it can only be "round". More types of joint can be added in the future.
5354
- patternScale. A float uniform. It is valid when the primitive inherits from a "Pattern" primitive. The default value is 1. You can lengthen or compress the line pattern by setting this property. For example, if patternScale is set to 2, the length of each dash and each gap will be enlarged by 2 times. This value will not impact on the line width.
5455
- screenspacePattern. A bool uniform. It is valid when the primitive inherits from a "Pattern" primitive. By default it is true, which means the dash-dot pattern will be based on screen unit. If we zoom in, the pattern on the line will change in the world space, so that the dash size and the dash gap size in the screen space will not change. If it is false, the pattern will be based on world unit. If we zoom in, the pattern on the line will not change in world space. The dash size and the dash gap size in the screen space will be larger.
5556

@@ -68,20 +69,26 @@ The DashDotPatternAPI has the following new properties:
6869
For example, assume the pattern is [(0, 10), (1, 4), (3, 0)]. It means the first symbol is a dash which is from 0 to 10. The second symbol is a dash which is from 11 to 15, and the third symbol is a dot which is at position 18. There are gaps between 10 and 11, and between 15 and 18. If the patternPeriod is 20, there is also a gap between 18 and 20.
6970

7071
### The DashDotLines rprim and shader
71-
In HdStorm, we will add the HdDashDotLines rprim for the DashDotLines primitive. The topology of the DashDotLines requires the curveVertexCounts, curveIndices and whether the pattern is screenspaced. In dashDotLines.glslfx, we add two sections of shader code: "DashDot.Vertex" and "DashDot.Fragment".
72+
In HdStorm, we will add the HdDashDotLines rprim for the DashDotLines primitive. The topology of the DashDotLines requires the shape detail ("allDetails" or "noCapJoint"), curveVertexCounts, curveIndices and whether the pattern is screenspaced. When the shapeDetail is "noCapJoint", the primitive type is PRIM_BASIS_CURVES_LINES. And when the shapeDetail is "allDetails", we add a new primitive type: PRIM_DASH_DOT_LINES, and the lines will be implemented as a list of rectangles, and each rectangle will contain two Striangles.
73+
74+
In dashDotLines.glslfx, we add four sections of shader code: "DashDotDefault.Vertex" and "DashDotDefault.Fragment" are for the "allDetails" implementation. "NoCapJoint.Vertex" and "NoCapJoint.Fragment" are for the "noCapJoint" implementation.
75+
76+
Different from the other primitive, the dashDotLines should not have effects under lights. So we use a different fallback material. The dashDotFallbackMaterialNetwork.glslfx save the default material shader. The surface shader will just return the color the line, so that the lights will not influent the lines.
7277

7378
### Other inputs for the shader and screen space pattern implementation
7479
For a polyline, the shader need to know the sum of line lengths before each vertex. This value can be pre-calculated in CPU. To implement screen space dash-dot pattern, the sum must be based on line lengths on the screen. So to calculate the sum, we need to do matrix transformation for the lines in CPU, and this calculation must be done when camera is changed. (Maybe we can use the compute shader to do the calculation before the rendering process in each frame)
7580

7681
# Examples
77-
### 2 DashDotLines primitives with dash-dot patterns
82+
### 2 DashDotLines primitives with dash-dot patterns, and the shape detail is "allDetails"
7883
```
7984
def DashDotLines "StyledPolyline1" (
8085
inherits = [</Pattern>]
8186
){
87+
uniform token shapeDetail = "allDetails"
8288
uniform bool screenspacePattern = true
8389
uniform token startCapType = "round"
8490
uniform token endCapType = "round"
91+
uniform token jointType = "round"
8592
float patternScale = 5
8693
int[] curveVertexCounts = [3, 4]
8794
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
@@ -91,12 +98,14 @@ def DashDotLines "StyledPolyline1" (
9198
def DashDotLines "StyledPolyline2" (
9299
inherits = [</Pattern>]
93100
){
101+
uniform token shapeDetail = "allDetails"
94102
uniform bool screenspacePattern = true
95103
uniform token startCapType = "triangle"
96104
uniform token endCapType = "triangle"
105+
uniform token jointType = "round"
97106
uniform float patternScale = 11
98107
int[] curveVertexCounts = [3, 4]
99-
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
108+
point3f[] points = [(20, 0, 0), (30, 10, 0), (30, 20, 0), (20, 30, 0), (10, 40, 0), (10, 50, 0), (20, 60, 0)]
100109
float[] widths = [10] (interpolation = "constant")
101110
color3f[] primvars:displayColor = [(0, 0, 1)]
102111
}
@@ -119,12 +128,59 @@ The image for the 2 DashDotLines primitives.
119128

120129
![image of Dashdotlines primitives](twoPolylines.png)
121130

131+
### 2 DashDotLines primitives with dash-dot patterns, and the shape detail is "noCapJoint"
132+
```
133+
def DashDotLines "StyledPolyline1" (
134+
inherits = [</Pattern>]
135+
){
136+
uniform token shapeDetail = "noCapJoint"
137+
uniform bool screenspacePattern = true
138+
uniform token startCapType = "round"
139+
uniform token endCapType = "round"
140+
uniform token jointType = "round"
141+
float patternScale = 5
142+
int[] curveVertexCounts = [3, 4]
143+
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
144+
float[] widths = [5] (interpolation = "constant")
145+
color3f[] primvars:displayColor = [(1, 0, 0)]
146+
}
147+
def DashDotLines "StyledPolyline2" (
148+
inherits = [</Pattern>]
149+
){
150+
uniform token shapeDetail = "noCapJoint"
151+
uniform bool screenspacePattern = true
152+
uniform token startCapType = "triangle"
153+
uniform token endCapType = "triangle"
154+
uniform token jointType = "round"
155+
uniform float patternScale = 11
156+
int[] curveVertexCounts = [3, 4]
157+
point3f[] points = [(20, 0, 0), (30, 10, 0), (30, 20, 0), (20, 30, 0), (10, 40, 0), (10, 50, 0), (20, 60, 0)]
158+
float[] widths = [10] (interpolation = "constant")
159+
color3f[] primvars:displayColor = [(0, 0, 1)]
160+
}
161+
162+
def "Pattern" (
163+
prepend apiSchemas = ["DashDotPatternAPI"]
164+
)
165+
{
166+
uniform float patternPeriod = 10
167+
uniform float2[] pattern = [(0, 5), (2.5, 0)]
168+
}
169+
```
170+
In this example, the two DashDotLines primitive are similar as the above example. The only difference is that the shapeDetail is "noCapJoint".
171+
172+
The image for the 2 DashDotLines primitives.
173+
174+
![image of Dashdotlines primitives](twoPolylinesSimple.png)
175+
122176
### A polyline with no pattern
123177
```
124178
def DashDotLines "StyledPolyline" (
125179
){
180+
uniform token shapeDetail = "allDetails"
126181
uniform token startCapType = "round"
127182
uniform token endCapType = "round"
183+
uniform token jointType = "round"
128184
int[] curveVertexCounts = [3]
129185
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0)]
130186
float[] widths = [5] (interpolation = "constant")
-1.02 KB
Loading
4.71 KB
Loading

0 commit comments

Comments
 (0)