source: framspy/gui/visual/shaders/WorldFragmentShader.glsl @ 1276

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

Added simple Python GUI for Framsticks library/server

File size: 936 bytes
Line 
1#version 330
2
3in vec3 g_color;
4in float height;
5in vec3 normal;
6in vec3 position;
7
8out vec4 out_Color;
9
10uniform int mode;
11uniform float worldSize;
12
13const vec3 color_low = vec3(1,0,0);
14const vec3 color_high = vec3(0.5,0.5,0);
15const float height_min = -5.f;
16const float height_max = 5.f;
17vec3 light_pos = vec3(worldSize/2, worldSize/2, worldSize);
18
19void main(void){
20    if(mode == 0)
21    {
22        float h = clamp(height, height_min, height_max);
23        h -= height_min;
24        h /= (height_max - height_min);
25
26        vec3 lightDir = normalize(light_pos - position);
27        float diff = max(dot(normal, lightDir), 0.0);
28        vec3 diffuse = vec3(diff);
29
30        if(abs(normal.z) < 0.0001)
31            out_Color = vec4(diffuse * vec3(0.5, 0.5, 0.5), 1);
32        else
33            out_Color = vec4(diffuse * mix(color_low, color_high, h), 1);
34    }
35    else
36        out_Color = vec4(g_color, 0.5);
37}
Note: See TracBrowser for help on using the repository browser.