diff options
Diffstat (limited to 'indra')
26 files changed, 92 insertions, 45 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 612c97168c..2a503664ad 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1238,12 +1238,6 @@ LLVector3 LLSettingsSky::getMoonDirection() const return mMoonDirection; } -LLColor4U LLSettingsSky::getFadeColor() const -{ - update(); - return mFadeColor; -} - LLColor4 LLSettingsSky::getMoonAmbient() const { update(); @@ -1305,12 +1299,9 @@ void LLSettingsSky::calculateLightSettings() const mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance)); mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5); - mMoonDiffuse = gammaCorrect(componentMult(LLColor3::white, light_transmittance)); - mMoonAmbient = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.5f); + mMoonDiffuse = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.5f); + mMoonAmbient = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.25f); mTotalAmbient = mSunAmbient; - - mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f; - mFadeColor.setAlpha(0); } LLUUID LLSettingsSky::GetDefaultAssetId() diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 65c0f2c581..cd173a6b18 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -280,7 +280,7 @@ public: LLVector3 getSunDirection() const; LLVector3 getMoonDirection() const; - LLColor4U getFadeColor() const; + LLColor4 getMoonAmbient() const; LLColor3 getMoonDiffuse() const; LLColor4 getSunAmbient() const; @@ -347,7 +347,6 @@ private: static const F32 DOME_RADIUS; static const F32 DOME_OFFSET; - mutable LLColor4U mFadeColor; mutable LLColor4 mMoonAmbient; mutable LLColor3 mMoonDiffuse; mutable LLColor4 mSunAmbient; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 173444f708..6e15f52866 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -895,6 +895,15 @@ void LLLightState::setDiffuse(const LLColor4& diffuse) } } +void LLLightState::setDiffuseB(const LLColor4& diffuse) +{ + if (mDiffuseB != diffuse) + { + ++gGL.mLightHash; + mDiffuseB = diffuse; + } +} + void LLLightState::setAmbient(const LLColor4& ambient) { if (mAmbient != ambient) @@ -1153,6 +1162,7 @@ void LLRender::syncLightState() LLVector3 direction[8]; LLVector4 attenuation[8]; LLVector3 diffuse[8]; + LLVector3 diffuseB[8]; for (U32 i = 0; i < 8; i++) { @@ -1162,6 +1172,7 @@ void LLRender::syncLightState() direction[i] = light->mSpotDirection; attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]); diffuse[i].set(light->mDiffuse.mV); + diffuseB[i].set(light->mDiffuseB.mV); } shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV); @@ -1169,8 +1180,8 @@ void LLRender::syncLightState() shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV); shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); - //HACK -- duplicate sunlight color for compatibility with drivers that can't deal with multiple shader objects referencing the same uniform shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuseB[0].mV); } } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index a79db80ebe..012a8da4ce 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -229,6 +229,7 @@ public: void enable(); void disable(); void setDiffuse(const LLColor4& diffuse); + void setDiffuseB(const LLColor4& diffuse); void setAmbient(const LLColor4& ambient); void setSpecular(const LLColor4& specular); void setPosition(const LLVector4& position); @@ -245,6 +246,7 @@ protected: S32 mIndex; bool mEnabled; LLColor4 mDiffuse; + LLColor4 mDiffuseB; LLColor4 mAmbient; LLColor4 mSpecular; LLVector4 mPosition; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 3989c1e2e4..11e84d8785 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1352,6 +1352,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("sun_moon_glow_factor"); mReservedUniforms.push_back("water_edge"); + mReservedUniforms.push_back("sun_up_factor"); + mReservedUniforms.push_back("moonlight_color"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index ef6f33f2e5..497c3eb231 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -250,6 +250,8 @@ public: SUN_MOON_GLOW_FACTOR, WATER_EDGE_FACTOR, + SUN_UP_FACTOR, + MOONLIGHT_COLOR, END_RESERVED_UNIFORMS } eGLSLReservedUniforms; 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); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl index 7e2d41cf7b..26f8095dc1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -34,6 +34,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; @@ -112,7 +114,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/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 2c1cc3026f..9a159e57f0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -57,6 +57,8 @@ uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; +uniform int sun_up_factor; + VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; @@ -91,7 +93,8 @@ void main() float da_sun = dot(norm.xyz, normalize(sun_dir.xyz)); float da_moon = dot(norm.xyz, normalize(moon_dir.xyz)); - float da = (da_sun > 0.0) ? da_sun : da_moon; + 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); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 683ab794d3..efcf848ab1 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -29,6 +29,8 @@ vec3 getAtmosAttenuation(); uniform vec4 gamma; 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; @@ -75,7 +77,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl index 86cdae8768..a26752f741 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl @@ -44,6 +44,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; @@ -74,7 +76,7 @@ void calcAtmospherics(vec3 inPositionEye) { vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index 3e3bd929e1..fb978691da 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -46,6 +46,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; @@ -93,7 +95,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/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index f9f1eb7355..a65cc09c73 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/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; // Sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl index 95d5b52b45..c0ba804a30 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudShadowF.glsl @@ -44,7 +44,6 @@ uniform sampler2D cloud_noise_texture_next; uniform float blend_factor; uniform vec4 cloud_pos_density1; uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; uniform vec4 cloud_color; uniform float cloud_shadow; uniform float cloud_scale; diff --git a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl index c111456782..cc7a86f35c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/cloudsF.glsl @@ -47,7 +47,6 @@ uniform sampler2D cloud_noise_texture_next; uniform float blend_factor; uniform vec4 cloud_pos_density1; uniform vec4 cloud_pos_density2; -uniform vec4 sunlight_color; uniform vec4 cloud_color; uniform float cloud_shadow; uniform float cloud_scale; diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl index a1b67fc31e..852c2478bc 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl @@ -29,6 +29,8 @@ vec3 getAtmosAttenuation(); uniform vec4 gamma; 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; @@ -69,7 +71,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl index 3270c243a4..9bd75cf118 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl @@ -38,6 +38,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; @@ -63,7 +65,7 @@ void calcAtmospherics(vec3 inPositionEye) { vec3 temp2 = vec3(0); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = sunlight_color; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; //sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index e716214d72..ba2b00ee4e 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -48,6 +48,7 @@ #include "pipeline.h" #include "llviewershadermgr.h" #include "llrender.h" +#include "llenvironment.h" const F32 DETAIL_SCALE = 1.f/16.f; int DebugDetailMap = 0; @@ -259,6 +260,9 @@ void LLDrawPoolTerrain::beginShadowPass(S32 pass) LLFacePool::beginRenderPass(pass); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gDeferredShadowProgram.bind(); + + LLEnvironment& environment = LLEnvironment::instance(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } void LLDrawPoolTerrain::endShadowPass(S32 pass) diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 81b0c8b1bb..aa8812ab9d 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -38,6 +38,7 @@ #include "llrender.h" #include "llviewercontrol.h" #include "llviewerregion.h" +#include "llenvironment.h" S32 LLDrawPoolTree::sDiffTex = 0; static LLGLSLShader* shader = NULL; @@ -178,7 +179,10 @@ void LLDrawPoolTree::beginShadowPass(S32 pass) glPolygonOffset(gSavedSettings.getF32("RenderDeferredTreeShadowOffset"), gSavedSettings.getF32("RenderDeferredTreeShadowBias")); + LLEnvironment& environment = LLEnvironment::instance(); + gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); gDeferredTreeShadowProgram.setMinimumAlpha(0.5f); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index acf2a6ea6e..313e74d5cd 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -701,6 +701,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() F32 moon_brightness = (float)psky->getMoonBrightness(); moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness); + moon_shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, gSky.mVOSkyp->getMoon().getColor().mV); moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 82c59282d5..49b39eb067 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6351,9 +6351,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) gGL.setAmbientLightColor(ambient); } - bool sun_up = environment.getIsSunUp(); - bool moon_up = environment.getIsMoonUp(); - bool sun_is_primary = sun_up || !moon_up; + bool sun_up = environment.getIsSunUp(); // Light 0 = Sun or Moon (All objects) { @@ -6379,15 +6377,15 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) } mMoonDiffuse.clamp(); - LLColor4 light_diffuse = sun_is_primary ? mSunDiffuse : mMoonDiffuse; - LLVector4 light_dir = sun_is_primary ? mSunDir : mMoonDir; + LLVector4 light_dir = sun_up ? mSunDir : mMoonDir; - mHWLightColors[0] = light_diffuse; + mHWLightColors[0] = mSunDiffuse; LLLightState* light = gGL.getLight(0); light->setPosition(light_dir); - light->setDiffuse(light_diffuse); + light->setDiffuse(mSunDiffuse); + light->setDiffuseB(mMoonDiffuse); light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); light->setConstantAttenuation(1.f); @@ -8757,6 +8755,10 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS); bindDeferredShader(soften_shader); + + LLEnvironment& environment = LLEnvironment::instance(); + soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + { LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -9870,6 +9872,8 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera stop_glerror(); + LLEnvironment& environment = LLEnvironment::instance(); + LLVertexBuffer::unbind(); { @@ -9880,6 +9884,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera else { gDeferredShadowProgram.bind(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } gGL.diffuseColor4f(1,1,1,1); @@ -9911,6 +9916,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowProgram.unbind(); renderGeomShadow(shadow_cam); gDeferredShadowProgram.bind(); + gDeferredShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); } else { @@ -9921,6 +9927,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA); gDeferredShadowAlphaMaskProgram.bind(); gDeferredShadowAlphaMaskProgram.uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width); + gDeferredShadowAlphaMaskProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | @@ -9935,6 +9942,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera mask = mask & ~LLVertexBuffer::MAP_TEXTURE_INDEX; gDeferredTreeShadowProgram.bind(); + gDeferredTreeShadowProgram.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); renderMaskedObjects(LLRenderPass::PASS_NORMSPEC_MASK, mask); renderMaskedObjects(LLRenderPass::PASS_MATERIAL_ALPHA_MASK, mask); renderMaskedObjects(LLRenderPass::PASS_SPECMAP_MASK, mask); |