Merged in graham_linden/viewer-eep-graham (pull request #139)

SL-1289
meow-7.2.2
Rider Linden 2018-10-09 18:02:24 +00:00
commit c2cbb40a0e
12 changed files with 116 additions and 38 deletions

View File

@ -91,6 +91,7 @@ const std::string LLSettingsSky::SETTING_CLOUD_SCALE("cloud_scale");
const std::string LLSettingsSky::SETTING_CLOUD_SCROLL_RATE("cloud_scroll_rate");
const std::string LLSettingsSky::SETTING_CLOUD_SHADOW("cloud_shadow");
const std::string LLSettingsSky::SETTING_CLOUD_TEXTUREID("cloud_id");
const std::string LLSettingsSky::SETTING_CLOUD_VARIANCE("cloud_variance");
const std::string LLSettingsSky::SETTING_DOME_OFFSET("dome_offset");
const std::string LLSettingsSky::SETTING_DOME_RADIUS("dome_radius");
@ -539,6 +540,8 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
validation.push_back(Validator(SETTING_CLOUD_SHADOW, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
validation.push_back(Validator(SETTING_CLOUD_TEXTUREID, false, LLSD::TypeUUID));
validation.push_back(Validator(SETTING_CLOUD_VARIANCE, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
validation.push_back(Validator(SETTING_DOME_OFFSET, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
@ -683,7 +686,8 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position)
dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199);
dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(0.0f)(0.0f);
dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699);
dfltsetting[SETTING_CLOUD_VARIANCE] = LLSD::Real(0.0);
dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f);
dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f);
dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0);
@ -692,7 +696,6 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position)
dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605);
dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue();
dfltsetting[SETTING_MOON_BRIGHTNESS] = LLSD::Real(0.5f);
dfltsetting[SETTING_MOON_TEXTUREID] = GetDefaultMoonTextureId();
dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(256.0000);
dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue();
@ -1431,6 +1434,16 @@ void LLSettingsSky::setCloudShadow(F32 val)
setValue(SETTING_CLOUD_SHADOW, val);
}
F32 LLSettingsSky::getCloudVariance() const
{
return mSettings[SETTING_CLOUD_VARIANCE].asReal();
}
void LLSettingsSky::setCloudVariance(F32 val)
{
setValue(SETTING_CLOUD_VARIANCE, val);
}
F32 LLSettingsSky::getDomeOffset() const
{
//return mSettings[SETTING_DOME_OFFSET].asReal();

View File

@ -57,6 +57,8 @@ public:
static const std::string SETTING_CLOUD_SCROLL_RATE;
static const std::string SETTING_CLOUD_SHADOW;
static const std::string SETTING_CLOUD_TEXTUREID;
static const std::string SETTING_CLOUD_VARIANCE;
static const std::string SETTING_DOME_OFFSET;
static const std::string SETTING_DOME_RADIUS;
static const std::string SETTING_GAMMA;
@ -184,6 +186,9 @@ public:
F32 getCloudShadow() const;
void setCloudShadow(F32 val);
F32 getCloudVariance() const;
void setCloudVariance(F32 val);
F32 getDomeOffset() const;
F32 getDomeRadius() const;

View File

@ -1327,6 +1327,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("halo_map");
mReservedUniforms.push_back("moon_brightness");
mReservedUniforms.push_back("moon_phase");
mReservedUniforms.push_back("cloud_variance");
llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS);

View File

@ -243,6 +243,8 @@ public:
MOON_BRIGHTNESS,
MOON_PHASE,
CLOUD_VARIANCE,
END_RESERVED_UNIFORMS
} eGLSLReservedUniforms;

View File

@ -44,6 +44,8 @@ uniform float blend_factor;
uniform vec4 cloud_pos_density1;
uniform vec4 cloud_pos_density2;
uniform vec4 gamma;
uniform float cloud_scale;
uniform float cloud_variance;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
@ -73,16 +75,19 @@ void main()
vec2 uv3 = vary_texcoord2.xy;
vec2 uv4 = vary_texcoord3.xy;
vec2 disturbance = vec2(cloudNoise(uv1 / 16.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f);
// Offset texture coords
uv1 += cloud_pos_density1.xy; //large texture, visible density
uv1 += cloud_pos_density1.xy + disturbance; //large texture, visible density
uv2 += cloud_pos_density1.xy; //large texture, self shadow
uv3 += cloud_pos_density2.xy; //small texture, visible density
uv3 += cloud_pos_density2.xy + disturbance; //small texture, visible density
uv4 += cloud_pos_density2.xy; //small texture, self shadow
// Compute alpha1, the main cloud opacity
float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z;
alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.);
alpha1 = min(max(alpha1 + cloudDensity, 0.) * (10. + disturbance.y) * cloud_pos_density1.z, 1.);
// And smooth
alpha1 = 1. - alpha1 * alpha1;
@ -96,7 +101,7 @@ void main()
// Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight
float alpha2 = (cloudNoise(uv2).x - 0.5);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * (2.5 + disturbance.x) * cloud_pos_density1.z, 1.);
// And smooth
alpha2 = 1. - alpha2;

