diff options
author | Graham Linden <graham@lindenlab.com> | 2019-02-06 16:42:23 -0800 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-02-06 16:42:23 -0800 |
commit | 8890c3238ab4ae8bbf1bc123284f9c6d4db4f9d6 (patch) | |
tree | 6d250b8114eb4d39a7c5810813a06d730665372b /indra/newview/app_settings/shaders/class1 | |
parent | f8171a909cb2a18fcca47f6a0317919ece802aef (diff) |
SL-10478
Fix side-effects of having both sun and moon as potential directional light contributors.
We pass an int to the shader indicating which to prefer instead of making per-pixel decisions
and pass the moonlight color/di independently.
Obsolete llsettingssky fade color which was unused elsewhere and cached for no reason.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
6 files changed, 22 insertions, 14 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 53391da9aa..4beb334f5a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -47,6 +47,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -94,7 +96,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index c6c12f80f8..d964ce8eee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -35,6 +35,7 @@ out vec4 frag_data[3]; uniform vec4 color; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; uniform vec3 lumWeights; uniform float moon_brightness; uniform float minLuminance; @@ -57,6 +58,7 @@ void main() vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; c.rgb = pow(c.rgb, exp); + //c.rgb *= moonlight_color.rgb; frag_data[0] = vec4(c.rgb, c.a); frag_data[1] = vec4(0.0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 6c509b7616..39fdd9ec44 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -44,12 +44,13 @@ uniform float spot_shadow_bias; uniform float spot_shadow_offset; uniform mat4 inv_proj; uniform vec2 screen_res; +int sun_up_factor; float pcfShadow(sampler2DShadow shadowMap, 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 * 3.33 * bias_mul; + 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 @@ -85,14 +86,14 @@ float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) { + 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); dp_directional_light = clamp(dp_directional_light, 0.0, 1.0); - vec3 light_dir = (dp_moon > dp_sun) ? moon_dir : sun_dir; - vec3 offset = light_dir * (1.0-dp_directional_light); - vec3 shadow_pos = pos.xyz + (offset * shadow_bias); + vec3 shadow_pos = pos.xyz; float shadow = 0.0f; vec4 spos = vec4(shadow_pos,1.0); @@ -117,7 +118,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, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap3, lpos, 0.5, 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); } @@ -129,7 +130,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, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap2, lpos, 0.75, pos_screen, light_dir)*w; weight += w; } @@ -140,7 +141,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, 1.0, pos_screen, light_dir)*w; + shadow += pcfShadow(shadowMap1, lpos, 0.88, pos_screen, light_dir)*w; weight += w; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 7c02d31d43..83dd9da091 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -39,6 +39,8 @@ uniform vec3 camPosLocal; uniform vec4 lightnorm; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; uniform vec4 ambient; uniform vec4 blue_horizon; uniform vec4 blue_density; @@ -82,7 +84,7 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 67e7604e22..8a98d6a489 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -39,7 +39,6 @@ uniform sampler2D diffuseMap; uniform sampler2D altDiffuseMap; uniform float blend_factor; uniform float custom_alpha; -uniform vec4 sunlight_color; uniform float time; float twinkle(){ diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index b66b56e0fb..947c301110 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -35,6 +35,7 @@ out vec4 frag_color; uniform vec4 color; uniform vec4 sunlight_color; +uniform vec4 moonlight_color; uniform vec3 lumWeights; uniform float moon_brightness; uniform float minLuminance; @@ -45,8 +46,8 @@ VARYING vec2 vary_texcoord0; void main() { - vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); - vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(moonA, moonB, blend_factor); // mix factor which blends when sunlight is brighter @@ -55,8 +56,9 @@ void main() float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights); vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; - c.rgb = pow(c.rgb, exp); + c.rgb = pow(c.rgb, exp); + //c.rgb *= moonlight_color.rgb; - frag_color = vec4(c.rgb, c.a); + frag_color = vec4(c.rgb, c.a); } |