diff options
| author | Joshua Rahm <joshua.rahm@colorado.edu> | 2013-12-10 21:19:37 -0700 |
|---|---|---|
| committer | Joshua Rahm <joshua.rahm@colorado.edu> | 2013-12-10 21:19:37 -0700 |
| commit | 5b39ce854345509b92fd9aee76d504eaac87aa65 (patch) | |
| tree | cf3f191fe65f1b248fe21be8c8db12360c8400c3 /shaders | |
| parent | 80199c0ef697c6b2d8309c2dcf2e4e466f528d13 (diff) | |
| download | SonsOfSol-5b39ce854345509b92fd9aee76d504eaac87aa65.tar.gz SonsOfSol-5b39ce854345509b92fd9aee76d504eaac87aa65.tar.bz2 SonsOfSol-5b39ce854345509b92fd9aee76d504eaac87aa65.zip | |
added fallback shader
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/earth_fallback.fp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/shaders/earth_fallback.fp b/shaders/earth_fallback.fp new file mode 100644 index 0000000..c8d6d2a --- /dev/null +++ b/shaders/earth_fallback.fp @@ -0,0 +1,36 @@ +// Set the fragment color + +uniform sampler2D tex; + +varying vec3 fragmentNormal ; +varying vec3 lightVector ; +varying vec3 cameraVector ; + +void main() +{ + vec3 fragNormal = normalize( fragmentNormal ) ; + + float f = 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 )); + + 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 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))); + + gl_FragColor = vec4( + redf*color[0] + 1000.0*redf2, + greenf*color[1] + 1000.0*greenf2, + bluef*color[2] + 1000.0*bluef2, + 1.0-1000.0*alpha ); +} |