summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl62
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/skyF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class3/windlight/transportF.glsl25
-rw-r--r--indra/newview/llenvironment.cpp59
-rw-r--r--indra/newview/llenvironment.h3
-rw-r--r--indra/newview/llviewershadermgr.cpp2
7 files changed, 117 insertions, 44 deletions
diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl
index db8ec71b35..fee1a7f311 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl
@@ -22,9 +22,12 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+
+vec3 getAdditiveColor();
+vec3 getAtmosAttenuation();
uniform sampler2D cloudMap;
+uniform vec4 gamma;
uniform vec4 cloud_pos_density1;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
@@ -41,26 +44,29 @@ uniform vec4 glow;
uniform float scene_light_strength;
uniform mat3 ssao_effect_mat;
-vec3 getAdditiveColor();
-vec3 getAtmosAttenuation();
-vec3 getAdditiveColor();
-vec3 getAtmosAttenuation();
-void setPositionEye(vec3);
-vec3 getPositionEye();
-vec3 getSunlitColor();
-vec3 getAmblitColor();
-vec3 getAdditiveColor();
-vec3 getAtmosAttenuation();
-void setPositionEye(vec3 v);
-void setSunlitColor(vec3 v);
-void setAmblitColor(vec3 v);
-void setAdditiveColor(vec3 v);
-void setAtmosAttenuation(vec3 v);
+vec3 scaleFragSoftClip(vec3 light)
+{
+ //soft clip effect:
+ light = 1. - clamp(light, vec3(0.), vec3(1.));
+ light = 1. - pow(light, gamma.xxx);
+ return light;
+}
-void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) {
+vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten)
+{
+ light *= atten.r;
+ light += additive;
+ return (2.0 * light);
+}
+
+vec3 atmosLighting(vec3 light)
+{
+ return atmosFragLighting(light, getAdditiveColor(), getAtmosAttenuation());
+}
+
+void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) {
vec3 P = inPositionEye;
- setPositionEye(P);
vec3 tmpLightnorm = lightnorm.xyz;
@@ -98,7 +104,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) {
temp1 = exp(-temp1 * temp2.z * distance_multiplier);
//final atmosphere attenuation factor
- setAtmosAttenuation(temp1.rgb);
+ atten = temp1.rgb;
//compute haze glow
//(can use temp2.x as temp because we haven't used it yet)
@@ -129,20 +135,14 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor) {
tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
//haze color
- setAdditiveColor(
+ additive =
vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient)
- + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
- + tmpAmbient)));
+ + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
+ + tmpAmbient));
//brightness of surface both sunlight and ambient
- setSunlitColor(vec3(sunlight * .5));
- setAmblitColor(vec3(tmpAmbient * .25));
- setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
+ sunlit = vec3(sunlight * .5);
+ amblit = vec3(tmpAmbient * .25);
+ additive *= vec3(1.0 - temp1);
}
-vec3 atmosLighting(vec3 light)
-{
- light *= getAtmosAttenuation().r;
- light += getAdditiveColor();
- return (2.0 * light);
-}
diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl
index c064023858..3270c243a4 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl
@@ -49,7 +49,7 @@ uniform float distance_multiplier;
uniform float max_y;
uniform vec4 glow;
-void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
+void calcAtmospherics(vec3 inPositionEye) {
vec3 P = inPositionEye;
setPositionEye(P);
@@ -118,7 +118,7 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
* vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
* tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
*/
- tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
+ //tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
//haze color
setAdditiveColor(
diff --git a/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl
index c71eaf4b13..08b6ec3f97 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/skyF.glsl
@@ -49,16 +49,16 @@ void main()
{
vec3 view_direction = normalize(view_dir);
- vec3 camPos = cameraPosLocal;
+ vec3 camPos = cameraPosLocal + vec3(0, 0, 6360.0f);
vec3 transmittance;
vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance);
- radiance *= transmittance;
+ //radiance *= transmittance;
// If the view ray intersects the Sun, add the Sun radiance.
if (dot(view_direction, sun_direction) >= sun_size.y)
{
- radiance = radiance + transmittance * GetSolarLuminance();
+ radiance = radiance + (transmittance * GetSolarLuminance());
}
vec3 color = vec3(1.0) - exp(-radiance);
diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
index 8a8e4cb0f6..82e1d7fe35 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
@@ -33,21 +33,30 @@ vec3 getAtmosAttenuation();
uniform sampler2D cloudMap;
uniform vec4 cloud_pos_density1;
-vec3 atmosTransport(vec3 light) {
- light *= getAtmosAttenuation().r;
- light += getAdditiveColor() * 2.0;
+vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive) {
+ light *= atten.r;
+ light += additive * 2.0;
return light;
}
-vec3 fullbrightAtmosTransport(vec3 light) {
+vec3 fullbrightFragAtmosTransport(vec3 light, vec3 atten, vec3 additive) {
float brightness = dot(light.rgb, vec3(0.33333));
-
- return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness);
+ return mix(atmosFragTransport(light.rgb, atten, additive), light.rgb + additive.rgb, brightness * brightness);
}
-vec3 fullbrightShinyAtmosTransport(vec3 light) {
+vec3 fullbrightFragShinyAtmosTransport(vec3 light, vec3 atten, vec3 additive) {
float brightness = dot(light.rgb, vec3(0.33333));
+ return mix(atmosFragTransport(light.rgb, atten, additive), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
+}
- return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness);
+vec3 atmosTransport(vec3 light) {
+ return atmosFragTransport(light, getAtmosAttenuation(), getAdditiveColor());
}
+vec3 fullbrightAtmosTransport(vec3 light) {
+ return fullbrightFragAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor());
+}
+
+vec3 fullbrightShinyAtmosTransport(vec3 light) {
+ return fullbrightFragShinyAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor());
+}
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index b03367c4dd..a795628e8f 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -54,6 +54,8 @@
#include <boost/make_shared.hpp>
+#include "llatmosphere.h"
+
//define EXPORT_PRESETS 1
//=========================================================================
namespace
@@ -135,6 +137,55 @@ bool LLEnvironment::canEdit() const
return true;
}
+void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky)
+{
+ settingsOut.m_skyBottomRadius = psky->getSkyBottomRadius();
+ settingsOut.m_skyTopRadius = psky->getSkyTopRadius();
+ settingsOut.m_sunArcRadians = psky->getSunArcRadians();
+ settingsOut.m_mieAnisotropy = psky->getMieAnisotropy();
+
+ LLSD rayleigh = psky->getRayleighConfigs();
+ settingsOut.m_rayleighProfile.clear();
+ for (LLSD::array_iterator itf = rayleigh.beginArray(); itf != rayleigh.endArray(); ++itf)
+ {
+ atmosphere::DensityProfileLayer layer;
+ LLSD& layerConfig = (*itf);
+ layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal();
+ layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal();
+ layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal();
+ layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal();
+ layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal();
+ settingsOut.m_rayleighProfile.push_back(layer);
+ }
+
+ LLSD mie = psky->getMieConfigs();
+ settingsOut.m_mieProfile.clear();
+ for (LLSD::array_iterator itf = mie.beginArray(); itf != mie.endArray(); ++itf)
+ {
+ atmosphere::DensityProfileLayer layer;
+ LLSD& layerConfig = (*itf);
+ layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal();
+ layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal();
+ layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal();
+ layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal();
+ layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal();
+ settingsOut.m_mieProfile.push_back(layer);
+ }
+
+ LLSD absorption = psky->getAbsorptionConfigs();
+ settingsOut.m_absorptionProfile.clear();
+ for (LLSD::array_iterator itf = absorption.beginArray(); itf != absorption.endArray(); ++itf)
+ {
+ atmosphere::DensityProfileLayer layer;
+ LLSD& layerConfig = (*itf);
+ layer.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal();
+ layer.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal();
+ layer.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal();
+ layer.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal();
+ layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal();
+ settingsOut.m_absorptionProfile.push_back(layer);
+ }
+}
LLEnvironment::connection_t LLEnvironment::setSkyListChange(const LLEnvironment::change_signal_t::slot_type& cb)
{
@@ -1326,6 +1377,7 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Sec
}
+
void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky)
{
if (mType == TYPE_CYCLED)
@@ -1335,6 +1387,13 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky)
mSky = psky;
mBlenderSky.reset();
+
+ if (gAtmosphere)
+ {
+ AtmosphericModelSettings settings;
+ LLEnvironment::getAtmosphericModelSettings(settings, psky);
+ gAtmosphere->configureAtmosphericModel(settings);
+ }
}
void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater)
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index a7159ca84d..55ade803ac 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -41,6 +41,7 @@
//-------------------------------------------------------------------------
class LLViewerCamera;
class LLGLSLShader;
+class AtmosphericModelSettings;
//-------------------------------------------------------------------------
class LLEnvironment : public LLSingleton<LLEnvironment>
@@ -137,6 +138,8 @@ public:
LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); }
LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); }
+ static void getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky);
+
void update(const LLViewerCamera * cam);
void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 54f48baa97..4db039ace3 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1319,6 +1319,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedAlphaProgram.mFeatures.encodesNormal = true;
gDeferredSkinnedAlphaProgram.mFeatures.calculatesAtmospherics = true;
gDeferredSkinnedAlphaProgram.mFeatures.hasAtmospherics = true;
+ gDeferredSkinnedAlphaProgram.mFeatures.hasTransport = true;
+ gDeferredSkinnedAlphaProgram.mFeatures.hasGamma = true;
gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));