forked from LukasBanana/LLGL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.450core.tese
52 lines (40 loc) · 1.14 KB
/
Example.450core.tese
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
// GLSL tessellation evaluation shader
#version 450
// Tessellation evaluation input configuration
layout(quads, fractional_odd_spacing, cw) in;
// Uniform buffer object (also named "Constant Buffer")
layout(std140, binding = 0) uniform Settings
{
mat4 wvpMatrix;
float tessLevelInner;
float tessLevelOuter;
float twist;
float _pad0;
};
// Input and output attributes
layout(location = 0) in vec3 tcPosition[];
layout(location = 0) out vec3 teColor;
// Vertex shader main function
void main()
{
// Interpolate position
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
vec3 a = mix(tcPosition[0], tcPosition[1], u);
vec3 b = mix(tcPosition[2], tcPosition[3], u);
vec3 position = mix(a, b, v);
// Set final vertex color
teColor = (1.0 - position) * 0.5;
// Apply twist rotation matrix (rotate around Y axis)
float twistFactor = (position.y + 1.0) * 0.5;
float s = sin(twist * twistFactor);
float c = cos(twist * twistFactor);
mat3 rotation = mat3(
c, 0, s,
0, 1, 0,
-s, 0, c
);
position = rotation * position;
// Transform vertex by the world-view-projection matrix chain
gl_Position = wvpMatrix * vec4(position, 1);
}