Last change
on this file was
1198,
checked in by Maciej Komosinski, 22 months ago
|
Added simple Python GUI for Framsticks library/server
|
File size:
936 bytes
|
Rev | Line | |
---|
[1198] | 1 | #version 330
|
---|
| 2 |
|
---|
| 3 | in vec3 g_color;
|
---|
| 4 | in float height;
|
---|
| 5 | in vec3 normal;
|
---|
| 6 | in vec3 position;
|
---|
| 7 |
|
---|
| 8 | out vec4 out_Color;
|
---|
| 9 |
|
---|
| 10 | uniform int mode;
|
---|
| 11 | uniform float worldSize;
|
---|
| 12 |
|
---|
| 13 | const vec3 color_low = vec3(1,0,0);
|
---|
| 14 | const vec3 color_high = vec3(0.5,0.5,0);
|
---|
| 15 | const float height_min = -5.f;
|
---|
| 16 | const float height_max = 5.f;
|
---|
| 17 | vec3 light_pos = vec3(worldSize/2, worldSize/2, worldSize);
|
---|
| 18 |
|
---|
| 19 | void 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.