View File

@ -36,10 +36,6 @@ out vec4 frag_color;
VARYING vec4 vary_CloudColorSun;
VARYING vec4 vary_CloudColorAmbient;
VARYING float vary_CloudDensity;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
uniform sampler2D cloud_noise_texture;
uniform sampler2D cloud_noise_texture_next;
@ -47,16 +43,23 @@ uniform float blend_factor;
uniform vec4 cloud_pos_density1;
uniform vec4 cloud_pos_density2;
uniform vec4 gamma;
uniform float cloud_scale;
uniform float cloud_variance;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light);
vec4 cloudNoise(vec2 uv)
{
vec4 a = texture2D(cloud_noise_texture, uv);
vec4 b = texture2D(cloud_noise_texture_next, uv);
vec4 samp = mix(a, b, blend_factor);
return samp;
vec4 a = texture2D(cloud_noise_texture, uv);
vec4 b = texture2D(cloud_noise_texture_next, uv);
vec4 cloud_noise_sample = mix(a, b, blend_factor);
return cloud_noise_sample;
}
void main()
@ -71,26 +74,28 @@ void main()
vec2 uv3 = vary_texcoord2.xy;
vec2 uv4 = vary_texcoord3.xy;
vec2 disturbance = vec2(cloudNoise(uv1 / 16.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f);
// Offset texture coords
uv1 += cloud_pos_density1.xy; //large texture, visible density
uv1 += cloud_pos_density1.xy + disturbance; //large texture, visible density
uv2 += cloud_pos_density1.xy; //large texture, self shadow
uv3 += cloud_pos_density2.xy; //small texture, visible density
uv3 += cloud_pos_density2.xy + disturbance; //small texture, visible density
uv4 += cloud_pos_density2.xy; //small texture, self shadow
// Compute alpha1, the main cloud opacity
float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z;
alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.);
alpha1 = min(max(alpha1 + cloudDensity, 0.) * (10. + disturbance.y) * cloud_pos_density1.z, 1.);
// And smooth
alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1;
// Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight
float alpha2 = (cloudNoise(uv2).x - 0.5);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * (2.5 + disturbance.x) * cloud_pos_density1.z, 1.);
// And smooth
alpha2 = 1. - alpha2;

View File

@ -36,10 +36,6 @@ out vec4 frag_color;
VARYING vec4 vary_CloudColorSun;
VARYING vec4 vary_CloudColorAmbient;
VARYING float vary_CloudDensity;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
uniform sampler2D cloud_noise_texture;
uniform sampler2D cloud_noise_texture_next;
@ -47,19 +43,25 @@ uniform float blend_factor;
uniform vec4 cloud_pos_density1;
uniform vec4 cloud_pos_density2;
uniform vec4 gamma;
uniform float cloud_scale;
uniform float cloud_variance;
vec4 cloudNoise(vec2 uv)
{
vec4 a = texture2D(cloud_noise_texture, uv);
vec4 b = texture2D(cloud_noise_texture_next, uv);
vec4 samp = mix(a, b, blend_factor);
return samp;
}
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
VARYING vec2 vary_texcoord2;
VARYING vec2 vary_texcoord3;
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light);
vec4 cloudNoise(vec2 uv)
{
vec4 a = texture2D(cloud_noise_texture, uv);
vec4 b = texture2D(cloud_noise_texture_next, uv);
vec4 cloud_noise_sample = mix(a, b, blend_factor);
return cloud_noise_sample;
}
void main()
{
// Set variables
@ -72,16 +74,19 @@ void main()
vec2 uv3 = vary_texcoord2.xy;
vec2 uv4 = vary_texcoord3.xy;
vec2 disturbance = vec2(cloudNoise(uv1 / 16.0f).x, cloudNoise((uv3 + uv1) / 16.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f);
// Offset texture coords
uv1 += cloud_pos_density1.xy; //large texture, visible density
uv1 += cloud_pos_density1.xy + disturbance; //large texture, visible density
uv2 += cloud_pos_density1.xy; //large texture, self shadow
uv3 += cloud_pos_density2.xy; //small texture, visible density
uv3 += cloud_pos_density2.xy + disturbance; //small texture, visible density
uv4 += cloud_pos_density2.xy; //small texture, self shadow
// Compute alpha1, the main cloud opacity
float alpha1 = (cloudNoise(uv1).x - 0.5) + (cloudNoise(uv3).x - 0.5) * cloud_pos_density2.z;
alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.);
alpha1 = min(max(alpha1 + cloudDensity, 0.) * (10. + disturbance.y) * cloud_pos_density1.z, 1.);
// And smooth
alpha1 = 1. - alpha1 * alpha1;
@ -91,7 +96,7 @@ void main()
// Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight
float alpha2 = (cloudNoise(uv2).x - 0.5);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * (2.5 + disturbance.x) * cloud_pos_density1.z, 1.);
// And smooth
alpha2 = 1. - alpha2;

