aboutsummaryrefslogtreecommitdiff
path: root/data/shaders/lighting.frag
diff options
context:
space:
mode:
Diffstat (limited to 'data/shaders/lighting.frag')
-rw-r--r--data/shaders/lighting.frag23
1 files changed, 11 insertions, 12 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag
index 48c6cf0..bf03dbb 100644
--- a/data/shaders/lighting.frag
+++ b/data/shaders/lighting.frag
@@ -35,12 +35,6 @@ void main() {
vec3 L, E, R;
vec3 tex;
- tex = texture2D(texture, gl_TexCoord[0].st).rgb;
- if ( texture_emits ) {
- gl_FragColor = vec4(tex.r, tex.g, tex.b, alpha);
- return; /* Bail out early in this case */
- }
-
diff = vec3(0.0, 0.0, 0.0);
spec = vec3(0.0, 0.0, 0.0);
@@ -62,7 +56,7 @@ void main() {
spot = pow(spot, gl_LightSource[0].spotExponent);
/* Ambient */
- ambi = col_ambi_diff * (gl_LightModel.ambient.rgb + gl_LightSource[0].ambient*spot*falloff);
+ ambi = col_ambi_diff * (gl_LightModel.ambient.rgb + gl_LightSource[0].ambient.rgb * spot * falloff);
/* Diffuse */
diff_fac = max(0.0, dot(normalize(light0vc).xyz, norm));
@@ -79,10 +73,15 @@ void main() {
/* Light 1: Diffuse background glow */
diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(0.0, dot(vec3(light1vc), norm));
- 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);
-
+ 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);
+ }
+
}