summaryrefslogtreecommitdiff
path: root/indra/newview/llreflectionmapmanager.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-06-22 19:56:26 -0500
committerDave Parks <davep@lindenlab.com>2022-06-22 19:56:26 -0500
commit6540b4c480d1d4b4c8342a0d093d09f525485659 (patch)
tree530a9099da2fe2e730690c30be8b36122524394a /indra/newview/llreflectionmapmanager.cpp
parentd0d1b832d4983f35ab29947eb6fda54a8aa48f8a (diff)
SL-17600 Cubemap filter tuning.
Diffstat (limited to 'indra/newview/llreflectionmapmanager.cpp')
-rw-r--r--indra/newview/llreflectionmapmanager.cpp54
1 files changed, 30 insertions, 24 deletions
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index dfd0d1b9a9..bde8c0c51c 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -425,7 +425,8 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
S32 mips = log2((F32)LL_REFLECTION_PROBE_RESOLUTION) + 0.5f;
- for (int i = 0; i < mMipChain.size(); ++i)
+ //for (int i = 0; i < mMipChain.size(); ++i)
+ for (int i = 0; i < 1; ++i)
{
LL_PROFILE_GPU_ZONE("probe mip");
mMipChain[i].bindTarget();
@@ -464,6 +465,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
mTexture->bind(0);
//glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, probe->mCubeIndex * 6 + face, 0, 0, res, res);
glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, targetIdx * 6 + face, 0, 0, res, res);
+ glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, probe->mCubeIndex * 6 + face, 0, 0, res, res);
mTexture->unbind();
}
mMipChain[i].flush();
@@ -485,24 +487,28 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
static LLStaticHashedString sSourceIdx("sourceIdx");
gRadianceGenProgram.uniform1i(sSourceIdx, targetIdx);
- for (int cf = 0; cf < 6; ++cf)
- { // for each cube face
- LLCoordFrame frame;
- frame.lookAt(LLVector3(0, 0, 0), LLCubeMapArray::sClipToCubeLookVecs[cf], LLCubeMapArray::sClipToCubeUpVecs[cf]);
+ static LLStaticHashedString sMipLevel("mipLevel");
- F32 mat[16];
- frame.getOpenGLRotation(mat);
- gGL.loadMatrix(mat);
+ for (int i = 1; i < mMipChain.size(); ++i)
+ {
+ for (int cf = 0; cf < 6; ++cf)
+ { // for each cube face
+ LLCoordFrame frame;
+ frame.lookAt(LLVector3(0, 0, 0), LLCubeMapArray::sClipToCubeLookVecs[cf], LLCubeMapArray::sClipToCubeUpVecs[cf]);
+
+ F32 mat[16];
+ frame.getOpenGLRotation(mat);
+ gGL.loadMatrix(mat);
- for (int i = 0; i < mMipChain.size(); ++i)
- {
mMipChain[i].bindTarget();
static LLStaticHashedString sRoughness("roughness");
- static LLStaticHashedString sNumSamples("numSamples");
- gRadianceGenProgram.uniform1i(sNumSamples, 32);
gRadianceGenProgram.uniform1f(sRoughness, (F32)i / (F32)(mMipChain.size() - 1));
-
+ gRadianceGenProgram.uniform1f(sMipLevel, llmax((F32)(i - 1), 0.f));
+ if (i > 0)
+ {
+ gRadianceGenProgram.uniform1i(sSourceIdx, probe->mCubeIndex);
+ }
gGL.begin(gGL.QUADS);
gGL.vertex3f(-1, -1, -1);
gGL.vertex3f(1, -1, -1);
@@ -523,7 +529,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
channel = gIrradianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY);
mTexture->bind(channel);
- gIrradianceGenProgram.uniform1i(sSourceIdx, targetIdx);
+ gIrradianceGenProgram.uniform1i(sSourceIdx, probe->mCubeIndex);
int start_mip = 0;
// find the mip target to start with based on irradiance map resolution
@@ -535,17 +541,17 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
}
}
- for (int cf = 0; cf < 6; ++cf)
- { // for each cube face
- LLCoordFrame frame;
- frame.lookAt(LLVector3(0, 0, 0), LLCubeMapArray::sClipToCubeLookVecs[cf], LLCubeMapArray::sClipToCubeUpVecs[cf]);
+ for (int i = start_mip; i < mMipChain.size(); ++i)
+ {
+ for (int cf = 0; cf < 6; ++cf)
+ { // for each cube 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);
- for (int i = start_mip; i < mMipChain.size(); ++i)
- {
mMipChain[i].bindTarget();
gGL.begin(gGL.QUADS);
@@ -558,7 +564,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
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);
+ glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, i - start_mip, 0, 0, probe->mCubeIndex * 6 + cf, 0, 0, res, res);
mTexture->bind(channel);
mMipChain[i].flush();
}