Debian Codegraph @

tests/manual/tessellation-modes/shaders/triangles.tes

raw
1 #version 400 core
2
3 layout( triangles, fractional_even_spacing, ccw ) in;
4
5 out EyeSpaceVertex {
6 vec3 position;
7 vec3 normal;
8 } te_out;
9
10 uniform mat4 modelViewMatrix;
11 uniform mat3 normalMatrix;
12 uniform mat4 projectionMatrix;
13 uniform mat4 mvp;
14
15 void main()
16 {
17 float u = gl_TessCoord.x;
18 float v = gl_TessCoord.y;
19 float w = gl_TessCoord.z;
20
21 vec4 p0 = gl_in[0].gl_Position;
22 vec4 p1 = gl_in[1].gl_Position;
23 vec4 p2 = gl_in[2].gl_Position;
24
25 // Linearly interpolate to the vertex position using the
26 // (u,v) barycentric coords
27 vec4 pos = (u * p0)
28 + (v * p1)
29 + (w * p2);
30
31 // Transform to eye space (for lighting calcs)
32 te_out.position = vec3( modelViewMatrix * pos );
33
34 // Assume normal points along z
35 te_out.normal = normalize( normalMatrix * vec3( 0.0, 0.0, 1.0 ) );
36
37 // Transform to clip-space
38 gl_Position = mvp * pos;
39 }