source: framspy/gui/visual/shaders/WorldGeometryShader.glsl @ 1320

Last change on this file since 1320 was 1198, checked in by Maciej Komosinski, 23 months ago

Added simple Python GUI for Framsticks library/server

File size: 1.3 KB
Line 
1#version 330
2
3layout(triangles) in;
4in vec3 v_color[];
5
6layout (triangle_strip, max_vertices = 3) out;
7out vec3 g_color;
8out float height;
9out vec3 normal;
10out vec3 position;
11
12uniform mat4 projectionMatrix;
13uniform mat4 viewMatrix;
14uniform int mode;
15uniform float worldSize;
16uniform float waterLevel;
17
18vec3 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
25void 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.