aboutsummaryrefslogtreecommitdiff
path: root/data/shaders
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-05-28 17:13:44 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-05-28 17:13:44 +0000
commit838e666fa3293f969042869c3b0fa3177e03d990 (patch)
tree82523517fb5e5eb44028c023628aeb5ae99c260c /data/shaders
parent66450800a7ff01f67ae72a79570decbfbd42c0a8 (diff)
Swirlytron!
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@49 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'data/shaders')
-rw-r--r--data/shaders/lighting.frag30
-rw-r--r--data/shaders/swirlytron.frag14
-rw-r--r--data/shaders/swirlytron.vert4
3 files changed, 36 insertions, 12 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag
index 265f494..4947e98 100644
--- a/data/shaders/lighting.frag
+++ b/data/shaders/lighting.frag
@@ -19,7 +19,7 @@ varying vec3 light2hvc;
uniform sampler2D texture;
uniform bool fill_light_enabled;
uniform bool texture_enabled;
-uniform bool texture_only;
+uniform bool texture_emits;
varying vec3 col_ambi_diff;
varying vec3 col_emit;
@@ -56,18 +56,30 @@ void main() {
spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[2].specular.rgb * pow(ndothv, 80.0);
}
- if ( !texture_only ) {
+ if ( texture_enabled ) {
+
+ vec3 tex = texture2D(texture, gl_TexCoord[0].st).rgb;
+
+ if ( texture_emits ) {
+ gl_FragColor = vec4(min(emit.r + ambi.r + diff.r + spec.r + tex.r, 1.0),
+ min(emit.g + ambi.g + diff.g + spec.g + tex.g, 1.0),
+ min(emit.b + ambi.b + diff.b + spec.b + tex.b, 1.0),
+ 1.0);
+ } else {
+ gl_FragColor = vec4(tex.r * min(emit.r + ambi.r + diff.r + spec.r, 1.0),
+ tex.g * min(emit.g + ambi.g + diff.g + spec.g, 1.0),
+ tex.b * min(emit.b + ambi.b + diff.b + spec.b, 1.0),
+ 1.0);
+ }
+
+ } else {
+
gl_FragColor = vec4(min(emit.r + ambi.r + diff.r + spec.r, 1.0),
min(emit.g + ambi.g + diff.g + spec.g, 1.0),
min(emit.b + ambi.b + diff.b + spec.b, 1.0),
1.0);
- } else {
- gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
- }
-
- if ( texture_enabled ) {
- gl_FragColor *= texture2D(texture, gl_TexCoord[0].st);
+
}
-
+
}
diff --git a/data/shaders/swirlytron.frag b/data/shaders/swirlytron.frag
index d152636..f582aa7 100644
--- a/data/shaders/swirlytron.frag
+++ b/data/shaders/swirlytron.frag
@@ -11,9 +11,21 @@
varying vec2 coords;
+uniform float time;
+
void main() {
- gl_FragColor = vec4(coords.x, 0.0, coords.y, 1.0);
+ vec3 colour;
+ float f;
+
+ f = 1.0 + (0.5*cos(time/1000.0));
+
+ colour.b = 0.2 * abs( cos(2*f*3.141*coords.x + (time/100.0)) );
+ colour.b += 0.5 * abs( cos(2*f*3.141*coords.y + (time/100.0)) );
+ colour.r = 0.1;
+ colour.g = 0.0;
+
+ gl_FragColor = vec4(colour.r, colour.g, colour.b, 1.0);
}
diff --git a/data/shaders/swirlytron.vert b/data/shaders/swirlytron.vert
index 0c6dc73..a15b8a7 100644
--- a/data/shaders/swirlytron.vert
+++ b/data/shaders/swirlytron.vert
@@ -13,8 +13,8 @@ varying vec2 coords;
void main() {
- coords.x = (gl_Vertex.x + 1.0)/2.0;
- coords.y = (gl_Vertex.y + 1.0)/2.0;
+ coords.x = gl_Vertex.x;
+ coords.y = gl_Vertex.y;
/* Coordinates */
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;