summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl12
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl43
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl15
4 files changed, 55 insertions, 17 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index dac93cee3a..d560a49c1f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -194,8 +194,12 @@ 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 = min(final_da, shadow);
+ final_da = max(final_da, 0.0f);
+ final_da = min(final_da, 1.0f);
+ final_da = pow(final_da, 1.0/1.3);
vec4 color = vec4(0,0,0,0);
@@ -205,9 +209,9 @@ void main()
float ambient = abs(da);
ambient *= 0.5;
ambient *= ambient;
- ambient = 1.0 - ambient;
+ ambient = 1.0 - max(0.9, ambient);
- vec3 sun_contrib = min(da, shadow) * sunlit;
+ vec3 sun_contrib = final_da * 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 c43b5b22bf..d389d975fa 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -302,7 +302,7 @@ void main()
float ambient = abs(da);
ambient *= 0.5;
ambient *= ambient;
- ambient = 1.0 - ambient;
+ ambient = 1.0 - max(0.9, ambient);
float final_da = min(da, shadow);
vec3 sun_contrib = final_da * sunlit;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index 6ff49c7dac..2d2d00cb51 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -46,21 +46,52 @@ 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 cs = shadow2D(shadowMap, stc.xyz).x;
- float shadow = cs * 4.0;
-
+ float shadow = cs;
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.125;
+ return shadow * 0.2;
}
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 7f1d518dd6..0c9dc5da58 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -98,15 +98,18 @@ void main()
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
float da = dot(normalize(norm.xyz), light_dir.xyz);
- da = clamp(da, 0.0, 1.0);
-
- float light_gamma = 1.0/1.3;
- da = pow(da, light_gamma);
vec4 diffuse = texture2DRect(diffuseRect, tc);
scol = max(scol_ambocc.r, diffuse.a);
+ 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);
vec3 col;
float bloom = 0.0;
@@ -123,9 +126,9 @@ void main()
float ambient = abs(da);
ambient *= 0.5;
ambient *= ambient;
- ambient = 1.0 - ambient;
+ ambient = 1.0 - max(0.9, ambient);
- vec3 sun_contrib = min(da,scol) * sunlit;
+ vec3 sun_contrib = final_da * sunlit;
col.rgb = amblit;
col.rgb *= ambient;