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.cpp181
1 files changed, 92 insertions, 89 deletions
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index 68a849714c..2ddb749141 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -445,18 +445,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)
@@ -487,7 +484,7 @@ void LLReflectionMapManager::update()
(oldestProbe == nullptr ||
check_priority(probe, oldestProbe)))
{
- oldestProbe = probe;
+ oldestProbe = probe;
}
}
@@ -541,7 +538,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
@@ -559,10 +556,10 @@ void LLReflectionMapManager::update()
if(shouldUpdate)
{
- probe->autoAdjustOrigin();
+ probe->autoAdjustOrigin();
- sUpdateCount++;
- mUpdatingProbe = probe;
+ sUpdateCount++;
+ mUpdatingProbe = probe;
if(probe->mCompletedCount < 2)
{
@@ -573,7 +570,7 @@ void LLReflectionMapManager::update()
probe->mNextUpdateTime = gFrameTimeSeconds + fmax( (F32)sMPUpdatePeriod, 0.25);
}
- doProbeUpdate();
+ doProbeUpdate();
}
}
@@ -813,11 +810,8 @@ void LLReflectionMapManager::doProbeUpdate()
{
mUpdatingProbe->mViewerObject->setDebugText(llformat("%.1f", (F32)gFrameTimeSeconds), LLColor4(1, 1, 1, 1));
}
-
updateNeighbors(mUpdatingProbe);
-
mUpdatingFace = 0;
-
if (isRadiancePass())
{
mUpdatingProbe->mComplete = true;
@@ -836,7 +830,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));
}
}
}
@@ -896,7 +890,6 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, b
LLGLDisable blend(GL_BLEND);
// downsample to placeholder map
-
{
gGL.matrixMode(gGL.MM_MODELVIEW);
gGL.pushMatrix();
@@ -941,10 +934,10 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, b
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)
@@ -963,6 +956,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, b
gGL.getTexUnit(diffuseChannel)->bind(&(mMipChain[i - 1]));
}
+
gReflectionMipProgram.uniform1f(resScale, 1.f/(mProbeResolution*2));
gPipeline.mScreenTriangleVB->setBuffer();
@@ -1002,8 +996,8 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, b
if(isRadiancePass()) updateProbeRadianceOnFace(probe, face, sourceIdx);
}
- // if(isRadiancePass()) updateProbeRadianceOnFace(probe, face, sourceIdx);
- //else updateProbeIrradianceOnFace(probe, face, sourceIdx);
+ // if(isRadiancePass()) updateProbeRadianceOnFace(probe, face, sourceIdx);
+ // else updateProbeIrradianceOnFace(probe, face, sourceIdx);
}
// ===================== IRRADIANCE ================================
@@ -1036,8 +1030,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);
@@ -1072,10 +1068,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);
}
@@ -1114,46 +1111,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();
-
- for (int i = 0; i < mMipChain.size(); ++i)
- {
- glViewport(0, 0, res, res);
+ U32 res = mMipChain[0].getWidth();
+ 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();
}
@@ -1180,48 +1179,52 @@ void LLReflectionMapManager::updateProbeIrradianceOnFace(LLReflectionMap* probe,
mMipChain[0].bindTarget("irradiance", 0);
//mMipChain[0].clear();
- gIrradianceGenProgram.bind();
+ gIrradianceGenProgram.bind();
- S32 channel = gIrradianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY);
- mTexture->bind(channel);
+#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);
+ gIrradianceGenProgram.uniform1i(sSourceIdx, sourceIdx);
+ gIrradianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD);
- mVertexBuffer->setBuffer();
+ mVertexBuffer->setBuffer();
+ int start_mip = 0;
+ // find the mip target to start with based on irradiance map resolution
+ for (start_mip = 0; start_mip < mMipChain.size(); ++start_mip)
+ {
+ if (mMipChain[start_mip].getWidth() == LL_IRRADIANCE_MAP_RESOLUTION)
+ {
+ break;
+ }
+ }
- int start_mip = 0;
- // find the mip target to start with based on irradiance map resolution
- for (start_mip = 0; start_mip < mMipChain.size(); ++start_mip)
- {
- if (mMipChain[start_mip].getWidth() == LL_IRRADIANCE_MAP_RESOLUTION)
- {
- break;
- }
- }
+ int i = start_mip;
+ glViewport(0, 0, mMipChain[i].getWidth(), mMipChain[i].getHeight());
- int i = start_mip;
- glViewport(0, 0, mMipChain[i].getWidth(), mMipChain[i].getHeight());
+ int cf = face;
+ {
+ LLCoordFrame frame;
+ frame.lookAt(LLVector3(0, 0, 0), LLCubeMapArray::sClipToCubeLookVecs[cf], LLCubeMapArray::sClipToCubeUpVecs[cf]);
- int cf = face;
- {
- 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);
+#if GL_VERSION_4_0
+ S32 res = mMipChain[i].getWidth();
+ mIrradianceMaps->bind(channel);
+ glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, i - start_mip, 0, 0, probe->mCubeIndex * 6 + cf, 0, 0, res, res);
+#endif
+ }
- S32 res = mMipChain[i].getWidth();
- mIrradianceMaps->bind(channel);
- glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, i - start_mip, 0, 0, probe->mCubeIndex * 6 + cf, 0, 0, res, res);
- }
+ mMipChain[0].flush();
- mMipChain[0].flush();
- gIrradianceGenProgram.unbind();
- mTexture->unbind();
+ gIrradianceGenProgram.unbind();
+ mTexture->unbind();
}
void LLReflectionMapManager::updateProbeRadianceOnFace(LLReflectionMap* probe, U32 face, S32 sourceIdx)
@@ -1388,7 +1391,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();
@@ -1740,9 +1742,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);
}
@@ -1793,7 +1797,6 @@ void LLReflectionMapManager::initReflectionMaps()
mDefaultProbe->mNextUpdateTime = 0.f;
touch_default_probe(mDefaultProbe);
-
}
if (mVertexBuffer.isNull())