MAINT-8838 render a sun disc if the texture(s) are provided by WL settings (default is no sun disc and just haze)

Refactor sky texture optimization to retain building the cubemap used by shiny.
meow-7.2.2
Graham Linden 2018-07-03 16:37:32 +01:00
parent 9717589a55
commit 8969b11435
13 changed files with 383 additions and 61 deletions

View File

@ -683,7 +683,7 @@ LLSettingsDay::CycleTrack_t::value_type LLSettingsDay::getSettingsNearKeyframe(c
F32 dist = get_wrapping_distance(startframe, (*it).first);
LL_DEBUGS("LAPRAS") << "[" << startframe << " ... " << keyframe << " -> " << (*it).first << "@" << dist << LL_ENDL;
//LL_DEBUGS("LAPRAS") << "[" << startframe << " ... " << keyframe << " -> " << (*it).first << "@" << dist << LL_ENDL;
if (dist <= (fudge * 2.0f))
return (*it);

View File

@ -640,7 +640,7 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position)
dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1;
dfltsetting[SETTING_CLOUD_TEXTUREID] = GetDefaultCloudNoiseTextureId();
dfltsetting[SETTING_MOON_TEXTUREID] = GetDefaultMoonTextureId();
dfltsetting[SETTING_SUN_TEXTUREID] = LLUUID::null; // GetDefaultSunTextureId();
dfltsetting[SETTING_SUN_TEXTUREID] = GetDefaultSunTextureId();
dfltsetting[SETTING_TYPE] = "sky";
@ -1092,7 +1092,8 @@ LLUUID LLSettingsSky::GetDefaultAssetId()
LLUUID LLSettingsSky::GetDefaultSunTextureId()
{
return DEFAULT_SUN_ID;
//return DEFAULT_SUN_ID;
return LLUUID::null;
}
LLUUID LLSettingsSky::GetDefaultMoonTextureId()

View File

@ -49,7 +49,7 @@ void main()
{
vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy);
vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy);
vec4 c = mix(moonA, moonB, blend_factor);
vec4 c = mix(moonB, moonA, blend_factor);
c.rgb = pow(c.rgb, vec3(0.7f));
c.rgb = fullbrightAtmosTransport(c.rgb);

View File

