summaryrefslogtreecommitdiff
path: root/indra/newview/llreflectionmapmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llreflectionmapmanager.cpp')
-rw-r--r--indra/newview/llreflectionmapmanager.cpp133
1 files changed, 64 insertions, 69 deletions
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index c1a87c6310..79fee971a4 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -223,11 +223,11 @@ void LLReflectionMapManager::update()
resume();
}
- static LLCachedControl<S32> sDetail(gSavedSettings, "RenderReflectionProbeDetail", 1);
- static LLCachedControl<S32> sLevel(gSavedSettings, "RenderReflectionProbeLevel", 1);
- static LLCachedControl<U32> sReflectionProbeCount(gSavedSettings, "RenderReflectionProbeCount", 8);
+ static LLCachedControl<S32> sDetail(gSavedSettings, "RenderReflectionProbeDetail", -1);
+ static LLCachedControl<S32> sLevel(gSavedSettings, "RenderReflectionProbeLevel", 3);
+ static LLCachedControl<U32> sReflectionProbeCount(gSavedSettings, "RenderReflectionProbeCount", 256U);
static LLCachedControl<S32> sProbeDynamicAllocation(gSavedSettings, "RenderReflectionProbeDynamicAllocation", -1);
- static LLCachedControl<F32> sProbeUpdateSlowDown(gSavedSettings, "MPRenderProbeSlowDown", 0.0);
+ static LLCachedControl<F32> sProbeUpdateSlowDown(gSavedSettings, "MPRenderProbeSlowDown", 0.05);
bool realtime = sDetail >= (S32)LLReflectionMapManager::DetailLevel::REALTIME;
@@ -292,7 +292,7 @@ void LLReflectionMapManager::update()
initReflectionMaps();
- static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", false);
+ static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", true);
static LLCachedControl<U32> MPColorPrecision(gSavedSettings, "MPColorPrecision", 0);
U32 color_fmt = render_hdr ? GL_R11F_G11F_B10F : GL_RGB8;
@@ -412,7 +412,7 @@ void LLReflectionMapManager::update()
mResetFade = llmin((F32)(mResetFade + gFrameIntervalSeconds * 2.f), 1.f);
- static LLCachedControl<F32> sDefaultUpdatePeriod(gSavedSettings, "RenderDefaultProbeUpdatePeriod", 4.0);
+ static LLCachedControl<F32> sDefaultUpdatePeriod(gSavedSettings, "RenderDefaultProbeUpdatePeriod", 2.0);
for (unsigned int i = 0; i < mProbes.size(); ++i)
{
@@ -443,18 +443,15 @@ void LLReflectionMapManager::update()
d.setSub(camera_pos, probe->mOrigin);
probe->mDistance = d.getLength3().getF32() - probe->mRadius;
}
+ else if (mDefaultProbe->mComplete)
+ {
+ // make default probe have a distance of 64m for the purposes of prioritization (if it's already been generated once)
+ probe->mDistance = 64.f;
+ }
else
{
- if (mDefaultProbe->mComplete)
- {
- // make default probe have a distance of 64m for the purposes of prioritization (if it's already been generated once)
- probe->mDistance = 64.f;
- }
- else
- {
- probe->mNextUpdateTime = 0.f;
- probe->mDistance = -4096.f; //boost priority of default probe when it's not complete
- }
+ probe->mNextUpdateTime = 0.f;
+ probe->mDistance = -4096.f; //boost priority of default probe when it's not complete
}
if (probe->mComplete)
@@ -485,7 +482,7 @@ void LLReflectionMapManager::update()
(oldestProbe == nullptr ||
check_priority(probe, oldestProbe)))
{
- oldestProbe = probe;
+ oldestProbe = probe;
}
}
@@ -539,7 +536,7 @@ void LLReflectionMapManager::update()
}
else if (sLevel > 0)
{ // when probes are enabled don't update the default probe less often than the prescribed update period
- oldestProbe = mDefaultProbe;
+ oldestProbe = mDefaultProbe;
}
// switch to updating the next oldest probe
@@ -557,12 +554,11 @@ void LLReflectionMapManager::update()
if(shouldUpdate)
{
- probe->autoAdjustOrigin();
+ probe->autoAdjustOrigin();
- sUpdateCount++;
- mUpdatingProbe = probe;
-
- doProbeUpdate();
+ sUpdateCount++;
+ mUpdatingProbe = probe;
+ doProbeUpdate();
}
}
@@ -790,14 +786,11 @@ void LLReflectionMapManager::doProbeUpdate()
{
mUpdatingProbe->mViewerObject->setDebugText(llformat("%.1f", (F32)gFrameTimeSeconds), LLColor4(1, 1, 1, 1));
}
-
updateNeighbors(mUpdatingProbe);
-
mUpdatingFace = 0;
-
if (isRadiancePass())
{
- static LLCachedControl<F32> sMPUpdatePeriod(gSavedSettings, "MPRenderProbeUpdatePeriod", 2.0);
+ static LLCachedControl<F32> sMPUpdatePeriod(gSavedSettings, "MPRenderProbeUpdatePeriod", 15.0);
mUpdatingProbe->mComplete = true;
mUpdatingProbe->mCompletedCount++;
@@ -828,7 +821,7 @@ void LLReflectionMapManager::doProbeUpdate()
if (debug_updates)
{
- mUpdatingProbe->mViewerObject->setDebugText(llformat("%.1f", (F32)gFrameTimeSeconds), LLColor4(1, 1, 0, 1));
+ mUpdatingProbe->mViewerObject->setDebugText(llformat("%.1f", (F32)gFrameTimeSeconds), LLColor4(1, 1, 0, 1));
}
}
}
@@ -847,9 +840,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gPipeline.mRT = &gPipeline.mAuxillaryRT;
mLightScale = 1.f;
-
- static LLCachedControl<F32> max_local_light_ambiance(gSavedSettings, "RenderReflectionProbeMaxLocalLightAmbiance", 1.0);
-
+ static LLCachedControl<F32> max_local_light_ambiance(gSavedSettings, "RenderReflectionProbeMaxLocalLightAmbiance", 8.f);
if (!isRadiancePass() && probe->getAmbiance() > max_local_light_ambiance)
{
mLightScale = max_local_light_ambiance / probe->getAmbiance();
@@ -890,7 +881,6 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
LLGLDisable blend(GL_BLEND);
// downsample to placeholder map
-
{
gGL.matrixMode(gGL.MM_MODELVIEW);
gGL.pushMatrix();
@@ -935,10 +925,10 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
screen_rt->flush();
}
+
S32 mips = (S32)(log2((F32)mProbeResolution) + 0.5f);
gReflectionMipProgram.bind();
-
S32 diffuseChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_TEXTURE);
for (int i = 0; i < mMipChain.size(); ++i)
@@ -957,6 +947,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gGL.getTexUnit(diffuseChannel)->bind(&(mMipChain[i - 1]));
}
+
gReflectionMipProgram.uniform1f(resScale, 1.f/(mProbeResolution*2));
gPipeline.mScreenTriangleVB->setBuffer();
@@ -1022,8 +1013,10 @@ void LLReflectionMapManager::updateProbeIrradiance(LLReflectionMap* probe)
gIrradianceGenProgram.bind();
+#if GL_VERSION_4_0
S32 channel = gIrradianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY);
mTexture->bind(channel);
+#endif
gIrradianceGenProgram.uniform1i(sSourceIdx, sourceIdx);
gIrradianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD);
@@ -1058,10 +1051,11 @@ void LLReflectionMapManager::updateProbeIrradiance(LLReflectionMap* probe)
mVertexBuffer->drawArrays(gGL.TRIANGLE_STRIP, 0, 4);
S32 res = mMipChain[i].getWidth();
-
+#if GL_VERSION_4_0
mIrradianceMaps->bind(channel);
glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, i - start_mip, 0, 0, probe->mCubeIndex * 6 + cf, 0, 0, res, res);
mTexture->bind(channel);
+#endif
//mMipChain[0].clear(0);
}
@@ -1100,45 +1094,48 @@ void LLReflectionMapManager::updateProbeRadiance(LLReflectionMap* probe)
gRadianceGenProgram.bind();
mVertexBuffer->setBuffer();
- S32 channel = gRadianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY);
- mTexture->bind(channel);
-
- gRadianceGenProgram.uniform1i(sSourceIdx, sourceIdx);
- gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD);
- gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_STRENGTH, 1.f);
- gRadianceGenProgram.uniform1i(sWidth, mProbeResolution);
+#if GL_VERSION_4_0
+ S32 channel = gRadianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY);
+ mTexture->bind(channel);
+#endif
+ gRadianceGenProgram.uniform1i(sSourceIdx, sourceIdx);
+ gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD);
+ gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_STRENGTH, 1.f);
+ gRadianceGenProgram.uniform1i(sWidth, mProbeResolution);
- U32 res = mMipChain[0].getWidth();
+ U32 res = mMipChain[0].getWidth();
- for (int i = 0; i < mMipChain.size(); ++i)
- {
- glViewport(0, 0, res, res);
+ for (int i = 0; i < mMipChain.size(); ++i)
+ {
+ glViewport(0, 0, res, res);
- gRadianceGenProgram.uniform1f(sMipLevel, (GLfloat)i);
- gRadianceGenProgram.uniform1f(sRoughness, (F32)i / (F32)(mMipChain.size() - 1));
+ gRadianceGenProgram.uniform1f(sMipLevel, (GLfloat)i);
+ gRadianceGenProgram.uniform1f(sRoughness, (F32)i / (F32)(mMipChain.size() - 1));
- for (int cf = 0; cf < 6; ++cf)
- {
- LLCoordFrame frame;
- frame.lookAt(LLVector3(0, 0, 0), LLCubeMapArray::sClipToCubeLookVecs[cf], LLCubeMapArray::sClipToCubeUpVecs[cf]);
+ for (int cf = 0; cf < 6; ++cf)
+ {
+ LLCoordFrame frame;
+ frame.lookAt(LLVector3(0, 0, 0), LLCubeMapArray::sClipToCubeLookVecs[cf], LLCubeMapArray::sClipToCubeUpVecs[cf]);
- F32 mat[16];
- frame.getOpenGLRotation(mat);
- gGL.loadMatrix(mat);
+ F32 mat[16];
+ frame.getOpenGLRotation(mat);
+ gGL.loadMatrix(mat);
- mVertexBuffer->drawArrays(gGL.TRIANGLE_STRIP, 0, 4);
+ mVertexBuffer->drawArrays(gGL.TRIANGLE_STRIP, 0, 4);
- glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, i, 0, 0, probe->mCubeIndex * 6 + cf, 0, 0, res, res);
- LOG_GLERROR("glCopyTexSubImage3D");
- }
+#if GL_VERSION_4_0
+ glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, i, 0, 0, probe->mCubeIndex * 6 + cf, 0, 0, res, res);
+#endif
+ LOG_GLERROR("glCopyTexSubImage3D");
+ }
- if (i != mMipChain.size() - 1)
- {
- res /= 2;
- }
+ if (i != mMipChain.size() - 1)
+ {
+ res /= 2;
+ }
}
- gRadianceGenProgram.unbind();
+ gRadianceGenProgram.unbind();
mMipChain[0].flush();
//mTexture->unbind();
}
@@ -1243,8 +1240,6 @@ void LLReflectionMapManager::updateUniforms()
LLSettingsSky::ptr_t psky = environment.getCurrentSky();
static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false);
-
-
F32 minimum_ambiance = psky->getReflectionProbeAmbiance(should_auto_adjust);
bool is_ambiance_pass = gCubeSnapshot && !isRadiancePass();
@@ -1560,8 +1555,7 @@ void LLReflectionMapManager::renderDebug()
void LLReflectionMapManager::initReflectionMaps()
{
- static LLCachedControl<U32> ref_probe_res(gSavedSettings, "RenderReflectionProbeResolution", 128);
-
+ static LLCachedControl<U32> ref_probe_res(gSavedSettings, "RenderReflectionProbeResolution", 128U);
U32 probe_resolution = nhpo2(llclamp(ref_probe_res(), (U32)64, (U32)512));
bool shouldInit = mTexture.isNull() || mReflectionProbeCount != mDynamicProbeCount || mProbeResolution != probe_resolution || mReset;
@@ -1586,7 +1580,7 @@ void LLReflectionMapManager::initReflectionMaps()
mTexture->getWidth() != mProbeResolution ||
mReflectionProbeCount + 2 != mTexture->getCount())
{
- static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", false);
+ static LLCachedControl<bool> render_hdr(gSavedSettings, "RenderHDREnabled", true);
if (mTexture)
{
@@ -1597,9 +1591,11 @@ void LLReflectionMapManager::initReflectionMaps()
else
{
mTexture = new LLCubeMapArray();
+
// store mReflectionProbeCount+2 cube maps, final two cube maps are used for render target and radiance map generation
// source)
mTexture->allocate(mProbeResolution, 3, mReflectionProbeCount + 2, true, render_hdr);
+
mIrradianceMaps = new LLCubeMapArray();
mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 3, mReflectionProbeCount, false, render_hdr);
}
@@ -1650,7 +1646,6 @@ void LLReflectionMapManager::initReflectionMaps()
mDefaultProbe->mNextUpdateTime = 0.f;
touch_default_probe(mDefaultProbe);
-
}
if (mVertexBuffer.isNull())