diff options
6 files changed, 25 insertions, 26 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ca82dd9432..ab7f779a39 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,7 +83,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) +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; @@ -115,15 +115,19 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); - col = lit * light_col * diffuse * shadow; + col = lit * light_col * diffuse; float amb_da = ambiance; - amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; - amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; + if (da > 0) + { + amb_da += (da*0.5+0.5) * ambiance; + } + 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 * 0.5 * light_col * diffuse; + // no spec for alpha shader... } col = max(col, vec3(0)); @@ -185,6 +189,7 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); + sunlit *= 0.5; vec2 abnormal = encode_normal(norm.xyz); @@ -228,9 +233,9 @@ vec3 post_diffuse = color.rgb; vec4 light = vec4(0,0,0,0); -vec3 prelight_linearish_maybe = color.rgb; +vec3 prelight_linearish_maybe = srgb_to_linear(color.rgb); - #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 * 0.5, 1.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, light_attenuation[i].w * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 9b07c11361..d14e67fc73 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -83,7 +83,7 @@ uniform vec3 light_direction[8]; uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance, float shadow) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -109,17 +109,16 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation da = dot(n, lv); da = clamp(da, 0.0, 1.0); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + float lit = max(da * dist_atten, 0.0); - // shadowmap is wrong for alpha-blended objs - // since we created shadowmaps for 2 but render N - col = light_col*lit*diffuse*shadow; + col = light_col*lit*diffuse; float amb_da = ambiance; if (da > 0) @@ -148,7 +147,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = lit*scol*light_col.rgb*spec.rgb; - speccol = max(speccol, vec3(0)); + speccol = clamp(speccol, vec3(0), vec3(1)); col += speccol; float cur_glare = max(speccol.r, speccol.g); @@ -372,9 +371,9 @@ vec3 post_spec = col.rgb; vec3 light = vec3(0,0,0); - vec3 prelight_linearish_maybe = col.rgb; + vec3 prelight_linearish_maybe = srgb_to_linear(col.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w * 0.5, 1.0); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 642aff6c41..0a714f0013 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -49,7 +49,7 @@ uniform int sun_up_factor; float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; - stc.z += shadow_bias * bias_mul * 2.0; + stc.z += shadow_bias * bias_mul * 16.0; stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here float cs = shadow2D(shadowMap, stc.xyz).x; float shadow = cs * 4.0; @@ -57,7 +57,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - return shadow * 0.125; + return clamp(shadow * 0.125, 0.0, 1.0); } float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index ff30004ffd..476a1216d3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -151,8 +151,8 @@ vec3 post_diffuse = col.rgb; { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scol*spec.rgb; - speccol = max(speccol, vec3(0)); - bloom = dot (speccol, speccol) / 2; + speccol = clamp(speccol, vec3(0), vec3(1)); + bloom = dot(speccol, speccol) / 2; col += speccol; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index d87b2560ce..6bebb79f31 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -68,7 +68,6 @@ uniform vec2 screen_res; vec3 getNorm(vec2 pos_screen); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); -vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 add, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); @@ -80,8 +79,6 @@ vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); vec4 getPositionWithDepth(vec2 pos_screen, float depth); vec4 getPosition(vec2 pos_screen); -vec3 nothing(); - #ifdef WATER_FOG vec4 applyWaterFogView(vec3 pos, vec4 color); #endif @@ -132,7 +129,7 @@ void main() ambient = max(0.66, ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = min(scol, final_da) * sunlit; + vec3 sun_contrib = scol * final_da * sunlit; col.rgb = amblit; col.rgb *= ambient; @@ -168,7 +165,7 @@ vec3 post_diffuse = col.rgb; { float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scontrib*spec.rgb; - speccol = max(speccol, vec3(0)); + speccol = clamp(speccol, vec3(0), vec3(1)); bloom += dot (speccol, speccol) / 2; col += speccol; } @@ -185,8 +182,6 @@ vec3 post_diffuse = col.rgb; if (norm.w < 1) { - //col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); - //col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col, additive, atten), diffuse.a); col = atmosFragLighting(col, additive, atten); col = scaleSoftClipFrag(col); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 1b1759aeaf..ebfdc38d50 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1009,7 +1009,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); |