diff options
author | Joshua Rahm <joshua.rahm@colorado.edu> | 2014-04-25 13:09:42 -0600 |
---|---|---|
committer | Joshua Rahm <joshua.rahm@colorado.edu> | 2014-04-25 13:09:42 -0600 |
commit | 0c54864f6301a6e0a7bf5553818995fda883bace (patch) | |
tree | d9ddf3607234aa4e8c86c7873cd1bcb3dc3fbaeb /shaders | |
parent | e3a07ab4ccf65ddf052b483cf879f6a9bdd97720 (diff) | |
download | terralloc-0c54864f6301a6e0a7bf5553818995fda883bace.tar.gz terralloc-0c54864f6301a6e0a7bf5553818995fda883bace.tar.bz2 terralloc-0c54864f6301a6e0a7bf5553818995fda883bace.zip |
have first person view
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/basic.frag | 4 | ||||
-rw-r--r-- | shaders/sky.frag | 4 | ||||
-rw-r--r-- | shaders/water.frag | 3 |
3 files changed, 8 insertions, 3 deletions
diff --git a/shaders/basic.frag b/shaders/basic.frag index a97caf8..61e57bf 100644 --- a/shaders/basic.frag +++ b/shaders/basic.frag @@ -12,6 +12,8 @@ uniform float dY ; uniform mat4 mvMatrix ; uniform mat4 pjMatrix ; +uniform float fog ; + in vec3 normal ; uniform sampler2D textures[8] ; @@ -81,5 +83,5 @@ void main() { float prod = dot( normalize(-newNorm), normalize(vec3(lightPos - position))); vec3 intensity = vec3(prod,prod,max(prod,0.4)) ; - frag_color = vec4(color * intensity,1) * vec4(normalize(globalAmbient.xyz),1.0); + frag_color = vec4(color * intensity / (-position.z*fog+1),1) * vec4(normalize(globalAmbient.xyz),1.0); } diff --git a/shaders/sky.frag b/shaders/sky.frag index 6d47adb..43b4265 100644 --- a/shaders/sky.frag +++ b/shaders/sky.frag @@ -13,6 +13,8 @@ uniform sampler2D night_tex ; in vec2 texcoord; in vec4 position ; +uniform float mult ; + float exp1( float x ) { return 2 / (1+exp(-x))-1; } @@ -28,6 +30,6 @@ void main() { mix(texture2D(night_tex,texcoord) * (1-globalAmbient.a), texture2D(texture,texcoord) * vec4(normalize(globalAmbient.xyz),1), (globalAmbient.a + 1) / 2) * 1.8 ; - frag_color = frag_color + mul ; + frag_color = (frag_color + mul)*mult ; } diff --git a/shaders/water.frag b/shaders/water.frag index 6c2aa2b..6e32796 100644 --- a/shaders/water.frag +++ b/shaders/water.frag @@ -12,6 +12,7 @@ uniform sampler2D texture ; uniform sampler2D skytex ; uniform sampler2D skynight ; uniform vec4 lightpos ; +uniform float fog ; in vec3 normal ; in vec4 position ; @@ -79,6 +80,6 @@ void main() { // frag_color = vec4( 0,0,1, 1.0 ); // frag_color = vec4(tex_x,tex_y,0,1.0) ; // vec4 color = sample(0,0); - frag_color = vec4(vec3(refcolor) * vec3(0.6,0.8,1.0),0.95) * vec4(normalize(globalAmbient.xyz),1.0); + frag_color = vec4(vec3(refcolor) * vec3(0.6,0.8,1.0) / (-position.z*fog+1),0.95) * vec4(normalize(globalAmbient.xyz),1.0); // frag_color = vec4(0,0,1,0.8) ; } |