diff options
Diffstat (limited to 'indra/newview/app_settings')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 27 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f1b7a1312f..772859576f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -63,7 +63,7 @@ uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; +uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; #ifdef WATER_FOG @@ -79,7 +79,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -91,13 +91,16 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec vec3 col = vec3(0); - if (d > 0.0 && la > 0.0 && fa > 0.0) + if (d > 0.0 && fa > 0.0) { //normalize light vector lv = normalize(lv); - + vec3 norm = normalize(n); + + da = max(0.0, dot(norm, lv)); + //distance attenuation - float dist = d/la; + float dist = d; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; @@ -106,17 +109,17 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 - //angular attenuation - da *= max(dot(n, lv), 0.0); - float lit = max(da * dist_atten,0.0); - col = light_col * lit * diffuse; + float amb_da = (da*da*0.5 + 0.5) * ambiance; + amb_da *= dist_atten; + amb_da = min(amb_da, 1.0f - lit); + col.rgb += amb_da * light_col * diffuse; // no spec for alpha shader... } - - return max(col, vec3(0.0,0.0,0.0)); + col = max(col, vec3(0)); + return col; } void main() @@ -199,7 +202,7 @@ void main() vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl index c66f3f62b2..5bb2020971 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl @@ -57,5 +57,7 @@ void main() frag_data[0] = c; frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); + + gl_FragDepth = 0.9997f; } |