diff options
| author | Josh Rahm <joshua.rahm@colorado.edu> | 2013-12-10 21:20:38 -0700 |
|---|---|---|
| committer | Josh Rahm <joshua.rahm@colorado.edu> | 2013-12-10 21:20:38 -0700 |
| commit | 2e297229c65eeb6ec899a6f77bd333c7abc331e4 (patch) | |
| tree | 8bad8a64812b7e7b25f3f43aac994534993a5b8e | |
| parent | 5b39ce854345509b92fd9aee76d504eaac87aa65 (diff) | |
| download | SonsOfSol-2e297229c65eeb6ec899a6f77bd333c7abc331e4.tar.gz SonsOfSol-2e297229c65eeb6ec899a6f77bd333c7abc331e4.tar.bz2 SonsOfSol-2e297229c65eeb6ec899a6f77bd333c7abc331e4.zip | |
added fallback shader
| -rw-r--r-- | shaders/earth_fallback.fp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/shaders/earth_fallback.fp b/shaders/earth_fallback.fp index c8d6d2a..872d45b 100644 --- a/shaders/earth_fallback.fp +++ b/shaders/earth_fallback.fp @@ -10,27 +10,29 @@ void main() { vec3 fragNormal = normalize( fragmentNormal ) ; - float f = dot( fragNormal, normalize( lightVector ) ); + float light = dot( fragNormal, normalize( lightVector ) ); float c = dot( fragNormal, normalize( cameraVector ) ); c = (c - 0.5) * 2.0 ; - vec4 color = texture2D(tex,gl_TexCoord[0].xy + vec2( 0.5, -0.2 )); + vec4 color = texture2D(tex,gl_TexCoord[0].xy); - float bluef = (1.0f / (1.0f + exp(-f * 150.0f))); - - float bluef2 = (1.0f / (1.0f + exp(c * 20.0f))) * f; - float redf2 = (1.0f / (1.0f + exp(c * 20.0f))) * pow(f,2) * f; + float bluef2 = (1.0f / (1.0f + exp(c * 20.0f))) * light; + float redf2 = (1.0f / (1.0f + exp(c * 20.0f))) * pow(light,2.0) * light; float greenf2 = redf2; - float alpha = (1.0f / (1.0f + exp(c * 30.0f))) * f; - /* Each color has its own drop off rate */ - float greenf = (1.0f / (1.0f + exp(-f * 60.0f))); - float redf = (1.0f / (1.0f + exp(-f * 30.0f))); + + float bluef = pow(light, 3.0) ; + float greenf = pow(light, 2.0) ; + float redf = pow(light, 1.0) ; + + if( bluef < 0.0 ) bluef = 0.0 ; + if( greenf < 0.0 ) greenf = 0.0 ; + if( redf < 0.0 ) redf = 0.0 ; gl_FragColor = vec4( - redf*color[0] + 1000.0*redf2, + redf*color[0] + 1000.0*redf2, greenf*color[1] + 1000.0*greenf2, - bluef*color[2] + 1000.0*bluef2, - 1.0-1000.0*alpha ); + bluef*color[2] + 1000.0*bluef2, + 1.0 ); } |