View File

@ -394,8 +394,13 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh
cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex());
cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext());
F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor();
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f;
F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f;
cloud_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
cloud_shader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance);
/// Render the skydome
renderDome(camPosLocal, camHeightLocal, cloud_shader);

View File

@ -53,6 +53,8 @@ namespace
const std::string FIELD_SKY_CLOUD_COLOR("cloud_color");
const std::string FIELD_SKY_CLOUD_COVERAGE("cloud_coverage");
const std::string FIELD_SKY_CLOUD_SCALE("cloud_scale");
const std::string FIELD_SKY_CLOUD_VARIANCE("cloud_variance");
const std::string FIELD_SKY_CLOUD_SCROLL_XY("cloud_scroll_xy");
const std::string FIELD_SKY_CLOUD_MAP("cloud_map");
const std::string FIELD_SKY_CLOUD_DENSITY_X("cloud_density_x");
@ -254,6 +256,8 @@ BOOL LLPanelSettingsSkyCloudTab::postBuild()
getChild<LLUICtrl>(FIELD_SKY_CLOUD_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudColorChanged(); });
getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudCoverageChanged(); });
getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScaleChanged(); });
getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudVarianceChanged(); });
getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCROLL_XY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScrollChanged(); });
getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudMapChanged(); });
getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setDefaultImageAssetID(LLSettingsSky::GetDefaultCloudNoiseTextureId());
@ -278,6 +282,7 @@ void LLPanelSettingsSkyCloudTab::setEnabled(BOOL enabled)
LLPanelSettingsSky::setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->setEnabled(enabled);
@ -301,6 +306,7 @@ void LLPanelSettingsSkyCloudTab::refresh()
getChild<LLColorSwatchCtrl>(FIELD_SKY_CLOUD_COLOR)->set(mSkySettings->getCloudColor());
getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->setValue(mSkySettings->getCloudShadow());
getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->setValue(mSkySettings->getCloudScale());
getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->setValue(mSkySettings->getCloudVariance());
LLVector2 cloudScroll(mSkySettings->getCloudScrollRate());
getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCROLL_XY)->setValue(cloudScroll.getValue());
@ -339,6 +345,12 @@ void LLPanelSettingsSkyCloudTab::onCloudScaleChanged()
setIsDirty();
}
void LLPanelSettingsSkyCloudTab::onCloudVarianceChanged()
{
mSkySettings->setCloudVariance(getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->getValue().asReal());
setIsDirty();
}
void LLPanelSettingsSkyCloudTab::onCloudScrollChanged()
{
LLVector2 scroll(getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCROLL_XY)->getValue());

View File

@ -95,6 +95,7 @@ private:
void onCloudColorChanged();
void onCloudCoverageChanged();
void onCloudScaleChanged();
void onCloudVarianceChanged();
void onCloudScrollChanged();
void onCloudMapChanged();
void onCloudDensityChanged();

View File

@ -657,10 +657,11 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const
param_map[SETTING_CLOUD_POS_DENSITY2] = LLShaderMgr::CLOUD_POS_DENSITY2;
param_map[SETTING_CLOUD_SCALE] = LLShaderMgr::CLOUD_SCALE;
param_map[SETTING_CLOUD_SHADOW] = LLShaderMgr::CLOUD_SHADOW;
param_map[SETTING_CLOUD_VARIANCE] = LLShaderMgr::CLOUD_VARIANCE;
param_map[SETTING_GLOW] = LLShaderMgr::GLOW;
param_map[SETTING_MAX_Y] = LLShaderMgr::MAX_Y;
param_map[SETTING_SUNLIGHT_COLOR] = LLShaderMgr::SUNLIGHT_COLOR;
param_map[SETTING_MOON_BRIGHTNESS] = LLShaderMgr::MOON_BRIGHTNESS;
param_map[SETTING_SKY_MOISTURE_LEVEL] = LLShaderMgr::MOISTURE_LEVEL;
param_map[SETTING_SKY_DROPLET_RADIUS] = LLShaderMgr::DROPLET_RADIUS;
param_map[SETTING_SKY_ICE_LEVEL] = LLShaderMgr::ICE_LEVEL;

View File

@ -88,6 +88,29 @@
top_delta="20"
width="214"
can_edit_text="true"/>
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="-5"
top_delta="25"
width="200">
Cloud Variance:
</text>
<slider
decimal_digits="2"
follows="left|top"
height="16"
increment="0.01"
initial_value="0"
layout="topleft"
left_delta="5"
min_val="0"
max_val="1.0"
name="cloud_variance"
top_delta="20"
width="214"
can_edit_text="true"/>
<text
follows="left|top"
height="10"
@ -244,4 +267,4 @@
can_edit_text="true"/>
</layout_panel>
</layout_stack>
</panel>
</panel>