aboutsummaryrefslogtreecommitdiff
path: root/data/shaders/fill-light.frag
diff options
context:
space:
mode:
Diffstat (limited to 'data/shaders/fill-light.frag')
-rw-r--r--data/shaders/fill-light.frag49
1 files changed, 15 insertions, 34 deletions
diff --git a/data/shaders/fill-light.frag b/data/shaders/fill-light.frag
index b9aba4c..6a7044e 100644
--- a/data/shaders/fill-light.frag
+++ b/data/shaders/fill-light.frag
@@ -1,7 +1,7 @@
/*
- * lighting.frag
+ * fill-light.frag
*
- * Lighting calculations
+ * Simplified lighting calculations for the lander craft
*
* (c) 2007-2008 Thomas White <taw27@cam.ac.uk>
*
@@ -18,8 +18,6 @@ uniform sampler2D texture;
uniform sampler2D normalmap;
uniform bool has_normals;
-uniform bool texture_enabled;
-uniform bool texture_emits;
uniform float alpha;
varying vec3 col_ambi_diff;
@@ -27,26 +25,26 @@ varying vec3 col_emit;
void main() {
- vec3 ambi;
- vec3 emit;
- vec3 diff = vec3(0.0, 0.0, 0.0);
- vec3 spec = vec3(0.0, 0.0, 0.0);
- vec3 norm = normal;
+ vec3 ambi, emit, diff, spec;
+ vec3 norm;
float diff_fac, spec_fac;
vec3 L, E, R;
+ vec3 tex;
+
+ tex = texture2D(texture, gl_TexCoord[0].st).rgb;
if ( has_normals ) {
norm += (texture2D(normalmap, gl_TexCoord[0].st).rgb - vec3(0.5, 0.5, 0.5)) / 2.0;
}
- norm = normalize(norm);
+ norm = normalize(normal);
/* Ambient */
ambi = col_ambi_diff * gl_LightModel.ambient.rgb;
/* Emission */
emit = col_emit;
-
+
/* Light 2: Fill-in for lander craft */
L = normalize(gl_LightSource[2].position.xyz - pos);
E = normalize(-pos);
@@ -54,31 +52,14 @@ void main() {
diff_fac = max(0.0, dot(normalize(light2vc).xyz, norm));
spec_fac = max(0.0, dot(R, E));
spec_fac = pow(spec_fac, 80.0);
-
- diff += col_ambi_diff * gl_LightSource[2].diffuse.rgb * diff_fac;
- spec += gl_LightSource[2].specular.rgb * spec_fac;
-
- if ( texture_enabled ) {
- vec3 tex = texture2D(texture, gl_TexCoord[0].st).rgb;
-
- if ( texture_emits ) {
- gl_FragColor = vec4(tex.r, tex.g, tex.b, alpha);
- } else {
- gl_FragColor = vec4(min(tex.r * (ambi.r + diff.r) + spec.r, 1.0),
- min(tex.g * (ambi.g + diff.g) + spec.g, 1.0),
- min(tex.b * (ambi.b + diff.b) + spec.b, 1.0),
- alpha);
- }
+ diff = col_ambi_diff * gl_LightSource[2].diffuse.rgb * diff_fac;
+ spec = gl_LightSource[2].specular.rgb * spec_fac;
- } 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),
- alpha);
-
- }
+ gl_FragColor = vec4(min(tex.r * (ambi.r + diff.r) + spec.r, 1.0),
+ min(tex.g * (ambi.g + diff.g) + spec.g, 1.0),
+ min(tex.b * (ambi.b + diff.b) + spec.b, 1.0),
+ alpha);
}