diff options
| author | Graham Linden <graham@lindenlab.com> | 2019-02-04 12:56:11 -0800 | 
|---|---|---|
| committer | Graham Linden <graham@lindenlab.com> | 2019-02-04 12:56:11 -0800 | 
| commit | 9a007cceeffb1b960ba495cd0e3d592698a52a99 (patch) | |
| tree | 07cb157b13f93d3a390fd566852633c240f90a0c /indra/newview/app_settings/shaders/class1/deferred | |
| parent | 1d1fcb451cc99b5ee2efbe1fdf38a0607233a2d8 (diff) | |
SL-10461
Pass projector ambiance as the .w element of the light_attenuation uniform
so that alpha shader can emulate the behavior of proper spot projectors.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 27 | 
1 files changed, 15 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) | 
