Last change
on this file since 1290 was
1198,
checked in by Maciej Komosinski, 22 months ago
|
Added simple Python GUI for Framsticks library/server
|
File size:
1.3 KB
|
Line | |
---|
1 | #version 330
|
---|
2 |
|
---|
3 | layout(triangles) in;
|
---|
4 | in vec3 v_color[];
|
---|
5 |
|
---|
6 | layout (triangle_strip, max_vertices = 3) out;
|
---|
7 | out vec3 g_color;
|
---|
8 | out float height;
|
---|
9 | out vec3 normal;
|
---|
10 | out vec3 position;
|
---|
11 |
|
---|
12 | uniform mat4 projectionMatrix;
|
---|
13 | uniform mat4 viewMatrix;
|
---|
14 | uniform int mode;
|
---|
15 | uniform float worldSize;
|
---|
16 | uniform float waterLevel;
|
---|
17 |
|
---|
18 | vec3 GetNormal()
|
---|
19 | {
|
---|
20 | vec3 a = vec3(gl_in[0].gl_Position) - vec3(gl_in[1].gl_Position);
|
---|
21 | vec3 b = vec3(gl_in[2].gl_Position) - vec3(gl_in[1].gl_Position);
|
---|
22 | return normalize(cross(a, b));
|
---|
23 | }
|
---|
24 |
|
---|
25 | void main(void) {
|
---|
26 | for(int i = 0; i < 3; i++)
|
---|
27 | {
|
---|
28 | if(mode == 0)
|
---|
29 | {
|
---|
30 | gl_Position = projectionMatrix * viewMatrix * gl_in[i].gl_Position;
|
---|
31 | height = gl_in[i].gl_Position.z;
|
---|
32 | position = gl_in[i].gl_Position.xyz;
|
---|
33 | }
|
---|
34 | else
|
---|
35 | {
|
---|
36 | mat4 transformation = mat4(1);
|
---|
37 | transformation[0][0] = worldSize;
|
---|
38 | transformation[1][1] = worldSize;
|
---|
39 | transformation[3][2] = waterLevel;
|
---|
40 | gl_Position = projectionMatrix * viewMatrix * transformation * gl_in[i].gl_Position;
|
---|
41 | position = vec3(transformation * gl_in[i].gl_Position);
|
---|
42 | height = 0;
|
---|
43 | }
|
---|
44 | g_color = v_color[0];
|
---|
45 | normal = -GetNormal().xyz;
|
---|
46 | EmitVertex();
|
---|
47 | }
|
---|
48 | EndPrimitive();
|
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.