Skip to content

Commit 47b31c8

Browse files
PierreWangerikaharrison-adsk
authored andcommitted
Merge the DashDotPattern into DashDotPatternAPI schema
1 parent 008cf54 commit 47b31c8

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

proposals/LineStyle/README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can also define other type of patterns.
3131
# The implementation of DashDot line style
3232
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.
3333

34-
The detail of the pattern will be put in a new type, the DashDotPattern. It inherits from Typed. There is an APISchema, the DashDotPatternAPI, which can bind a DashDotLines primitive with one DashDotPattern. One DashDotPattern can be bound to several different DashDotLines primitive.
34+
The detail of the pattern will be put in the DashDotPatternAPI.
3535

3636
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.
3737

@@ -41,7 +41,7 @@ In the implementation, we also create special geometry for the primitive. Each l
4141
A new primitive DashDotLines is added, which inherits from Curves. It inherits properties from Curves.
4242
The shape of this primitive on the screen is a uniform-width line or polyline. Its width will not change when camera changes. It has either no pattern or dash-dot pattern.
4343

44-
The DashDotLines primitive can bind a DashDotPattern type. Then the lines will have dash-dot pattern. If it doesn't bind a DashDotPattern, it will not have a pattern.
44+
By default, the DashDotLines primitive doesn't have a pattern. If you would like to have a pattern, you need to create a "Pattern" primitive which will apply the DashDotPatternAPI schema, and you can configure the pattern properties. Then the DashDotLines primitive should inherit from the "Pattern" primitive. Different DashDotLines primitive could inherits from the same "Pattern" primitive.
4545

4646
These are properties which inherited from Curves:
4747
- curveVertexCounts
@@ -50,25 +50,23 @@ These are properties which inherited from Curves:
5050
The DashDotLines has the following new properties:
5151
- 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".
5252
- 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".
53-
- patternScale. A float uniform. It is valid when the primitive binds a DashDotPattern. 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.
54-
- screenspacePattern. A bool uniform. It is valid when the primitive binds a DashDotPattern. 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.
53+
- 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.
54+
- 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.
5555

5656
![image of screenspacePattern](screenSpacePattern.png)
5757

5858
### Extents of the DashDotLines
5959
Different from the other Curves, the extents of the DashDotLines is only the bound box of the control points. The width of the line will not be considered, because it is screen spaced, that it is implemented via the shader.
6060

61-
### The DashDotPattern schema
62-
The DashDotPattern schema inherits from Typed. It saves the detail of a dash-dot pattern. A dash-dot pattern is an array of symbols. Each symbol is either a dash, which is a line, or a dot, which is a point. The DashDotPattern can be bound to one or more DashDotLines primitive.
61+
### The DashDotPatternAPI schema
62+
The DashDotPatternAPI schema inherits from APISchemaBase. It saves the detail of a dash-dot pattern. A dash-dot pattern is an array of symbols. Each symbol is either a dash, which is a line, or a dot, which is a point.
6363

64-
The DashDotPattern has the following new properties:
64+
The DashDotPatternAPI has the following new properties:
6565
- patternPeriod. A float uniform. It is the length of a pattern. By default it is zero. If there is no pattern, it should be zero.
6666
- pattern. An array of float2. It saves the dash-dot pattern. For each float2, the x value and the y value must be zero or positive. The x value saves the offset of the start of current symbol, from the end of the previous symbol. If the current symbol is the first symbol, the offset is from the start of the pattern to the start of current symbol. The y value saves the length of the current symbol. If it is zero, the current symbol is a dot. If it is larger than zero, the current symbol is a dash. As a result, the total sum of all the x value and y value will be the length from the start of the pattern to the end of the last symbol. This sum must be smaller than patternPeriod.
6767

6868
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.
6969

70-
An API schema DashDotPatternAPI is provided to bind the DashDotPattern to a DashDotLines primitive.
71-
7270
### The DashDotLines rprim and shader
7371
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".
7472

@@ -79,10 +77,9 @@ For a polyline, the shader need to know the sum of line lengths before each vert
7977
### 2 DashDotLines primitives with dash-dot patterns
8078
```
8179
def DashDotLines "StyledPolyline1" (
82-
prepend apiSchemas = ["DashDotPatternAPI"]
80+
inherits = [</Pattern>]
8381
){
8482
uniform bool screenspacePattern = true
85-
rel dashDotPattern:binding = </Pattern>
8683
uniform token startCapType = "round"
8784
uniform token endCapType = "round"
8885
float patternScale = 5
@@ -92,10 +89,9 @@ def DashDotLines "StyledPolyline1" (
9289
color3f[] primvars:displayColor = [(1, 0, 0)]
9390
}
9491
def DashDotLines "StyledPolyline2" (
95-
prepend apiSchemas = ["DashDotPatternAPI"]
92+
inherits = [</Pattern>]
9693
){
9794
uniform bool screenspacePattern = true
98-
rel dashDotPattern:binding = </Pattern>
9995
uniform token startCapType = "triangle"
10096
uniform token endCapType = "triangle"
10197
uniform float patternScale = 11
@@ -105,13 +101,15 @@ def DashDotLines "StyledPolyline2" (
105101
color3f[] primvars:displayColor = [(0, 0, 1)]
106102
}
107103
108-
def DashDotPattern "Pattern"
104+
def "Pattern" (
105+
prepend apiSchemas = ["DashDotPatternAPI"]
106+
)
109107
{
110108
uniform float patternPeriod = 10
111109
uniform float2[] pattern = [(0, 5), (2.5, 0)]
112110
}
113111
```
114-
In this example, there are two DashDotLines primitives. They all bind to the same dash-dot pattern, and the pattern is defined in "Pattern". The period of the pattern is 10. There are two symbols in the pattern. The first symbol starts at 0, and it is a dash with length 5. The second symbol starts at 7.5, and it is a dot.
112+
In this example, there are two DashDotLines primitives. They all inherits from the same dash-dot pattern, and the pattern is defined in "Pattern". The period of the pattern is 10. There are two symbols in the pattern. The first symbol starts at 0, and it is a dash with length 5. The second symbol starts at 7.5, and it is a dot.
115113

116114
The first primitive has two polylines. One polyline has 3 vertices and another has 4 vertices. The line width on screen is 5. The startCapType and endCapType are both round. The patternScale is 5 which means the dashes and gaps will be lengthened by 5 times.
117115

0 commit comments

Comments
 (0)