summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-04-05 09:19:46 -0700
committerGraham Linden <graham@lindenlab.com>2019-04-05 09:19:46 -0700
commit09bb0336f15027e907fbd28130b4ffda28a830cd (patch)
treeff3e06f294b954484c7eca8c396ab396085c398e /indra/newview
parentfa6f770a895d663266df5907ff13c2676e6ce8ad (diff)
SL-10854 part 2
Clamp ambient to keep shadows dark. Apply min with shadow value after we've pow'd by light gamma consistently between forward and deferred.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl40
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl10
4 files changed, 19 insertions, 52 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index d560a49c1f..1bc576a4ec 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -196,9 +196,7 @@ void main()
float da = dot(norm.xyz, light_dir.xyz);
float final_da = da;
- final_da = min(final_da, shadow);
- final_da = max(final_da, 0.0f);
- final_da = min(final_da, 1.0f);
+ final_da = clamp(final_da, 0.0f, 1.0f);
final_da = pow(final_da, 1.0/1.3);
vec4 color = vec4(0,0,0,0);
@@ -209,9 +207,10 @@ void main()
float ambient = abs(da);
ambient *= 0.5;
ambient *= ambient;
- ambient = 1.0 - max(0.9, ambient);
+ ambient = max(0.9, ambient); // keeps shadows dark
+ ambient = 1.0 - ambient;
- vec3 sun_contrib = final_da * sunlit;
+ vec3 sun_contrib = min(final_da, shadow) * sunlit;
color.rgb *= ambient;
color.rgb += sun_contrib;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index d389d975fa..4e24e61018 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -296,16 +296,18 @@ void main()
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
float da = dot(norm.xyz, light_dir.xyz);
- da = clamp(da, 0.0, 1.0);
- da = pow(da, 1.0 / 1.3);
+
+ float final_da = da;
+ final_da = clamp(final_da, 0.0, 1.0);
+ final_da = pow(final_da, 1.0 / 1.3);
float ambient = abs(da);
ambient *= 0.5;
ambient *= ambient;
- ambient = 1.0 - max(0.9, ambient);
+ ambient = max(0.9, ambient);
+ ambient = 1.0 - ambient;
- float final_da = min(da, shadow);
- vec3 sun_contrib = final_da * sunlit;
+ vec3 sun_contrib = min(final_da, shadow) * sunlit;
col.rgb = amblit;
col.rgb *= ambient;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index 2d2d00cb51..642aff6c41 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -46,52 +46,18 @@ uniform mat4 inv_proj;
uniform vec2 screen_res;
uniform int sun_up_factor;
-const float sample_count = 5;
-
-float cGoldenAngle = 2.39996323f;
-
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 * 4.0;
-
- float shadow = 0.0;
- float cs = shadow2D(shadowMap, stc.xyz).x;
- float initialTheta = cGoldenAngle*fract((pos_screen.y+pos_screen.x)*shadow_res.y);
- float theta = initialTheta;
- int i;
- for (i = 0; i < sample_count; i++)
- {
- float r = float(i) / float(sample_count);
- float weight = sqrt(1.0 - r);
- r = sqrt(r);
- vec2 sampleOffset;
- sampleOffset.x = cos(theta);
- sampleOffset.y = sin(theta);
- sampleOffset *= r * 2.0;
- float s = shadow2D(shadowMap, stc.xyz + vec3(sampleOffset, 0)).x;
- shadow += weight * s;
- theta += cGoldenAngle;
- }
- shadow /= float(sample_count);
- shadow += cs;
- shadow *= 0.5;
- return shadow;
-}
-
-float pcfShadowOld(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)
-{
- stc.xyz /= stc.w;
-
- float cs = shadow2D(shadowMap, stc.xyz).x;
stc.z += shadow_bias * bias_mul * 2.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 shadow = cs;
+ float cs = shadow2D(shadowMap, stc.xyz).x;
+ float shadow = cs * 4.0;
shadow += shadow2D(shadowMap, stc.xyz+vec3(2.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(-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.2;
+ return shadow * 0.125;
}
float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen)
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 0c9dc5da58..92888e0fd2 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -94,6 +94,7 @@ void main()
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
+ float light_gamma = 1.0/1.3;
float scol = 1.0;
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
@@ -102,12 +103,10 @@ void main()
vec4 diffuse = texture2DRect(diffuseRect, tc);
scol = max(scol_ambocc.r, diffuse.a);
+ //scol = pow(scol, light_gamma);
float final_da = da;
- final_da = min(final_da, scol);
final_da = clamp(final_da, 0.0, 1.0);
-
- float light_gamma = 1.0/1.3;
final_da = pow(final_da, light_gamma);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
@@ -126,9 +125,10 @@ void main()
float ambient = abs(da);
ambient *= 0.5;
ambient *= ambient;
- ambient = 1.0 - max(0.9, ambient);
+ ambient = max(0.9, ambient);
+ ambient = 1.0 - ambient;
- vec3 sun_contrib = final_da * sunlit;
+ vec3 sun_contrib = min(scol, final_da) * sunlit;
col.rgb = amblit;
col.rgb *= ambient;