@@ -51,13 +51,13 @@ vec2[3] DecodeTriangleTexCoords(in const cbt_Node node)
51
51
}
52
52
53
53
void EmitTriangle(
54
- inout ClipSpaceAttribute v0,
55
- inout ClipSpaceAttribute v1,
56
- inout ClipSpaceAttribute v2
54
+ inout VertexAttribute v0,
55
+ inout VertexAttribute v1,
56
+ inout VertexAttribute v2
57
57
) {
58
- vec4 c0 = u_ViewProjectionMatrix * v0.position;
59
- vec4 c1 = u_ViewProjectionMatrix * v1.position;
60
- vec4 c2 = u_ViewProjectionMatrix * v2.position;
58
+ vec4 c0 = u_ModelViewProjectionMatrix * v0.position;
59
+ vec4 c1 = u_ModelViewProjectionMatrix * v1.position;
60
+ vec4 c2 = u_ModelViewProjectionMatrix * v2.position;
61
61
vec2 p0 = u_ScreenResolution * c0.xy / c0.w;
62
62
vec2 p1 = u_ScreenResolution * c1.xy / c1.w;
63
63
vec2 p2 = u_ScreenResolution * c2.xy / c2.w;
@@ -68,19 +68,19 @@ void EmitTriangle(
68
68
69
69
gl_Position = c0;
70
70
o_TexCoord = v0.texCoord;
71
- o_WorldPos = v0.position.xyz;
71
+ o_WorldPos = (u_ModelMatrix * v0.position) .xyz;
72
72
o_Distance = vec3 (area / length (u0), 0 , 0 );
73
73
EmitVertex();
74
74
75
75
gl_Position = c1;
76
76
o_TexCoord = v1.texCoord;
77
- o_WorldPos = v1.position.xyz;
77
+ o_WorldPos = (u_ModelMatrix * v1.position) .xyz;
78
78
o_Distance = vec3 (0 , area / length (u1), 0 );
79
79
EmitVertex();
80
80
81
81
gl_Position = c2;
82
82
o_TexCoord = v2.texCoord;
83
- o_WorldPos = v2.position.xyz;
83
+ o_WorldPos = (u_ModelMatrix * v2.position) .xyz;
84
84
o_Distance = vec3 (0 , 0 , area / length (u2));
85
85
EmitVertex();
86
86
@@ -138,15 +138,15 @@ void main()
138
138
only one triangle.
139
139
*/
140
140
#if TERRAIN_PATCH_SUBD_LEVEL == 0
141
- ClipSpaceAttribute v0 = TessellateClipSpaceTriangle (
141
+ VertexAttribute v0 = TessellateTriangle (
142
142
triangleTexCoords,
143
143
vec2 (0 , 1 )
144
144
);
145
- ClipSpaceAttribute v1 = TessellateClipSpaceTriangle (
145
+ VertexAttribute v1 = TessellateTriangle (
146
146
triangleTexCoords,
147
147
vec2 (0 , 0 )
148
148
);
149
- ClipSpaceAttribute v2 = TessellateClipSpaceTriangle (
149
+ VertexAttribute v2 = TessellateTriangle (
150
150
triangleTexCoords,
151
151
vec2 (1 , 0 )
152
152
);
@@ -159,19 +159,19 @@ void main()
159
159
for (uint nodeID = minNodeID; nodeID < maxNodeID; ++ nodeID) {
160
160
cbt_Node node = cbt_CreateNode(nodeID, nodeDepth);
161
161
vec2 tessCoords[3 ] = DecodeTriangleTexCoords(node);
162
- ClipSpaceAttribute v0 = TessellateClipSpaceTriangle (
162
+ VertexAttribute v0 = TessellateTriangle (
163
163
triangleTexCoords,
164
164
tessCoords[2 ]
165
165
);
166
- ClipSpaceAttribute v1 = TessellateClipSpaceTriangle (
166
+ VertexAttribute v1 = TessellateTriangle (
167
167
triangleTexCoords,
168
168
tessCoords[1 ]
169
169
);
170
- ClipSpaceAttribute v2 = TessellateClipSpaceTriangle (
170
+ VertexAttribute v2 = TessellateTriangle (
171
171
triangleTexCoords,
172
172
(tessCoords[0 ] + tessCoords[2 ]) / 2 .0f
173
173
);
174
- ClipSpaceAttribute v3 = TessellateClipSpaceTriangle (
174
+ VertexAttribute v3 = TessellateTriangle (
175
175
triangleTexCoords,
176
176
tessCoords[0 ]
177
177
);
0 commit comments