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.frag71
1 files changed, 25 insertions, 46 deletions
diff --git a/data/shaders/lighting.frag b/data/shaders/lighting.frag
index 7ec0d3e..39f39fc 100644
--- a/data/shaders/lighting.frag
+++ b/data/shaders/lighting.frag
@@ -37,6 +37,9 @@ void main() {
vec3 diff = vec3(0.0, 0.0, 0.0);
vec3 spec = vec3(0.0, 0.0, 0.0);
vec3 norm = normal;
+ float falloff, spot;
+ float diff_fac, spec_fac;
+ vec3 L, E, R;
if ( has_normals ) {
norm += (texture2D(normalmap, gl_TexCoord[0].st).rgb - vec3(0.5, 0.5, 0.5)) / 2.0;
@@ -49,53 +52,29 @@ void main() {
/* Emission */
emit = col_emit;
-
- if ( fill_light_enabled ) {
-
- float diff_fac, spec_fac;
- vec3 L, E, R;
-
- /* Light 2: Fill-in for lander craft */
- L = normalize(gl_LightSource[2].position.xyz - pos);
- E = normalize(-pos);
- R = normalize(-reflect(L, norm));
- 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;
-
- } else {
- float falloff, spot;
- float diff_fac, spec_fac;
- vec3 L, E, R;
-
- /* Light 0: Lander craft's spotlight */
- falloff = 1.0 / ( gl_LightSource[0].constantAttenuation
- + gl_LightSource[0].linearAttenuation * length(light0vc)
- + gl_LightSource[0].quadraticAttenuation * pow(length(light0vc), 2.0) );
-
- spot = max(dot(normalize(-light0vc), gl_LightSource[0].spotDirection), 0.0);
- spot = pow(spot, gl_LightSource[0].spotExponent);
-
- diff_fac = max(0.0, dot(normalize(light0vc).xyz, norm));
-
- L = normalize(gl_LightSource[0].position.xyz - pos);
- E = normalize(-pos);
- R = normalize(-reflect(L, norm));
- spec_fac = max(0.0, dot(R, E));
- spec_fac = pow(spec_fac, 80.0);
-
- diff += col_ambi_diff * gl_LightSource[0].diffuse.rgb * spot * falloff * diff_fac;
-
- spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * spot * falloff * spec_fac;
-
- /* Light 1: Diffuse background glow */
- diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(0.0, dot(vec3(light1vc), norm));
-
- }
+ /* Light 0: Lander craft's spotlight */
+ falloff = 1.0 / ( gl_LightSource[0].constantAttenuation
+ + gl_LightSource[0].linearAttenuation * length(light0vc)
+ + gl_LightSource[0].quadraticAttenuation * pow(length(light0vc), 2.0) );
+
+ spot = max(dot(normalize(-light0vc), gl_LightSource[0].spotDirection), 0.0);
+ spot = pow(spot, gl_LightSource[0].spotExponent);
+
+ diff_fac = max(0.0, dot(normalize(light0vc).xyz, norm));
+
+ L = normalize(gl_LightSource[0].position.xyz - pos);
+ E = normalize(-pos);
+ R = normalize(-reflect(L, norm));
+ spec_fac = max(0.0, dot(R, E));
+ spec_fac = pow(spec_fac, 80.0);
+
+ diff += col_ambi_diff * gl_LightSource[0].diffuse.rgb * spot * falloff * diff_fac;
+
+ spec += vec3(1.0, 1.0, 1.0) * gl_LightSource[0].specular.rgb * spot * falloff * spec_fac;
+
+ /* Light 1: Diffuse background glow */
+ diff += col_ambi_diff * gl_LightSource[1].diffuse.rgb * max(0.0, dot(vec3(light1vc), norm));
if ( texture_enabled ) {