summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl38
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl15
-rw-r--r--indra/newview/pipeline.cpp45
3 files changed, 36 insertions, 62 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index 39fdd9ec44..e762871ba1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -39,20 +39,18 @@ uniform vec2 proj_shadow_res;
uniform mat4 shadow_matrix[6];
uniform vec4 shadow_clip;
uniform float shadow_bias;
-
+uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
uniform mat4 inv_proj;
uniform vec2 screen_res;
-int sun_up_factor;
+uniform int sun_up_factor;
-float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)
+float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)
{
stc.xyz /= stc.w;
- float offset = max(0.75, light_dir.z);
- stc.z += offset * shadow_bias * bias_mul;
-
- stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*3.14159))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
+ stc.z += shadow_bias * bias_mul* 2.0;
+ stc.x = floor(stc.x*shadow_res.x + fract(stc.y*pos_screen.y*pos_screen.x))/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;
@@ -62,7 +60,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float bias_mul, vec2 pos_sc
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.125;
}
float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen)
@@ -86,23 +84,18 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
{
+ float shadow = 0.0f;
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
float dp_sun = max(0.0, dot(sun_dir.xyz, norm));
float dp_moon = max(0.0, dot(moon_dir.xyz, norm));
- float dp_directional_light = max(dp_sun,dp_moon);
+ float dp_directional_light = (sun_up_factor == 1) ? dp_sun : dp_moon;
dp_directional_light = clamp(dp_directional_light, 0.0, 1.0);
vec3 shadow_pos = pos.xyz;
-
- float shadow = 0.0f;
- vec4 spos = vec4(shadow_pos,1.0);
-
- // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup
- if (dp_directional_light <= 0.0)
- {
- return 0.0;
- }
+ vec3 offset = abs(light_dir.xyz) * (1.0 - dp_directional_light* 0.8);
+ shadow_pos += offset;
+ vec4 spos = vec4(shadow_pos.xyz, 1.0);
if (spos.z > -shadow_clip.w)
{
@@ -118,7 +111,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
- shadow += pcfShadow(shadowMap3, lpos, 0.5, pos_screen, light_dir)*w;
+ shadow += pcfShadow(shadowMap3, norm, lpos, 4.0, pos_screen, light_dir)*w;
weight += w;
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
}
@@ -130,7 +123,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
- shadow += pcfShadow(shadowMap2, lpos, 0.75, pos_screen, light_dir)*w;
+ shadow += pcfShadow(shadowMap2, norm, lpos, 2.0, pos_screen, light_dir)*w;
weight += w;
}
@@ -141,7 +134,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
- shadow += pcfShadow(shadowMap1, lpos, 0.88, pos_screen, light_dir)*w;
+ shadow += pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w;
weight += w;
}
@@ -152,14 +145,13 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)
float w = 1.0;
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
- shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen, light_dir)*w;
+ shadow += pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w;
weight += w;
}
shadow /= weight;
}
- shadow = min(dp_directional_light, shadow);
return shadow;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 9a159e57f0..8bc9add5cf 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -91,10 +91,9 @@ void main()
float envIntensity = norm.z;
norm.xyz = getNorm(tc); // unpack norm
- float da_sun = dot(norm.xyz, normalize(sun_dir.xyz));
- float da_moon = dot(norm.xyz, normalize(moon_dir.xyz));
+ float da_sun = dot(norm.xyz, sun_dir.xyz);
+ float da_moon = dot(norm.xyz, moon_dir.xyz);
float da = (sun_up_factor == 1) ? da_sun : da_moon;
- //float da = (da_sun > 0.0) ? da_sun : da_moon;
da = clamp(da, 0.0, 1.0);
da = pow(da, global_gamma + 0.3);
@@ -109,7 +108,7 @@ void main()
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
scol_ambocc = pow(scol_ambocc, vec2(global_gamma + 0.3));
- float scol = max(scol_ambocc.r, diffuse.a);
+ float scol = max(scol_ambocc.r, diffuse.a);
float ambocc = scol_ambocc.g;
vec3 sunlit;
@@ -119,7 +118,8 @@ void main()
calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten);
- float ambient = dot(norm.xyz, sun_dir.xyz);
+ float ambient = da;
+
ambient *= 0.5;
ambient *= ambient;
ambient = (1.0-ambient);
@@ -127,7 +127,7 @@ void main()
col.rgb = amblit;
col.rgb *= min(ambient, max(scol, 0.5));
- col += (sunlit * da) * scol;
+ col += sunlit * da * scol;
col *= diffuse.rgb;
@@ -165,6 +165,9 @@ void main()
col = fogged.rgb;
bloom = fogged.a;
#endif
+
+//col.rgb = vec3(scol);
+//col.rgb = vec3(da * scol);
}
frag_color.rgb = col;
frag_color.a = bloom;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 49b39eb067..0898b0d53d 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6075,9 +6075,7 @@ void LLPipeline::setupAvatarLights(bool for_edit)
LLEnvironment& environment = LLEnvironment::instance();
LLSettingsSky::ptr_t psky = environment.getCurrentSky();
- bool sun_up = environment.getIsSunUp();
- bool moon_up = environment.getIsMoonUp();
- bool sun_is_primary = sun_up || !moon_up;
+ bool sun_up = environment.getIsSunUp();
if (for_edit)
{
@@ -6113,13 +6111,13 @@ void LLPipeline::setupAvatarLights(bool for_edit)
}
else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini)
{
- LLVector3 light_dir = sun_is_primary ? LLVector3(mSunDir) : LLVector3(mMoonDir);
+ LLVector3 light_dir = sun_up ? LLVector3(mSunDir) : LLVector3(mMoonDir);
LLVector3 opposite_pos = -light_dir;
LLVector3 orthog_light_pos = light_dir % LLVector3::z_axis;
LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f);
backlight_pos.normalize();
- LLColor4 light_diffuse = sun_is_primary ? mSunDiffuse : mMoonDiffuse;
+ LLColor4 light_diffuse = sun_up ? mSunDiffuse : mMoonDiffuse;
LLColor4 backlight_diffuse(1.f - light_diffuse.mV[VRED], 1.f - light_diffuse.mV[VGREEN], 1.f - light_diffuse.mV[VBLUE], 1.f);
F32 max_component = 0.001f;
@@ -6377,7 +6375,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
}
mMoonDiffuse.clamp();
- LLVector4 light_dir = sun_up ? mSunDir : mMoonDir;
+ LLVector4 light_dir = sun_up ? mSunDir : mMoonDir;
mHWLightColors[0] = mSunDiffuse;
@@ -8594,32 +8592,14 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
vert[1].set(-1,-3,0);
vert[2].set(3,1,0);
- const LLEnvironment& environment = LLEnvironment::instance();
-
- bool sun_up = environment.getIsSunUp();
- bool moon_up = environment.getIsMoonUp();
-
- {
- setupHWLights(NULL); //to set mSun/MoonDir;
- glh::vec4f tc(mSunDir.mV);
- mat.mult_matrix_vec(tc);
+ setupHWLights(NULL); //to set mSun/MoonDir;
- glh::vec4f tc_moon(mMoonDir.mV);
- mTransformedMoonDir.set(tc_moon.v);
- mTransformedMoonDir.normalize();
+ glh::vec4f tc(mSunDir.mV);
+ mat.mult_matrix_vec(tc);
+ mTransformedSunDir.set(tc.v);
- bool sun_is_primary = sun_up || !moon_up;
- if (sun_is_primary)
- {
- mTransformedSunDir.set(tc.v);
- mTransformedSunDir.normalize();
- }
- else
- {
- mTransformedSunDir.set(tc_moon.v);
- mTransformedSunDir.normalize();
- }
- }
+ glh::vec4f tc_moon(mMoonDir.mV);
+ mTransformedMoonDir.set(tc_moon.v);
gGL.pushMatrix();
gGL.loadIdentity();
@@ -10633,9 +10613,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
bool sun_up = environment.getIsSunUp();
bool moon_up = environment.getIsMoonUp();
- bool sun_is_primary = sun_up || !moon_up;
- bool ignore_shadows = (sun_is_primary && (mSunDiffuse == LLColor4::black))
- || (moon_up && (mMoonDiffuse == LLColor4::black))
+ bool ignore_shadows = (sun_up && (mSunDiffuse == LLColor4::black))
+ || (moon_up && (mMoonDiffuse == LLColor4::black))
|| !(sun_up || moon_up);
if (ignore_shadows)