diff options
author | Graham Linden <graham@lindenlab.com> | 2019-07-10 14:50:59 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-07-10 14:50:59 -0700 |
commit | 664722168d7016d8bf80a65626bbff542913dc24 (patch) | |
tree | 688a2097614bb99d9e0c982a42db98ea6aed0560 /indra/newview/app_settings/shaders/class1 | |
parent | d23bf2c16e2d36b18c920bbd42f49c47f3c58bd9 (diff) |
SL-1491
Make sun additive contribition depend on facing the sun (without breaking fog).
Put back scaling factor keeping sun contrib from blowing out with new FS param range for glow.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
4 files changed, 18 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 15408b3475..759c49a0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -75,7 +75,7 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive, bool use_ao); #ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -201,6 +201,8 @@ void main() } #else + vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; + float final_alpha = diffuse_linear.a * vertex_color.a; diffuse_srgb.rgb *= vertex_color.rgb; diffuse_linear.rgb *= vertex_color.rgb; @@ -210,11 +212,10 @@ void main() vec3 additive; vec3 atten; - calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); vec2 abnormal = encode_normal(norm.xyz); - vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); da = clamp(da, -1.0, 1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4cbef89fef..38792601f6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -41,7 +41,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); @@ -304,6 +304,8 @@ void main() float envIntensity = final_normal.z; + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + vec3 color = vec3(0.0); float bloom = 0.0; @@ -312,11 +314,10 @@ void main() vec3 additive; vec3 atten; - calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false); vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; float da = dot(normalize(norm.xyz), normalize(light_dir.xyz)); da = clamp(da, -1.0, 1.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 0d180e5798..269b76a19f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -59,7 +59,7 @@ uniform vec2 screen_res; vec3 getNorm(vec2 pos_screen); vec4 getPositionWithDepth(vec2 pos_screen, float depth); -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); float getAmbientClamp(); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); @@ -101,7 +101,7 @@ void main() vec3 additive; vec3 atten; - calcAtmosphericVars(pos.xyz, ambocc, sunlit, amblit, additive, atten, false); + calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, false); float ambient = da; ambient *= 0.5; diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 786a65df0f..3fe3b7afd3 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -47,7 +47,7 @@ float getAmbientClamp() return 1.0f; } -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao) { +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao) { vec3 P = inPositionEye; @@ -103,13 +103,19 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o //compute haze glow //(can use temp2.x as temp because we haven't used it yet) temp2.x = dot(Pn, tmpLightnorm.xyz); + + // dampen sun additive contrib when not facing it... + if (length(light_dir) > 0.01) + { + temp2.x *= max(0.0f, dot(light_dir, Pn)); + } temp2.x = 1. - temp2.x; //temp2.x is 0 at the sun and increases away from sun temp2.x = max(temp2.x, .001); //was glow.y //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) temp2.x *= glow.x; //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); + temp2.x = pow(temp2.x, glow.z * 0.2); //glow.z should be negative, so we're doing a sort of (1 / "angle") function //add "minimum anti-solar illumination" |