@ -0,0 +1,55 @@
/**
* @file sunDiscF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2005, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#extension GL_ARB_texture_rectangle : enable
/*[EXTRA_CODE_HERE]*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
vec3 fullbrightAtmosTransport(vec3 light);
vec3 fullbrightScaleSoftClip(vec3 light);
uniform sampler2D diffuseMap;
uniform sampler2D altDiffuseMap;
uniform float blend_factor; // interp factor between sunDisc A/B
VARYING vec2 vary_texcoord0;
void main()
{
vec4 sunDiscA = texture2D(diffuseMap, vary_texcoord0.xy);
vec4 sunDiscB = texture2D(altDiffuseMap, vary_texcoord0.xy);
vec4 c = mix(sunDiscB, sunDiscA, blend_factor);
c.rgb = pow(c.rgb, vec3(0.7f));
c.rgb = fullbrightAtmosTransport(c.rgb);
c.rgb = fullbrightScaleSoftClip(c.rgb);
frag_color = c;
}

View File

@ -0,0 +1,44 @@
/**
* @file sunDiscV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 texture_matrix0;
uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
VARYING vec2 vary_texcoord0;
void main()
{
//transform vertex
vec4 vert = vec4(position.xyz, 1.0);
vec4 pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
}

View File

@ -49,7 +49,7 @@ void main()
{
vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy);
vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy);
vec4 c = mix(moonA, moonB, blend_factor);
vec4 c = mix(moonB, moonA, blend_factor);
c.rgb = pow(c.rgb, vec3(0.45f));
c.rgb = fullbrightAtmosTransport(c.rgb);

View File

@ -0,0 +1,54 @@
/**
* @file sunDiscF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2005, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#extension GL_ARB_texture_rectangle : enable
/*[EXTRA_CODE_HERE]*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
vec3 fullbrightAtmosTransport(vec3 light);
vec3 fullbrightScaleSoftClip(vec3 light);
uniform sampler2D diffuseMap;
uniform sampler2D altDiffuseMap;
uniform float blend_factor; // interp factor between sun A/B
VARYING vec2 vary_texcoord0;
void main()
{
vec4 sunA = texture2D(diffuseMap, vary_texcoord0.xy);
vec4 sunB = texture2D(altDiffuseMap, vary_texcoord0.xy);
vec4 c = mix(sunB, sunA, blend_factor);
c.rgb = pow(c.rgb, vec3(0.45f));
c.rgb = fullbrightAtmosTransport(c.rgb);
c.rgb = fullbrightScaleSoftClip(c.rgb);
frag_color = c;
}

View File

@ -0,0 +1,44 @@
/**
* @file sunDiscV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2007, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 texture_matrix0;
uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
VARYING vec2 vary_texcoord0;
void main()
{
//transform vertex
vec4 vert = vec4(position.xyz, 1.0);
vec4 pos = (modelview_matrix * vert);
gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
}

View File

@ -48,8 +48,9 @@ static LLStaticHashedString sCamPosLocal("camPosLocal");
static LLStaticHashedString sCustomAlpha("custom_alpha");
static LLGLSLShader* cloud_shader = NULL;
static LLGLSLShader* sky_shader = NULL;
static LLGLSLShader* moon_shader = NULL;
static LLGLSLShader* sky_shader = NULL;
static LLGLSLShader* sun_shader = NULL;
static LLGLSLShader* moon_shader = NULL;
LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
LLDrawPool(POOL_WL_SKY)
@ -77,6 +78,11 @@ void LLDrawPoolWLSky::beginRenderPass( S32 pass )
&gObjectFullbrightNoColorWaterProgram :
&gWLCloudProgram;
sun_shader =
LLPipeline::sUnderWaterRender ?
&gObjectFullbrightNoColorWaterProgram :
&gWLSunProgram;
moon_shader =
LLPipeline::sUnderWaterRender ?
&gObjectFullbrightNoColorWaterProgram :
@ -91,6 +97,12 @@ void LLDrawPoolWLSky::beginDeferredPass(S32 pass)
{
sky_shader = &gDeferredWLSkyProgram;
cloud_shader = &gDeferredWLCloudProgram;
sun_shader =
LLPipeline::sUnderWaterRender ?
&gObjectFullbrightNoColorWaterProgram :
&gDeferredWLSunProgram;
moon_shader =
LLPipeline::sUnderWaterRender ?
&gObjectFullbrightNoColorWaterProgram :
@ -300,53 +312,116 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
LLGLEnable blend_on(GL_BLEND);
gPipeline.disableLights();
#if 0 // when we want to re-add a texture sun disc, here's where to do it.
LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN];
if (gSky.mVOSkyp->getSun().getDraw() && face->getGeomCount())
F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor();
bool can_use_vertex_shaders = gPipeline.canUseVertexShaders();
if (gSky.mVOSkyp->getSun().getDraw() && face && face->getGeomCount())
{
LLViewerTexture * tex = face->getTexture();
gGL.getTexUnit(0)->bind(tex);
LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor());
LLFacePool::LLOverrideFaceColor color_override(this, color);
face->renderIndexed();
LLViewerTexture* tex_a = face->getTexture(LLRender::DIFFUSE_MAP);
LLViewerTexture* tex_b = face->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP);
// if we even have sun disc textures to work with...
if (tex_a || tex_b)
{
// if and only if we have a texture defined, render the sun disc
if (can_use_vertex_shaders)
{
sun_shader->bind();
}
if (tex_a && (!tex_b || (tex_a == tex_b)))
{
// Bind current and next sun textures
gGL.getTexUnit(0)->bind(tex_a);
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
blend_factor = 0;
}
else if (tex_b && !tex_a)
{
gGL.getTexUnit(0)->bind(tex_b);
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
blend_factor = 0;
}
else if (tex_b != tex_a)
{
gGL.getTexUnit(0)->bind(tex_a);
gGL.getTexUnit(1)->bind(tex_b);
}
LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor());
if (can_use_vertex_shaders)
{
sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
sun_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
}
LLFacePool::LLOverrideFaceColor color_override(this, color);
face->renderIndexed();
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
if (can_use_vertex_shaders)
{
sun_shader->unbind();
}
}
}
#endif
LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON];
face = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON];
if (gSky.mVOSkyp->getMoon().getDraw() && face && face->getTexture(LLRender::DIFFUSE_MAP) && face->getGeomCount() && moon_shader)
{
LLViewerTexture* tex_a = face->getTexture(LLRender::DIFFUSE_MAP);
LLViewerTexture* tex_b = face->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP);
if (gSky.mVOSkyp->getMoon().getDraw() && face->getGeomCount() && moon_shader)
{
// *NOTE: even though we already bound this texture above for the
// stars register combiners, we bind again here for defensive reasons,
// since LLImageGL::bind detects that it's a noop, and optimizes it out.
gGL.getTexUnit(0)->bind(face->getTexture());
LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor());
/*F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2];
if (a > 0.f)
{
a = a*a*4.f;
}
color.mV[3] = llclamp(a, 0.f, 1.f);*/
if (gPipeline.canUseVertexShaders())
if (can_use_vertex_shaders)
{
moon_shader->bind();
moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
moon_shader->uniform3fv(LLShaderMgr::GLOW_LUM_WEIGHTS, 1, LLPipeline::RenderGlowLumWeights.mV);
F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor();
}
if (tex_a && (!tex_b || (tex_a == tex_b)))
{
// Bind current and next sun textures
gGL.getTexUnit(0)->bind(tex_a);
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
blend_factor = 0;
}
else if (tex_b && !tex_a)
{
gGL.getTexUnit(0)->bind(tex_b);
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
blend_factor = 0;
}
else if (tex_b != tex_a)
{
gGL.getTexUnit(0)->bind(tex_a);
gGL.getTexUnit(1)->bind(tex_b);
}
if (can_use_vertex_shaders)
{
moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV);
moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
}
}
LLFacePool::LLOverrideFaceColor color_override(this, color);
face->renderIndexed();
if (gPipeline.canUseVertexShaders())
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
if (can_use_vertex_shaders)
{
moon_shader->unbind();
}
}
}
}
void LLDrawPoolWLSky::renderDeferred(S32 pass)
@ -383,12 +458,6 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
gGL.pushMatrix();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
// *NOTE: have to bind moon textures here since register combiners blending in
// renderStars() requires something to be bound and we might as well only
// bind the moon textures once.
gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(LLRender::DIFFUSE_MAP));
gGL.getTexUnit(1)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP));
renderHeavenlyBodies();
}
}

