diff options
Diffstat (limited to 'indra/newview/llreflectionmapmanager.cpp')
-rw-r--r-- | indra/newview/llreflectionmapmanager.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 9b801a3065..5b63f96e1e 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; doProbeUpdate(); } @@ -792,11 +789,8 @@ void LLReflectionMapManager::doProbeUpdate() { mUpdatingProbe->mViewerObject->setDebugText(llformat("%.1f", (F32)gFrameTimeSeconds), LLColor4(1, 1, 1, 1)); } - updateNeighbors(mUpdatingProbe); - mUpdatingFace = 0; - if (isRadiancePass()) { F32 sMPUpdatePeriod = gSavedSettings.getF32("MPRenderProbeUpdatePeriod"); @@ -830,7 +824,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)); } } } @@ -891,7 +885,6 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) LLGLDisable blend(GL_BLEND); // downsample to placeholder map - { gGL.matrixMode(gGL.MM_MODELVIEW); gGL.pushMatrix(); @@ -936,10 +929,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) @@ -958,6 +951,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(); @@ -1023,8 +1017,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); @@ -1059,10 +1055,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); } @@ -1101,45 +1098,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(); } @@ -1244,7 +1244,6 @@ void LLReflectionMapManager::updateUniforms() LLSettingsSky::ptr_t psky = environment.getCurrentSky(); bool should_auto_adjust = gSavedSettings.getBOOL("RenderSkyAutoAdjustLegacy"); - F32 minimum_ambiance = psky->getReflectionProbeAmbiance(should_auto_adjust); bool is_ambiance_pass = gCubeSnapshot && !isRadiancePass(); @@ -1596,9 +1595,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); } @@ -1649,7 +1650,6 @@ void LLReflectionMapManager::initReflectionMaps() mDefaultProbe->mNextUpdateTime = 0.f; touch_default_probe(mDefaultProbe); - } if (mVertexBuffer.isNull()) |