aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authorJoshua Rahm <joshua.rahm@colorado.edu>2013-12-10 19:19:26 -0700
committerJoshua Rahm <joshua.rahm@colorado.edu>2013-12-10 19:19:26 -0700
commit010f829485d570afb66c630026504fec63f93cdd (patch)
treed5e42e333178794377c05a99b5bf0c034485bcb6 /shaders
parent7be3bda2b664068bf47404278fa9ee1ce552ea0e (diff)
downloadSonsOfSol-010f829485d570afb66c630026504fec63f93cdd.tar.gz
SonsOfSol-010f829485d570afb66c630026504fec63f93cdd.tar.bz2
SonsOfSol-010f829485d570afb66c630026504fec63f93cdd.zip
Almost finished working commit
Diffstat (limited to 'shaders')
-rw-r--r--shaders/earth.fp36
-rw-r--r--shaders/earth.vp22
-rw-r--r--shaders/moon.fp13
-rw-r--r--shaders/moon.vp11
4 files changed, 82 insertions, 0 deletions
diff --git a/shaders/earth.fp b/shaders/earth.fp
new file mode 100644
index 0000000..c8d6d2a
--- /dev/null
+++ b/shaders/earth.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 );
+}
diff --git a/shaders/earth.vp b/shaders/earth.vp
new file mode 100644
index 0000000..502a970
--- /dev/null
+++ b/shaders/earth.vp
@@ -0,0 +1,22 @@
+/* Light position of Sun */
+uniform vec3 lightPos ;
+
+/* Position of the -x axis */
+uniform vec3 cameraPos ;
+
+varying vec3 fragmentNormal;
+varying vec3 lightVector;
+varying vec3 cameraVector ;
+
+void main() {
+ /* Set the vectors and get the normal */
+ fragmentNormal = gl_Normal;
+ lightVector = lightPos - gl_Vertex.xyz;
+ cameraVector = cameraPos - gl_Vertex.xyz;
+
+ /* Texture */
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
+
+
diff --git a/shaders/moon.fp b/shaders/moon.fp
new file mode 100644
index 0000000..18242d2
--- /dev/null
+++ b/shaders/moon.fp
@@ -0,0 +1,13 @@
+uniform sampler2D tex;
+
+varying vec3 fragmentNormal ;
+varying vec3 lightVector ;
+
+void main() {
+ float f = dot( normalize( fragmentNormal ), normalize( lightVector ) );
+ vec4 color = texture2D( tex, gl_TexCoord[0].xy );
+
+ f = ( 1.0f / (1.0f + exp( -f * 150.0f ) ) ) ;
+
+ gl_FragColor = f * color;
+}
diff --git a/shaders/moon.vp b/shaders/moon.vp
new file mode 100644
index 0000000..11fef10
--- /dev/null
+++ b/shaders/moon.vp
@@ -0,0 +1,11 @@
+uniform vec3 lightPos ;
+
+varying vec3 fragmentNormal ;
+varying vec3 lightVector ;
+
+void main() {
+ fragmentNormal = gl_Normal ;
+ lightVector = lightPos - gl_Vertex.xyz ;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex ;
+}