-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathgrass.tesc
More file actions
59 lines (42 loc) · 1.55 KB
/
grass.tesc
File metadata and controls
59 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(vertices = 1) out;
layout(set = 0, binding = 0) uniform CameraBufferObject {
mat4 view;
mat4 proj;
} camera;
// TODO: Declare tessellation control shader inputs and outputs
layout(location = 0) in vec4 control_v1[];
layout(location = 1) in vec4 control_v2[];
layout(location = 2) in vec4 control_up[];
layout(location = 3) in vec4 control_width[];
layout(location = 0) patch out vec4 evaluation_v1;
layout(location = 1) patch out vec4 evaluation_v2;
layout(location = 2) patch out vec4 evaluation_up;
layout(location = 3) patch out vec4 evaluation_Width;
void main() {
// Don't move the origin location of the patch
vec4 WorldPosV0 = gl_in[gl_InvocationID].gl_Position;
gl_out[gl_InvocationID].gl_Position = WorldPosV0;
// TODO: Write any shader outputs
evaluation_v1 = control_v1[0];
evaluation_v2 = control_v2[0];
evaluation_up = control_up[0];
evaluation_Width = control_width[0];
float near = 0.1;
float far = 25.0;
float depth = -(camera.view * WorldPosV0).z / (far - near);
depth = clamp(depth, 0.0, 1.0);
float maxLevel = 5.0;
float minLevel = 1.0;
depth = depth*depth;
float level = mix(maxLevel, minLevel, depth);
evaluation_Width.w = depth;
// TODO: Set level of tesselation
gl_TessLevelInner[0] = 1.0; //horizontal
gl_TessLevelInner[1] = level; //vertical
gl_TessLevelOuter[0] = level; //vertical
gl_TessLevelOuter[1] = 1.0; //horizontal
gl_TessLevelOuter[2] = level; //vertical
gl_TessLevelOuter[3] = 1.0; //horizontal
}