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

SL-9751 and SL-9709
meow-7.2.2
Rider Linden 2018-10-09 16:33:59 +00:00
commit 0a4ddfffdc
14 changed files with 206 additions and 37 deletions

View File

@ -102,6 +102,8 @@ const std::string LLSettingsSky::SETTING_MAX_Y("max_y");
const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation");
const std::string LLSettingsSky::SETTING_MOON_SCALE("moon_scale");
const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id");
const std::string LLSettingsSky::SETTING_MOON_BRIGHTNESS("moon_brightness");
const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness");
const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color");
const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation");
@ -555,6 +557,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
validation.push_back(Validator(SETTING_MOON_SCALE, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.25f)(20.0f))), LLSD::Real(1.0)));
validation.push_back(Validator(SETTING_MOON_TEXTUREID, false, LLSD::TypeUUID));
validation.push_back(Validator(SETTING_MOON_BRIGHTNESS, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
validation.push_back(Validator(SETTING_STAR_BRIGHTNESS, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(500.0f)))));
validation.push_back(Validator(SETTING_SUNLIGHT_COLOR, true, LLSD::TypeArray,
@ -686,6 +691,9 @@ 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();
dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue();
@ -1496,6 +1504,16 @@ void LLSettingsSky::setMoonTextureId(LLUUID id)
setValue(SETTING_MOON_TEXTUREID, id);
}
F32 LLSettingsSky::getMoonBrightness() const
{
return mSettings[SETTING_MOON_BRIGHTNESS].asReal();
}
void LLSettingsSky::setMoonBrightness(F32 brightness_factor)
{
setValue(SETTING_MOON_BRIGHTNESS, brightness_factor);
}
F32 LLSettingsSky::getStarBrightness() const
{
return mSettings[SETTING_STAR_BRIGHTNESS].asReal();

View File

@ -66,6 +66,8 @@ public:
static const std::string SETTING_MOON_ROTATION;
static const std::string SETTING_MOON_SCALE;
static const std::string SETTING_MOON_TEXTUREID;
static const std::string SETTING_MOON_BRIGHTNESS;
static const std::string SETTING_STAR_BRIGHTNESS;
static const std::string SETTING_SUNLIGHT_COLOR;
static const std::string SETTING_SUN_ROTATION;
@ -205,6 +207,9 @@ public:
LLUUID getMoonTextureId() const;
void setMoonTextureId(LLUUID id);
F32 getMoonBrightness() const;
void setMoonBrightness(F32 brightness_factor);
F32 getStarBrightness() const;
void setStarBrightness(F32 val);

View File

@ -1325,6 +1325,8 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("ice_level");
mReservedUniforms.push_back("rainbow_map");
mReservedUniforms.push_back("halo_map");
mReservedUniforms.push_back("moon_brightness");
mReservedUniforms.push_back("moon_phase");
llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS);

View File

@ -239,6 +239,10 @@ public:
ICE_LEVEL,
RAINBOW_MAP,
HALO_MAP,
MOON_BRIGHTNESS,
MOON_PHASE,
END_RESERVED_UNIFORMS
} eGLSLReservedUniforms;

View File

@ -39,6 +39,7 @@ vec3 fullbrightScaleSoftClip(vec3 light);
uniform vec4 color;
uniform vec4 sunlight_color;
uniform vec3 lumWeights;
uniform float moon_brightness;
uniform float minLuminance;
uniform sampler2D diffuseMap;
uniform sampler2D altDiffuseMap;
@ -51,15 +52,23 @@ void main()
vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy);
vec4 c = mix(moonA, moonB, blend_factor);
if (c.a < 0.1f)
{
discard;
}
c.rgb = pow(c.rgb, vec3(0.7f));
c.rgb = fullbrightAtmosTransport(c.rgb);
c.rgb = fullbrightScaleSoftClip(c.rgb);
// mix factor which blends when sunlight is brighter
// and shows true moon color at night
vec3 luma_weights = vec3(0.1, 0.3, 0.0);
float mix = 1.0f - dot(sunlight_color.rgb, luma_weights);
frag_data[0] = vec4(c.rgb, mix * c.a);
vec3 luma_weights = vec3(0.2, 0.3, 0.2);
float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights);
c.rgb = pow(c.rgb, 1.2 - vec3(mix * moon_brightness));
frag_data[0] = vec4(c.rgb, mix * (moon_brightness + (c.a * 0.25)));
frag_data[1] = vec4(0.0);
frag_data[2] = vec4(0.0f);
}

