diff options
| author | Rider Linden <rider@lindenlab.com> | 2019-02-04 21:32:57 +0000 | 
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2019-02-04 21:32:57 +0000 | 
| commit | db01f4bb2bce97f76058bbf912cb48c985c3e10a (patch) | |
| tree | d9f92d13b5084964f941e854985413edffc04740 | |
| parent | 0b5c452fd991648f9a5c55eb6865deda5cc1f0a4 (diff) | |
| parent | 9a007cceeffb1b960ba495cd0e3d592698a52a99 (diff) | |
Merged in graham_linden/viewer-eep-fixes (pull request #263)
SL-10459, SL-10461
| -rw-r--r-- | indra/llrender/llrender.cpp | 6 | ||||
| -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 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 8 | 
4 files changed, 25 insertions, 18 deletions
| diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5733a18f47..173444f708 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1151,7 +1151,7 @@ void LLRender::syncLightState()  		LLVector4 position[8];  		LLVector3 direction[8]; -		LLVector3 attenuation[8]; +		LLVector4 attenuation[8];  		LLVector3 diffuse[8];  		for (U32 i = 0; i < 8; i++) @@ -1160,13 +1160,13 @@ void LLRender::syncLightState()  			position[i] = light->mPosition;  			direction[i] = light->mSpotDirection; -			attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]); +            attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]);  			diffuse[i].set(light->mDiffuse.mV);  		}  		shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV);  		shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, 8, direction[0].mV); -		shader->uniform3fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV); +		shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV);  		shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV);  		shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);  		//HACK -- duplicate sunlight color for compatibility with drivers that can't deal with multiple shader objects referencing the same uniform 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;  } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 73e2bd5ec0..82c59282d5 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6482,7 +6482,9 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)  				light_state->setSpotCutoff(90.f);  				light_state->setSpotExponent(2.f); -				const LLColor4 specular(0.f, 0.f, 0.f, 0.f); +                LLVector3 spotParams = light->getSpotLightParams(); + +				const LLColor4 specular(0.f, 0.f, 0.f, spotParams[2]);  				light_state->setSpecular(specular);  			}  			else // omnidirectional (point) light @@ -6491,8 +6493,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)  				light_state->setSpotCutoff(180.f);  				// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight -				const LLColor4 specular(0.f, 0.f, 0.f, 1.f); -				light_state->setSpecular(specular);				 +				const LLColor4 specular(0.f, 0.f, 1.f, 0.f); +				light_state->setSpecular(specular);  			}  			cur_light++;  			if (cur_light >= 8) | 
