diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-28 13:58:39 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-28 13:58:39 +0200 |
commit | 303636788d5e6ae546f4581f772e71309e3bcffc (patch) | |
tree | 140380b53faa47ab38a9d429ac3143b94ce36601 /shaders | |
parent | 3bb33734a92e86024488adf88dc2a368c8c952b2 (diff) |
Terrain changes, added water.
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/terrain_fragment.glsl | 17 | ||||
-rw-r--r-- | shaders/water_fragment.glsl | 13 |
2 files changed, 24 insertions, 6 deletions
diff --git a/shaders/terrain_fragment.glsl b/shaders/terrain_fragment.glsl index aa2de9b..7197883 100644 --- a/shaders/terrain_fragment.glsl +++ b/shaders/terrain_fragment.glsl @@ -11,14 +11,19 @@ void main() { vec3 n = normalize(normal); float diffuse = max(dot(n, light_pos), 0.5); - float f1 = clamp((pos.y-15.0) / 3.0, 0.0, 1.0); - float f2 = clamp((pos.y-2) / 3.0, 0.0, 1.0); + //float f1 = clamp((pos.y-15.0) / 3.0, 0.0, 1.0); + //float f2 = clamp((pos.y-2) / 3.0, 0.0, 1.0); + float f1 = clamp((pos.y-60.0) / 3.0, 0.0, 1.0); + float f2 = clamp((pos.y-30) / 3.0, 0.0, 1.0); - vec4 t0 = texture2D(tex[0], gl_TexCoord[0].st); - vec4 t1 = texture2D(tex[1], gl_TexCoord[0].st); - vec4 t2 = texture2D(tex[2], gl_TexCoord[0].st); + vec4 grass = texture2D(tex[0], gl_TexCoord[0].st); + vec4 rock = texture2D(tex[1], gl_TexCoord[0].st); + vec4 soil = texture2D(tex[2], gl_TexCoord[0].st); - gl_FragColor = mix(mix(t2, t0, f2), t1, f1) * diffuse; + gl_FragColor = mix(mix(soil, grass, f2), rock, f1) * diffuse; + + //gl_FragColor = mix(gl_FragColor, gl_FragColor*vec4(0, 0, 1, 0), clamp(31 - pos.y, 0.0, 1.0)); + //gl_FragColor += vec4(0, 0, 1, clamp(31 - pos.y, 0.0, 1.0)); /* selection marker */ if(show_sel && diff --git a/shaders/water_fragment.glsl b/shaders/water_fragment.glsl new file mode 100644 index 0000000..857a500 --- /dev/null +++ b/shaders/water_fragment.glsl @@ -0,0 +1,13 @@ +#version 120 + +varying vec3 pos; +uniform vec3 player_pos; +uniform sampler2D tex; + +void main() { + gl_FragColor = texture2D(tex, gl_TexCoord[0].st) - vec4(.2, .2, 0, 0); + gl_FragColor = mix(gl_FragColor, gl_Fog.color, pow(length(player_pos - pos)/100, 5)); + gl_FragColor.a = 0.7; +} + +/* vim: set syn=glsl: */ |