View File

@ -39,6 +39,7 @@ vec3 fullbrightScaleSoftClip(vec3 light);
uniform vec4 color;
uniform vec4 sunlight_color;
uniform vec3 lumWeights;
uniform float moon_brightness;
uniform float minLuminance;
uniform sampler2D diffuseMap;
uniform sampler2D altDiffuseMap;
@ -51,13 +52,22 @@ void main()
vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy);
vec4 c = mix(moonA, moonB, blend_factor);
c.rgb = pow(c.rgb, vec3(0.45f));
if (c.a < 0.1f)
{
discard;
}
c.rgb = pow(c.rgb, vec3(0.7f));
c.rgb = fullbrightAtmosTransport(c.rgb);
c.rgb = fullbrightScaleSoftClip(c.rgb);
// mix factor which blends when sunlight is brighter
// and shows true moon color at night
vec3 luma_weights = vec3(0.1, 0.3, 0.0);
float mix = 1.0f - dot(sunlight_color.rgb, luma_weights);
frag_color = vec4(c.rgb, mix * c.a);
vec3 luma_weights = vec3(0.2, 0.3, 0.2);
float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights);
c.rgb = pow(c.rgb, 1.2 - vec3(mix * moon_brightness));
frag_color = vec4(c.rgb, mix * (moon_brightness + (c.a * 0.25)));
}

View File

@ -224,6 +224,22 @@ void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightL
LLGLDisable blend(GL_BLEND);
sky_shader->bind();
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
LLViewerTexture* rainbow_tex = gSky.mVOSkyp->getRainbowTex();
LLViewerTexture* halo_tex = gSky.mVOSkyp->getHaloTex();
sky_shader->bindTexture(LLShaderMgr::RAINBOW_MAP, rainbow_tex);
sky_shader->bindTexture(LLShaderMgr::HALO_MAP, halo_tex);
F32 moisture_level = (float)psky->getSkyMoistureLevel();
F32 droplet_radius = (float)psky->getSkyDropletRadius();
F32 ice_level = (float)psky->getSkyIceLevel();
sky_shader->uniform1f(LLShaderMgr::MOISTURE_LEVEL, moisture_level);
sky_shader->uniform1f(LLShaderMgr::DROPLET_RADIUS, droplet_radius);
sky_shader->uniform1f(LLShaderMgr::ICE_LEVEL, ice_level);
/// Render the skydome
renderDome(origin, camHeightLocal, sky_shader);
@ -484,6 +500,12 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE);
}
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
F32 moon_brightness = (float)psky->getMoonBrightness();
moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness);
moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);

View File