View File

@ -176,6 +176,7 @@ LLGLSLShader gImpostorProgram;
// WindLight shader handles
LLGLSLShader gWLSkyProgram;
LLGLSLShader gWLCloudProgram;
LLGLSLShader gWLSunProgram;
LLGLSLShader gWLMoonProgram;
// Effects Shaders
@ -232,6 +233,7 @@ LLGLSLShader gFXAAProgram;
LLGLSLShader gDeferredPostNoDoFProgram;
LLGLSLShader gDeferredWLSkyProgram;
LLGLSLShader gDeferredWLCloudProgram;
LLGLSLShader gDeferredWLSunProgram;
LLGLSLShader gDeferredWLMoonProgram;
LLGLSLShader gDeferredStarProgram;
LLGLSLShader gDeferredFullbrightShinyProgram;
@ -251,6 +253,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
//ONLY shaders that need WL Param management should be added here
mShaderList.push_back(&gWLSkyProgram);
mShaderList.push_back(&gWLCloudProgram);
mShaderList.push_back(&gWLSunProgram);
mShaderList.push_back(&gWLMoonProgram);
mShaderList.push_back(&gAvatarProgram);
mShaderList.push_back(&gObjectShinyProgram);
@ -345,6 +348,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
mShaderList.push_back(&gDeferredWLSkyProgram);
mShaderList.push_back(&gDeferredWLCloudProgram);
mShaderList.push_back(&gDeferredWLMoonProgram);
mShaderList.push_back(&gDeferredWLSunProgram);
}
LLViewerShaderMgr::~LLViewerShaderMgr()
@ -831,6 +835,7 @@ void LLViewerShaderMgr::unloadShaders()
gWLSkyProgram.unload();
gWLCloudProgram.unload();
gWLSunProgram.unload();
gWLMoonProgram.unload();
gPostColorFilterProgram.unload();
@ -1213,6 +1218,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredUnderWaterProgram.unload();
gDeferredWLSkyProgram.unload();
gDeferredWLCloudProgram.unload();
gDeferredWLSunProgram.unload();
gDeferredWLMoonProgram.unload();
gDeferredStarProgram.unload();
gDeferredFullbrightShinyProgram.unload();
@ -2157,6 +2163,24 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
llassert(success);
}
if (success)
{
gDeferredWLSunProgram.mName = "Deferred Windlight Sun Program";
gDeferredWLSunProgram.mFeatures.calculatesAtmospherics = true;
gDeferredWLSunProgram.mFeatures.hasTransport = true;
gDeferredWLSunProgram.mFeatures.hasGamma = true;
gDeferredWLSunProgram.mFeatures.hasAtmospherics = true;
gDeferredWLSunProgram.mFeatures.isFullbright = true;
gDeferredWLSunProgram.mFeatures.disableTextureIndex = true;
gDeferredWLSunProgram.mShaderFiles.clear();
gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLSunProgram.createShader(NULL, NULL);
llassert(success);
}
if (success)
{
gDeferredWLMoonProgram.mName = "Deferred Windlight Moon Program";
@ -2171,10 +2195,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLMoonProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY;
if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3)
{
gDeferredWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink();
}
success = gDeferredWLMoonProgram.createShader(NULL, NULL);
llassert(success);
}
@ -3510,6 +3530,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
{
gWLSkyProgram.unload();
gWLCloudProgram.unload();
gWLSunProgram.unload();
gWLMoonProgram.unload();
gDownsampleMinMaxDepthRectProgram.unload();
gInscatterRectProgram.unload();
@ -3546,6 +3567,24 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
success = gWLCloudProgram.createShader(NULL, NULL);
}
if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3))
{
gWLSunProgram.mName = "Windlight Sun Program";
gWLSunProgram.mShaderFiles.clear();
gWLSunProgram.mFeatures.calculatesAtmospherics = true;
gWLSunProgram.mFeatures.hasTransport = true;
gWLSunProgram.mFeatures.hasGamma = true;
gWLSunProgram.mFeatures.hasAtmospherics = true;
gWLSunProgram.mFeatures.isFullbright = true;
gWLSunProgram.mFeatures.disableTextureIndex = true;
gWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY;
gWLSunProgram.mShaderFiles.push_back(make_pair("windlight/sunDiscV.glsl", GL_VERTEX_SHADER_ARB));
gWLSunProgram.mShaderFiles.push_back(make_pair("windlight/sunDiscF.glsl", GL_FRAGMENT_SHADER_ARB));
gWLSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];
gWLSunProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gWLSunProgram.createShader(NULL, NULL);
}
if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3))
{
gWLMoonProgram.mName = "Windlight Moon Program";

View File

@ -261,6 +261,7 @@ extern LLGLSLShader gImpostorProgram;
// WindLight shader handles
extern LLGLSLShader gWLSkyProgram;
extern LLGLSLShader gWLCloudProgram;
extern LLGLSLShader gWLSunProgram;
extern LLGLSLShader gWLMoonProgram;
// Post Process Shaders
@ -316,6 +317,7 @@ extern LLGLSLShader gDeferredAvatarEyesProgram;
extern LLGLSLShader gDeferredAvatarAlphaProgram;
extern LLGLSLShader gDeferredWLSkyProgram;
extern LLGLSLShader gDeferredWLCloudProgram;
extern LLGLSLShader gDeferredWLSunProgram;
extern LLGLSLShader gDeferredWLMoonProgram;
extern LLGLSLShader gDeferredStarProgram;
extern LLGLSLShader gDeferredFullbrightShinyProgram;

View File

@ -427,7 +427,7 @@ void LLVOSky::init()
for (S32 tile = 0; tile < NUM_TILES; ++tile)
{
initSkyTextureDirs(side, tile);
createSkyTexture(side, tile);
createSkyTexture(side, tile, false);
}
}
@ -556,7 +556,7 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile)
}
}
void LLVOSky::createSkyTexture(const S32 side, const S32 tile)
void LLVOSky::createSkyTexture(const S32 side, const S32 tile, bool use_windlight_shaders)
{
S32 tile_x = tile % NUM_TILES_X;
S32 tile_y = tile / NUM_TILES_X;
@ -569,7 +569,10 @@ void LLVOSky::createSkyTexture(const S32 side, const S32 tile)
{
for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x)
{
mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(mSkyTex[side].getDir(x, y)), x, y);
if (use_windlight_shaders)
{
mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(mSkyTex[side].getDir(x, y)), x, y);
}
mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(mSkyTex[side].getDir(x, y), true), x, y);
}
}
@ -652,7 +655,9 @@ bool LLVOSky::updateSky()
mForceUpdate = mForceUpdate || color_changed;
mForceUpdate = mForceUpdate || !mInitialized;
if ((mForceUpdate) && (forceupdThrottle.hasExpired()) && (!gPipeline.canUseWindLightShaders()))
bool use_windlight_shaders = gPipeline.canUseWindLightShaders();
if (mForceUpdate && forceupdThrottle.hasExpired())
{
LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED);
@ -674,16 +679,21 @@ bool LLVOSky::updateSky()
{
for (int tile = 0; tile < NUM_TILES; tile++)
{
createSkyTexture(side, tile);
createSkyTexture(side, tile, use_windlight_shaders);
}
}
for (int side = 0; side < 6; side++)
{
LLImageRaw* raw1 = mSkyTex[side].getImageRaw(TRUE);
LLImageRaw* raw2 = mSkyTex[side].getImageRaw(FALSE);
raw2->copy(raw1);
mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE));
LLImageRaw* raw1 = nullptr;
LLImageRaw* raw2 = nullptr;
if (use_windlight_shaders)
{
raw1 = mSkyTex[side].getImageRaw(TRUE);
raw2 = mSkyTex[side].getImageRaw(FALSE);
raw2->copy(raw1);
mSkyTex[side].createGLImage(mSkyTex[side].getWhich(FALSE));
}
raw1 = mShinyTex[side].getImageRaw(TRUE);
raw2 = mShinyTex[side].getImageRaw(FALSE);
@ -695,7 +705,10 @@ bool LLVOSky::updateSky()
// update the sky texture
for (S32 i = 0; i < 6; ++i)
{
mSkyTex[i].create(1.0f);
if (use_windlight_shaders)
{
mSkyTex[i].create(1.0f);
}
mShinyTex[i].create(1.0f);
}
@ -778,8 +791,9 @@ LLDrawable *LLVOSky::createDrawable(LLPipeline *pipeline)
void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next)
{
mSunTexturep[0] = LLViewerTextureManager::getFetchedTexture(sun_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
mSunTexturep[1] = LLViewerTextureManager::getFetchedTexture(sun_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
// We test the UUIDs here because we explicitly do not want the default image returned by getFetchedTexture in that case...
mSunTexturep[0] = sun_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
mSunTexturep[1] = sun_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
if (mFace[FACE_SUN])
{
@ -791,9 +805,9 @@ void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_textur
if (mSunTexturep[1])
{
mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
mFace[FACE_SUN]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mSunTexturep[1]);
mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
}
mFace[FACE_SUN]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mSunTexturep[1]);
}
}

View File

@ -289,7 +289,7 @@ protected:
void updateDirections(void);
void initSkyTextureDirs(const S32 side, const S32 tile);
void createSkyTexture(const S32 side, const S32 tile);
void createSkyTexture(const S32 side, const S32 tile, bool use_windlight_shaders);
LLPointer<LLViewerFetchedTexture> mSunTexturep[2];
LLPointer<LLViewerFetchedTexture> mMoonTexturep[2];