summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r--indra/newview/pipeline.cpp111
1 files changed, 86 insertions, 25 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3240e2a663..e441e189ad 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -431,6 +431,7 @@ void LLPipeline::init()
stop_glerror();
//create render pass pools
+ getPool(LLDrawPool::POOL_WATEREXCLUSION);
getPool(LLDrawPool::POOL_ALPHA_PRE_WATER);
getPool(LLDrawPool::POOL_ALPHA_POST_WATER);
getPool(LLDrawPool::POOL_SIMPLE);
@@ -673,6 +674,8 @@ void LLPipeline::cleanup()
// don't delete wl sky pool it was handled above in the for loop
//delete mWLSkyPool;
mWLSkyPool = NULL;
+ delete mWaterExclusionPool;
+ mWaterExclusionPool = nullptr;
releaseGLBuffers();
@@ -907,6 +910,15 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)
mPostMap.allocate(resX, resY, screenFormat);
+ // The water exclusion mask needs its own depth buffer so we can take care of the problem of multiple water planes.
+ // Should we ever make water not just a plane, it also aids with that as well as the water planes will be rendered into the mask.
+ // Why do we do this? Because it saves us some janky logic in the exclusion shader when we generate the mask.
+ // Regardless, this should always only be an R8 texture unless we choose to start having multiple kinds of exclusion that 8 bits can't handle.
+ // - Geenz 2025-02-06
+ bool success = mWaterExclusionMask.allocate(resX, resY, GL_R8, true);
+
+ assert(success);
+
// used to scale down textures
// See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown
mDownResMap.allocate(1024, 1024, GL_RGBA);
@@ -1166,6 +1178,8 @@ void LLPipeline::releaseGLBuffers()
mSceneMap.release();
+ mWaterExclusionMask.release();
+
mPostMap.release();
mFXAAMap.release();
@@ -1676,6 +1690,10 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0)
poolp = mPBRAlphaMaskPool;
break;
+ case LLDrawPool::POOL_WATEREXCLUSION:
+ poolp = mWaterExclusionPool;
+ break;
+
default:
llassert(0);
LL_ERRS() << "Invalid Pool Type in LLPipeline::findPool() type=" << type << LL_ENDL;
@@ -3855,7 +3873,12 @@ void LLPipeline::renderSelectedFaces(const LLColor4& color)
for (auto facep : mSelectedFaces)
{
- if (!facep || facep->getDrawable()->isDead())
+ if (!facep || !facep->getViewerObject())
+ {
+ LLSelectMgr::getInstance()->clearSelections();
+ return;
+ }
+ if (!facep->getDrawable() || facep->getDrawable()->isDead())
{
LL_ERRS() << "Bad face on selection" << LL_ENDL;
return;
@@ -4067,6 +4090,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion)
#endif
}
+// Render all of our geometry that's required after our deferred pass.
+// This is gonna be stuff like alpha, water, etc.
void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
@@ -4085,6 +4110,10 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
bool done_atmospherics = LLPipeline::sRenderingHUDs; //skip atmospherics on huds
bool done_water_haze = done_atmospherics;
+ bool done_water_exclusion = false;
+
+ // do water exclusion just before water pass.
+ U32 water_exclusion_pass = LLDrawPool::POOL_WATEREXCLUSION;
// do atmospheric haze just before post water alpha
U32 atmospherics_pass = LLDrawPool::POOL_ALPHA_POST_WATER;
@@ -4123,6 +4152,12 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
cur_type = poolp->getType();
+ if (cur_type >= water_exclusion_pass && !done_water_exclusion)
+ { // do water exclusion against depth buffer before rendering alpha
+ doWaterExclusionMask();
+ done_water_exclusion = true;
+ }
+
if (cur_type >= atmospherics_pass && !done_atmospherics)
{ // do atmospherics against depth buffer before rendering alpha
doAtmospherics();
@@ -5238,6 +5273,17 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
}
break;
+ case LLDrawPool::POOL_WATEREXCLUSION:
+ if (mWaterExclusionPool)
+ {
+ llassert(0);
+ LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Water Exclusion Pool" << LL_ENDL;
+ }
+ else
+ {
+ mWaterExclusionPool = new_poolp;
+ }
+ break;
default:
llassert(0);
@@ -5360,6 +5406,11 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp )
mPBRAlphaMaskPool = NULL;
break;
+ case LLDrawPool::POOL_WATEREXCLUSION:
+ llassert(poolp == mWaterExclusionPool);
+ mWaterExclusionPool = nullptr;
+ break;
+
default:
llassert(0);
LL_WARNS() << "Invalid Pool Type in LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL;
@@ -7118,7 +7169,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky();
- F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust);
+ F32 probe_ambiance = LLEnvironment::instance().getCurrentSky()->getReflectionProbeAmbiance(should_auto_adjust());
F32 exp_min = 1.f;
F32 exp_max = 1.f;
@@ -7129,13 +7180,13 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
{
if (dynamic_exposure_enabled)
{
- exp_min = sky->getHDROffset() - sky->getHDRMin();
- exp_max = sky->getHDROffset() + sky->getHDRMax();
+ exp_min = sky->getHDROffset(should_auto_adjust()) - sky->getHDRMin(should_auto_adjust());
+ exp_max = sky->getHDROffset(should_auto_adjust()) + sky->getHDRMax(should_auto_adjust());
}
else
{
- exp_min = sky->getHDROffset();
- exp_max = sky->getHDROffset();
+ exp_min = sky->getHDROffset(should_auto_adjust());
+ exp_max = sky->getHDROffset(should_auto_adjust());
}
}
else if (dynamic_exposure_enabled)
@@ -7155,7 +7206,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool
shader->uniform1f(dt, gFrameIntervalSeconds);
shader->uniform2f(noiseVec, ll_frand() * 2.0f - 1.0f, ll_frand() * 2.0f - 1.0f);
shader->uniform4f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max, dynamic_exposure_speed_error);
- shader->uniform4f(dynamic_exposure_params2, sky->getHDROffset(), exp_min, exp_max, dynamic_exposure_speed_target);
+ shader->uniform4f(dynamic_exposure_params2, sky->getHDROffset(should_auto_adjust()), exp_min, exp_max, dynamic_exposure_speed_target);
mScreenTriangleVB->setBuffer();
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
@@ -7213,7 +7264,7 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)
static LLCachedControl<U32> tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U);
shader.uniform1i(tonemap_type, tonemap_type_setting);
- shader.uniform1f(tonemap_mix, psky->getTonemapMix());
+ shader.uniform1f(tonemap_mix, psky->getTonemapMix(should_auto_adjust()));
mScreenTriangleVB->setBuffer();
mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
@@ -8433,13 +8484,13 @@ void LLPipeline::renderDeferredLighting()
setupHWLights(); // to set mSun/MoonDir;
- glm::vec4 tc(glm::make_vec4(mSunDir.mV));
+ glm::vec4 tc(mSunDir);
tc = mat * tc;
- mTransformedSunDir.set(glm::value_ptr(tc));
+ mTransformedSunDir.set(tc);
- glm::vec4 tc_moon(glm::make_vec4(mMoonDir.mV));
+ glm::vec4 tc_moon(mMoonDir);
tc_moon = mat * tc_moon;
- mTransformedMoonDir.set(glm::value_ptr(tc_moon));
+ mTransformedMoonDir.set(tc_moon);
if ((RenderDeferredSSAO && !gCubeSnapshot) || RenderShadowDetail > 0)
{
@@ -8692,7 +8743,7 @@ void LLPipeline::renderDeferredLighting()
continue;
}
- glm::vec3 tc(glm::make_vec3(c));
+ glm::vec3 tc(center);
tc = mul_mat4_vec3(mat, tc);
fullscreen_lights.push_back(LLVector4(tc.x, tc.y, tc.z, s));
@@ -8799,13 +8850,12 @@ void LLPipeline::renderDeferredLighting()
LLDrawable* drawablep = *iter;
LLVOVolume* volume = drawablep->getVOVolume();
LLVector3 center = drawablep->getPositionAgent();
- F32* c = center.mV;
F32 light_size_final = volume->getLightRadius() * 1.5f;
F32 light_falloff_final = volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF);
sVisibleLightCount++;
- glm::vec3 tc(glm::make_vec3(c));
+ glm::vec3 tc(center);
tc = mul_mat4_vec3(mat, tc);
setupSpotLight(gDeferredMultiSpotLightProgram, drawablep);
@@ -8862,6 +8912,7 @@ void LLPipeline::renderDeferredLighting()
LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK,
LLPipeline::RENDER_TYPE_TERRAIN,
LLPipeline::RENDER_TYPE_WATER,
+ LLPipeline::RENDER_TYPE_WATEREXCLUSION,
END_RENDER_TYPES);
renderGeomPostDeferred(*LLViewerCamera::getInstance());
@@ -9000,6 +9051,8 @@ void LLPipeline::doWaterHaze()
static LLStaticHashedString above_water_str("above_water");
haze_shader.uniform1i(above_water_str, sUnderWaterRender ? -1 : 1);
+ haze_shader.bindTexture(LLShaderMgr::WATER_EXCLUSIONTEX, &mWaterExclusionMask);
+
if (LLPipeline::sUnderWaterRender)
{
LLGLDepthTest depth(GL_FALSE);
@@ -9030,6 +9083,17 @@ void LLPipeline::doWaterHaze()
}
}
+void LLPipeline::doWaterExclusionMask()
+{
+ mWaterExclusionMask.bindTarget();
+ glClearColor(1, 1, 1, 1);
+ mWaterExclusionMask.clear();
+ mWaterExclusionPool->render();
+
+ mWaterExclusionMask.flush();
+ glClearColor(0, 0, 0, 0);
+}
+
void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
{
//construct frustum
@@ -9946,10 +10010,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
LLVector3 lightDir = -caster_dir;
lightDir.normVec();
- glm::vec3 light_dir(glm::make_vec3(lightDir.mV));
-
//create light space camera matrix
-
LLVector3 at = lightDir;
LLVector3 up = camera.getAtAxis();
@@ -10001,9 +10062,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
//get good split distances for frustum
for (U32 i = 0; i < fp.size(); ++i)
{
- glm::vec3 v(glm::make_vec3(fp[i].mV));
+ glm::vec3 v(fp[i]);
v = mul_mat4_vec3(saved_view, v);
- fp[i].setVec(glm::value_ptr(v));
+ fp[i] = LLVector3(v);
}
min = fp[0];
@@ -10152,9 +10213,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
for (U32 i = 0; i < fp.size(); i++)
{
- glm::vec3 p = glm::make_vec3(fp[i].mV);
+ glm::vec3 p(fp[i]);
p = mul_mat4_vec3(view[j], p);
- wpf.push_back(LLVector3(glm::value_ptr(p)));
+ wpf.push_back(LLVector3(p));
}
min = wpf[0];
@@ -10355,19 +10416,19 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
view[j] = glm::inverse(view[j]);
//llassert(origin.isFinite());
- glm::vec3 origin_agent(glm::make_vec3(origin.mV));
+ glm::vec3 origin_agent(origin);
//translate view to origin
origin_agent = mul_mat4_vec3(view[j], origin_agent);
- eye = LLVector3(glm::value_ptr(origin_agent));
+ eye = LLVector3(origin_agent);
//llassert(eye.isFinite());
if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot)
{
mShadowFrustOrigin[j] = eye;
}
- view[j] = look(LLVector3(glm::value_ptr(origin_agent)), lightDir, -up);
+ view[j] = look(LLVector3(origin_agent), lightDir, -up);
F32 fx = 1.f/tanf(fovx);
F32 fz = 1.f/tanf(fovz);