@ -72,6 +72,7 @@ namespace
const std::string FIELD_SKY_MOON_ROTATION("moon_rotation");
const std::string FIELD_SKY_MOON_IMAGE("moon_image");
const std::string FIELD_SKY_MOON_SCALE("moon_scale");
const std::string FIELD_SKY_MOON_BRIGHTNESS("moon_brightness");
const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL("rayleigh_exponential");
const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE("rayleigh_exponential_scale");
@ -398,6 +399,7 @@ BOOL LLPanelSettingsSkySunMoonTab::postBuild()
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowNoTexture(TRUE);
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowLocalTexture(FALSE);
getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonScaleChanged(); });
getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonBrightnessChanged(); });
refresh();
@ -411,6 +413,9 @@ void LLPanelSettingsSkySunMoonTab::setEnabled(BOOL enabled)
getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setEnabled(enabled);
getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setEnabled(enabled);
}
void LLPanelSettingsSkySunMoonTab::refresh()
@ -438,6 +443,7 @@ void LLPanelSettingsSkySunMoonTab::refresh()
getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation());
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId());
getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale());
getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setValue(mSkySettings->getMoonBrightness());
}
//-------------------------------------------------------------------------
@ -513,6 +519,12 @@ void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged()
setIsDirty();
}
void LLPanelSettingsSkySunMoonTab::onMoonBrightnessChanged()
{
mSkySettings->setMoonBrightness((getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->getValue().asReal()));
mSkySettings->update();
setIsDirty();
}
LLPanelSettingsSkyDensityTab::LLPanelSettingsSkyDensityTab()
{

View File

@ -123,6 +123,7 @@ private:
void onSunImageChanged();
void onMoonRotationChanged();
void onMoonScaleChanged();
void onMoonBrightnessChanged();
void onMoonImageChanged();
};

View File

@ -873,6 +873,57 @@ void LLWorld::waterHeightRegionInfo(std::string const& sim_name, F32 water_heigh
}
}
void LLWorld::precullWaterObjects(LLCamera& camera, LLCullResult* cull, bool include_void_water)
{
if (!gAgent.getRegion())
{
return;
}
if (mRegionList.empty())
{
LL_WARNS() << "No regions!" << LL_ENDL;
return;
}
for (region_list_t::iterator iter = mRegionList.begin();
iter != mRegionList.end(); ++iter)
{
LLViewerRegion* regionp = *iter;
LLVOWater* waterp = regionp->getLand().getWaterObj();
if (waterp && waterp->mDrawable)
{
waterp->mDrawable->setVisible(camera);
cull->pushDrawable(waterp->mDrawable);
}
}
if (include_void_water)
{
for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin();
iter != mHoleWaterObjects.end(); ++ iter)
{
LLVOWater* waterp = *iter;
if (waterp && waterp->mDrawable)
{
waterp->mDrawable->setVisible(camera);
cull->pushDrawable(waterp->mDrawable);
}
}
}
S32 dir;
for (dir = 0; dir < 8; dir++)
{
LLVOWater* waterp = mEdgeWaterObjects[dir];
if (waterp && waterp->mDrawable)
{
waterp->mDrawable->setVisible(camera);
cull->pushDrawable(waterp->mDrawable);
}
}
}
void LLWorld::updateWaterObjects()
{
if (!gAgent.getRegion())

View File

@ -138,6 +138,9 @@ public:
LLViewerTexture *getDefaultWaterTexture();
void updateWaterObjects();
void precullWaterObjects(LLCamera& camera, LLCullResult* cull, bool include_void_water);
void waterHeightRegionInfo(std::string const& sim_name, F32 water_height);
void shiftRegions(const LLVector3& offset);

View File

@ -88,6 +88,7 @@
#include "llvocache.h"
#include "llvoground.h"
#include "llvosky.h"
#include "llvowlsky.h"
#include "llvotree.h"
#include "llvovolume.h"
#include "llvosurfacepatch.h"
@ -2415,21 +2416,14 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
{
LLVector3 pnorm;
F32 height = region->getWaterHeight();
if (water_clip < 0)
{ //camera is above water, clip plane points up
pnorm.setVec(0,0,1);
plane.setVec(pnorm, -height);
}
else if (water_clip > 0)
{ //camera is below water, clip plane points down
pnorm = LLVector3(0,0,-1);
plane.setVec(pnorm, height);
}
pnorm.setVec(0,0,-(F32)water_clip);
plane.setVec(pnorm, height * pnorm.mV[VZ]);
}
}
glh::matrix4f modelview = get_last_modelview();
glh::matrix4f proj = get_last_projection();
glh::matrix4f proj = get_last_projection();
LLGLUserClipPlane clip(plane, modelview, proj, water_clip != 0 && LLPipeline::sReflectionRender);
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
@ -2455,9 +2449,9 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
LLViewerRegion* region = *iter;
if (water_clip != 0)
if (water_clip != 0 && LLPipeline::sReflectionRender)
{
LLPlane plane(LLVector3(0,0, (F32) -water_clip), (F32) water_clip*region->getWaterHeight());
LLPlane plane(LLVector3(0,0, -(F32)water_clip), water_clip * region->getWaterHeight());
camera.setUserClipPlane(plane);
}
else
@ -2513,7 +2507,20 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
sCull->pushDrawable(gSky.mVOGroundp->mDrawable);
}
if (hasRenderType(LLPipeline::RENDER_TYPE_WL_SKY) &&
gPipeline.canUseWindLightShaders() &&
gSky.mVOWLSkyp.notNull() &&
gSky.mVOWLSkyp->mDrawable.notNull())
{
gSky.mVOWLSkyp->mDrawable->setVisible(camera);
sCull->pushDrawable(gSky.mVOWLSkyp->mDrawable);
}
if (hasRenderType(LLPipeline::RENDER_TYPE_WATER))
{
LLWorld::getInstance()->precullWaterObjects(camera, sCull, hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER));
}
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();
gGL.matrixMode(LLRender::MM_MODELVIEW);
@ -9823,21 +9830,23 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
F32 plane_d;
S32 water_clip = 0;
if (!LLViewerCamera::getInstance()->cameraUnderWater())
{ //camera is above water, clip plane points up
pnorm.setVec(0,0,1);
plane_d = -water_height;
plane.setVec(pnorm, -distance_to_water);
water_clip = -1;
if (LLViewerCamera::getInstance()->cameraUnderWater())
{
//camera is below water, clip plane points down
water_clip = 1;
}
else
{ //camera is below water, clip plane points down
pnorm = LLVector3(0,0,-1);
plane_d = water_height;
plane.setVec(pnorm, distance_to_water);
water_clip = 1;
{
//camera is above water, clip plane points up
water_clip = -1;
}
//camera is below water, clip plane points down
pnorm = LLVector3(0,0,-(F32)water_clip);
plane_d = water_height * pnorm.mV[VZ];
plane.setVec(pnorm, distance_to_water * pnorm.mV[VZ]);
bool materials_in_water = false;
#if MATERIALS_IN_REFLECTIONS

View File

@ -6,9 +6,9 @@
save_rect="false"
title="Edit Day Cycle"
width="705"
height="650"
height="700"
min_width="705"
min_height="650"
min_height="700"
single_instance="true"
can_resize="false">
@ -25,7 +25,7 @@
<!-- Layout -->
<layout_stack name="outer_stack"
width="705"
height="650"
height="700"
follows="all"
animate="false"
top="0"

View File

@ -14,14 +14,14 @@
top="5"
right="-5"
bottom="-5"
orientation="hoizontal">
orientation="horizontal">
<layout_panel
border="true"
bevel_style="in"
auto_resize="true"
user_resize="false"
visible="true"
height="350">
height="400">
<text
follows="left|top"
height="10"
@ -176,6 +176,29 @@
top_delta="15"
width="250"
can_edit_text="true"/>
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="-5"
top_delta="22"
width="200">
Moon Brightness:
</text>
<slider
decimal_digits="2"
follows="left|top"
height="16"
increment="0.01"
initial_value="0"
layout="topleft"
left_delta="5"
min_val="0.0"
max_val="1.0"
name="moon_brightness"
top_delta="15"
width="250"
can_edit_text="true"/>
</layout_panel>
<layout_panel
border="false"
@ -183,7 +206,7 @@
auto_resize="true"
user_resize="false"
visible="true"
height="350">
height="400">
<layout_stack
left="5"
top="5"