summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-08-24 18:44:39 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-08-24 18:44:39 +0100
commit98cc2365034a93c69704daa69efb389799cc9627 (patch)
tree4c3ec75b78a26a736f18a2153af025040ae05a4b /indra/newview/pipeline.cpp
parent6ba23344c95157793af9e4154933ae8df61630e8 (diff)
Backed out changeset a62bf7c0af21
Backing out this merge that I pushed (prematurely) to the wrong place.
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r--indra/newview/pipeline.cpp920
1 files changed, 314 insertions, 606 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e4c2ca9ae3..a3b402c1a3 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -185,7 +185,6 @@ std::string gPoolNames[] =
};
void drawBox(const LLVector3& c, const LLVector3& r);
-void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
U32 nhpo2(U32 v)
{
@@ -263,8 +262,7 @@ BOOL LLPipeline::sRenderHighlight = TRUE;
BOOL LLPipeline::sForceOldBakedUpload = FALSE;
S32 LLPipeline::sUseOcclusion = 0;
BOOL LLPipeline::sDelayVBUpdate = TRUE;
-BOOL LLPipeline::sAutoMaskAlphaDeferred = TRUE;
-BOOL LLPipeline::sAutoMaskAlphaNonDeferred = FALSE;
+BOOL LLPipeline::sFastAlpha = TRUE;
BOOL LLPipeline::sDisableShaders = FALSE;
BOOL LLPipeline::sRenderBump = TRUE;
BOOL LLPipeline::sUseTriStrips = TRUE;
@@ -324,6 +322,7 @@ LLPipeline::LLPipeline() :
mInitialized(FALSE),
mVertexShadersEnabled(FALSE),
mVertexShadersLoaded(0),
+ mRenderTypeMask(0),
mRenderDebugFeatureMask(0),
mRenderDebugMask(0),
mOldRenderDebugMask(0),
@@ -377,11 +376,7 @@ void LLPipeline::init()
LLViewerStats::getInstance()->mTrianglesDrawnStat.reset();
resetFrameStats();
- for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
- {
- mRenderTypeEnabled[i] = TRUE; //all rendering types start enabled
- }
-
+ mRenderTypeMask = 0xffffffff; // All render types start on
mRenderDebugFeatureMask = 0xffffffff; // All debugging features on
mRenderDebugMask = 0; // All debug starts off
@@ -408,8 +403,6 @@ void LLPipeline::init()
{
mSpotLightFade[i] = 1.f;
}
-
- setLightingDetail(-1);
}
LLPipeline::~LLPipeline()
@@ -512,7 +505,6 @@ void LLPipeline::destroyGL()
}
static LLFastTimer::DeclareTimer FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
-
void LLPipeline::resizeScreenTexture()
{
LLFastTimer ft(FTM_RESIZE_SCREEN_TEXTURE);
@@ -569,12 +561,9 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
F32 scale = gSavedSettings.getF32("RenderShadowResolutionScale");
- //HACK: make alpha masking work on ATI depth shadows (work around for ATI driver bug)
- U32 shadow_fmt = gGLManager.mIsATI ? GL_ALPHA : 0;
-
for (U32 i = 0; i < 4; i++)
{
- mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
+ mShadow[i].allocate(U32(resX*scale),U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
}
@@ -583,9 +572,11 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
for (U32 i = 4; i < 6; i++)
{
- mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE);
+ mShadow[i].allocate(width, height, 0, TRUE, FALSE);
}
+
+
width = nhpo2(resX)/2;
height = nhpo2(resY)/2;
mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE);
@@ -630,11 +621,9 @@ void LLPipeline::updateRenderDeferred()
{
BOOL deferred = (gSavedSettings.getBOOL("RenderDeferred") &&
LLRenderTarget::sUseFBO &&
- LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
gSavedSettings.getBOOL("VertexShaderEnable") &&
gSavedSettings.getBOOL("RenderAvatarVP") &&
- (gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE) &&
- !gUseWireframe;
+ gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE;
sRenderDeferred = deferred;
}
@@ -909,18 +898,13 @@ S32 LLPipeline::setLightingDetail(S32 level)
if (level < 0)
{
- if (gSavedSettings.getBOOL("VertexShaderEnable"))
- {
- level = 1;
- }
- else
- {
- level = 0;
- }
+ level = gSavedSettings.getS32("RenderLightingDetail");
}
level = llclamp(level, 0, getMaxLightingDetail());
if (level != mLightingDetail)
{
+ gSavedSettings.setS32("RenderLightingDetail", level);
+
mLightingDetail = level;
if (mVertexShadersLoaded == 1)
@@ -1524,10 +1508,8 @@ BOOL LLPipeline::visibleObjectsInFrustum(LLCamera& camera)
BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& max)
{
- const F32 X = 65536.f;
-
- min = LLVector3(X,X,X);
- max = LLVector3(-X,-X,-X);
+ min = LLVector3(F32_MAX, F32_MAX, F32_MAX);
+ max = LLVector3(-F32_MAX, -F32_MAX, -F32_MAX);
U32 saved_camera_id = LLViewerCamera::sCurCameraID;
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
@@ -1966,31 +1948,23 @@ void LLPipeline::updateGeom(F32 max_dtime)
void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
{
LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
-
- if(drawablep && !drawablep->isDead())
+ if(!drawablep || drawablep->isDead())
{
+ return;
+ }
+
if (drawablep->isSpatialBridge())
{
- const LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
- llassert(root); // trying to catch a bad assumption
- if (root && // // this test may not be needed, see above
- root->getVObj()->isAttachment())
- {
- LLDrawable* rootparent = root->getParent();
- if (rootparent) // this IS sometimes NULL
- {
- LLViewerObject *vobj = rootparent->getVObj();
- llassert(vobj); // trying to catch a bad assumption
- if (vobj) // this test may not be needed, see above
+ LLDrawable* root = ((LLSpatialBridge*) drawablep)->mDrawable;
+
+ if (root && root->getParent() && root->getVObj() && root->getVObj()->isAttachment())
{
- const LLVOAvatar* av = vobj->asAvatar();
+ LLVOAvatar* av = root->getParent()->getVObj()->asAvatar();
if (av && av->isImpostor())
{
return;
}
}
- }
- }
sCull->pushBridge((LLSpatialBridge*) drawablep);
}
else
@@ -2000,7 +1974,6 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
drawablep->setVisible(camera);
}
-}
void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
{
@@ -2209,13 +2182,14 @@ static LLFastTimer::DeclareTimer FTM_RESET_DRAWORDER("Reset Draw Order");
void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
{
- if (hasAnyRenderType(LLPipeline::RENDER_TYPE_AVATAR,
- LLPipeline::RENDER_TYPE_GROUND,
- LLPipeline::RENDER_TYPE_TERRAIN,
- LLPipeline::RENDER_TYPE_TREE,
- LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_WATER,
- LLPipeline::END_RENDER_TYPES))
+ const U32 face_mask = (1 << LLPipeline::RENDER_TYPE_AVATAR) |
+ (1 << LLPipeline::RENDER_TYPE_GROUND) |
+ (1 << LLPipeline::RENDER_TYPE_TERRAIN) |
+ (1 << LLPipeline::RENDER_TYPE_TREE) |
+ (1 << LLPipeline::RENDER_TYPE_SKY) |
+ (1 << LLPipeline::RENDER_TYPE_WATER);
+
+ if (mRenderTypeMask & face_mask)
{
//clear faces from face pools
LLFastTimer t(FTM_RESET_DRAWORDER);
@@ -3435,14 +3409,26 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
gGLLastMatrix = NULL;
glLoadMatrixd(gGLModelView);
+ renderHighlights();
+ mHighlightFaces.clear();
+
+ renderDebug();
+
+ LLVertexBuffer::unbind();
+
+ if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+ {
+ // Render debugging beacons.
+ gObjectList.renderObjectBeacons();
+ gObjectList.resetObjectBeacons();
+ }
+
if (occlude)
{
occlude = FALSE;
gGLLastMatrix = NULL;
glLoadMatrixd(gGLModelView);
doOcclusion(camera);
- gGLLastMatrix = NULL;
- glLoadMatrixd(gGLModelView);
}
}
@@ -3605,17 +3591,12 @@ void LLPipeline::renderDebug()
for (U32 i = 0; i < 8; i++)
{
- LLVector3* frust = mShadowCamera[i].mAgentFrustum;
-
if (i > 3)
- { //render shadow frusta as volumes
- if (mShadowFrustPoints[i-4].empty())
{
- continue;
- }
-
gGL.color4fv(col+(i-4)*4);
+ LLVector3* frust = mShadowCamera[i].mAgentFrustum;
+
gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
@@ -3643,49 +3624,31 @@ void LLPipeline::renderDebug()
if (i < 4)
{
+ gGL.begin(LLRender::LINES);
- if (i == 0 || !mShadowFrustPoints[i].empty())
+ F32* c = col+i*4;
+ for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
{
- //render visible point cloud
- gGL.flush();
- glPointSize(8.f);
- gGL.begin(LLRender::POINTS);
- F32* c = col+i*4;
gGL.color3fv(c);
- for (U32 j = 0; j < mShadowFrustPoints[i].size(); ++j)
+ for (U32 k = 0; k < mShadowFrustPoints[i].size(); ++k)
+ {
+ if (j != k)
{
gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
-
+ gGL.vertex3fv(mShadowFrustPoints[i][k].mV);
}
- gGL.end();
-
- gGL.flush();
- glPointSize(1.f);
-
- LLVector3* ext = mShadowExtents[i];
- LLVector3 pos = (ext[0]+ext[1])*0.5f;
- LLVector3 size = (ext[1]-ext[0])*0.5f;
- drawBoxOutline(pos, size);
-
- //render camera frustum splits as outlines
- gGL.begin(LLRender::LINES);
- gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[1].mV);
- gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[2].mV);
- gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[3].mV);
- gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[0].mV);
- gGL.vertex3fv(frust[4].mV); gGL.vertex3fv(frust[5].mV);
- gGL.vertex3fv(frust[5].mV); gGL.vertex3fv(frust[6].mV);
- gGL.vertex3fv(frust[6].mV); gGL.vertex3fv(frust[7].mV);
- gGL.vertex3fv(frust[7].mV); gGL.vertex3fv(frust[4].mV);
- gGL.vertex3fv(frust[0].mV); gGL.vertex3fv(frust[4].mV);
- gGL.vertex3fv(frust[1].mV); gGL.vertex3fv(frust[5].mV);
- gGL.vertex3fv(frust[2].mV); gGL.vertex3fv(frust[6].mV);
- gGL.vertex3fv(frust[3].mV); gGL.vertex3fv(frust[7].mV);
- gGL.end();
}
+ if (!mShadowFrustOrigin[i].isExactlyZero())
+ {
+ gGL.vertex3fv(mShadowFrustPoints[i][j].mV);
+ gGL.color4f(1,1,1,1);
+ gGL.vertex3fv(mShadowFrustOrigin[i].mV);
+ }
+ }
+ gGL.end();
}
/*for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
@@ -4597,42 +4560,32 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
LLVector4 light_pos_gl(light_pos, 1.0f);
F32 light_radius = llmax(light->getLightRadius(), 0.001f);
+ F32 atten, quad;
- F32 x = (3.f * (1.f + light->getLightFalloff())); // why this magic? probably trying to match a historic behavior.
- float linatten = x / (light_radius); // % of brightness at radius
-
+#if 0 //1.9.1
+ if (pool->getVertexShaderLevel() > 0)
+ {
+ atten = light_radius;
+ quad = llmax(light->getLightFalloff(), 0.0001f);
+ }
+ else
+#endif
+ {
+ F32 x = (3.f * (1.f + light->getLightFalloff()));
+ atten = x / (light_radius); // % of brightness at radius
+ quad = 0.0f;
+ }
mHWLightColors[cur_light] = light_color;
S32 gllight = GL_LIGHT0+cur_light;
glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
glLightfv(gllight, GL_DIFFUSE, light_color.mV);
glLightfv(gllight, GL_AMBIENT, LLColor4::black.mV);
+ glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
glLightf (gllight, GL_CONSTANT_ATTENUATION, 0.0f);
- glLightf (gllight, GL_LINEAR_ATTENUATION, linatten);
- glLightf (gllight, GL_QUADRATIC_ATTENUATION, 0.0f);
- if (light->isLightSpotlight() // directional (spot-)light
- && (LLPipeline::sRenderDeferred || gSavedSettings.getBOOL("RenderSpotLightsInNondeferred"))) // these are only rendered as GL spotlights if we're in deferred rendering mode *or* the setting forces them on
- {
- LLVector3 spotparams = light->getSpotLightParams();
- LLQuaternion quat = light->getRenderRotation();
- LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
- at_axis *= quat;
- //llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
- glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
- glLightf (gllight, GL_SPOT_EXPONENT, 2.0f); // 2.0 = good old dot product ^ 2
- glLightf (gllight, GL_SPOT_CUTOFF, 90.0f); // hemisphere
- const float specular[] = {0.f, 0.f, 0.f, 0.f};
- glLightfv(gllight, GL_SPECULAR, specular);
- }
- else // omnidirectional (point) light
- {
+ glLightf (gllight, GL_LINEAR_ATTENUATION, atten);
+ glLightf (gllight, GL_QUADRATIC_ATTENUATION, quad);
glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
glLightf (gllight, GL_SPOT_CUTOFF, 180.0f);
-
- // we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
- const float specular[] = {0.f, 0.f, 0.f, 1.f};
- glLightfv(gllight, GL_SPECULAR, specular);
- //llinfos << "boring light" << llendl;
- }
cur_light++;
if (cur_light >= 8)
{
@@ -4659,10 +4612,13 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
LLVector4 light_pos_gl(light_pos, 1.0f);
F32 light_radius = 16.f;
+ F32 atten, quad;
+ {
F32 x = 3.f;
- float linatten = x / (light_radius); // % of brightness at radius
-
+ atten = x / (light_radius); // % of brightness at radius
+ quad = 0.0f;
+ }
mHWLightColors[2] = light_color;
S32 gllight = GL_LIGHT2;
glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
@@ -4670,8 +4626,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
glLightfv(gllight, GL_AMBIENT, LLColor4::black.mV);
glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
glLightf (gllight, GL_CONSTANT_ATTENUATION, 0.0f);
- glLightf (gllight, GL_LINEAR_ATTENUATION, linatten);
- glLightf (gllight, GL_QUADRATIC_ATTENUATION, 0.0f);
+ glLightf (gllight, GL_LINEAR_ATTENUATION, atten);
+ glLightf (gllight, GL_QUADRATIC_ATTENUATION, quad);
glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
glLightf (gllight, GL_SPOT_CUTOFF, 180.0f);
}
@@ -4792,16 +4748,16 @@ void LLPipeline::enableLightsFullbright(const LLColor4& color)
enableLights(mask);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,color.mV);
- /*if (mLightingDetail >= 2)
+ if (mLightingDetail >= 2)
{
glColor4f(0.f, 0.f, 0.f, 1.f); // no local lighting by default
- }*/
+ }
}
void LLPipeline::disableLights()
{
enableLights(0); // no lighting (full bright)
- //glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
+ glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
}
//============================================================================
@@ -4991,7 +4947,8 @@ void LLPipeline::setLight(LLDrawable *drawablep, BOOL is_light)
//static
void LLPipeline::toggleRenderType(U32 type)
{
- gPipeline.mRenderTypeEnabled[type] = !gPipeline.mRenderTypeEnabled[type];
+ U32 bit = (1<<type);
+ gPipeline.mRenderTypeMask ^= bit;
}
//static
@@ -5539,7 +5496,6 @@ void LLPipeline::bindScreenToTexture()
}
static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom");
-
void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
{
LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM);
@@ -5862,12 +5818,6 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
-
- if (LLRenderTarget::sUseFBO)
- { //copy depth buffer from mScreen to framebuffer
- LLRenderTarget::copyContentsToFramebuffer(mScreen, 0, 0, mScreen.getWidth(), mScreen.getHeight(),
- 0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
- }
}
@@ -5884,12 +5834,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
}
-static LLFastTimer::DeclareTimer FTM_BIND_DEFERRED("Bind Deferred");
-
void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRenderTarget* gi_source, LLRenderTarget* last_gi_post, U32 noise_map)
{
- LLFastTimer t(FTM_BIND_DEFERRED);
-
if (noise_map == 0xFFFFFFFF)
{
noise_map = mNoiseMap;
@@ -6227,16 +6173,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
matrix_nondiag, matrix_nondiag, matrix_diag};
shader.uniformMatrix3fv("ssao_effect_mat", 1, GL_FALSE, ssao_effect_mat);
- F32 shadow_offset_error = 1.f + gSavedSettings.getF32("RenderShadowOffsetError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
- F32 shadow_bias_error = 1.f + gSavedSettings.getF32("RenderShadowBiasError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
-
shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f);
- shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset")*shadow_offset_error);
- shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias")*shadow_bias_error);
- shader.uniform1f ("spot_shadow_offset", gSavedSettings.getF32("RenderSpotShadowOffset"));
- shader.uniform1f("spot_shadow_bias", gSavedSettings.getF32("RenderSpotShadowBias"));
-
+ shader.uniform1f("alpha_soften", gSavedSettings.getF32("RenderDeferredAlphaSoften"));
+ shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset"));
+ shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias"));
shader.uniform1f("lum_scale", gSavedSettings.getF32("RenderLuminanceScale"));
shader.uniform1f("sun_lum_scale", gSavedSettings.getF32("RenderSunLuminanceScale"));
shader.uniform1f("sun_lum_offset", gSavedSettings.getF32("RenderSunLuminanceOffset"));
@@ -6330,6 +6271,8 @@ void LLPipeline::renderDeferredLighting()
glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
}
+ if (gSavedSettings.getBOOL("RenderDeferredShadow"))
+ {
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
@@ -6337,9 +6280,7 @@ void LLPipeline::renderDeferredLighting()
glLoadIdentity();
mDeferredLight[0].bindTarget();
-
- if (gSavedSettings.getBOOL("RenderDeferredSSAO") || gSavedSettings.getS32("RenderShadowDetail") > 0)
- {
+ if (gSavedSettings.getBOOL("RenderDeferredSun"))
{ //paint shadow/SSAO light map (direct lighting lightmap)
LLFastTimer ftm(FTM_SUN_SHADOW);
bindDeferredShader(gDeferredSunProgram, 0);
@@ -6380,22 +6321,18 @@ void LLPipeline::renderDeferredLighting()
unbindDeferredShader(gDeferredSunProgram);
}
- }
else
{
- glClearColor(1,1,1,1);
mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
- glClearColor(0,0,0,0);
}
mDeferredLight[0].flush();
- { //global illumination specific block (still experimental)
if (gSavedSettings.getBOOL("RenderDeferredBlurLight") &&
gSavedSettings.getBOOL("RenderDeferredGI"))
{
LLFastTimer ftm(FTM_EDGE_DETECTION);
- //generate edge map
+ //get edge map
LLGLDisable blend(GL_BLEND);
LLGLDisable test(GL_ALPHA_TEST);
LLGLDepthTest depth(GL_FALSE);
@@ -6492,9 +6429,8 @@ void LLPipeline::renderDeferredLighting()
unbindDeferredShader(gDeferredPostGIProgram);
}
}
- }
- if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
+ if (gSavedSettings.getBOOL("RenderDeferredBlurLight"))
{ //soften direct lighting lightmap
LLFastTimer ftm(FTM_SOFTEN_SHADOW);
//blur lightmap
@@ -6564,6 +6500,7 @@ void LLPipeline::renderDeferredLighting()
stop_glerror();
glPopMatrix();
stop_glerror();
+ }
//copy depth and stencil from deferred screen
//mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(),
@@ -6572,15 +6509,11 @@ void LLPipeline::renderDeferredLighting()
if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 2)
{
mDeferredLight[1].bindTarget();
- // clear color buffer here (GI) - zeroing alpha (glow) is important or it will accumulate against sky
- glClearColor(0,0,0,0);
- mScreen.clear(GL_COLOR_BUFFER_BIT);
+ mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
}
else
{
mScreen.bindTarget();
- // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky
- glClearColor(0,0,0,0);
mScreen.clear(GL_COLOR_BUFFER_BIT);
}
@@ -6617,16 +6550,15 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable stencil(GL_STENCIL_TEST);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
- gPipeline.pushRenderTypeMask();
-
- gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::END_RENDER_TYPES);
+ U32 render_mask = mRenderTypeMask;
+ mRenderTypeMask = mRenderTypeMask &
+ ((1 << LLPipeline::RENDER_TYPE_SKY) |
+ (1 << LLPipeline::RENDER_TYPE_CLOUDS) |
+ (1 << LLPipeline::RENDER_TYPE_WL_SKY));
renderGeomPostDeferred(*LLViewerCamera::getInstance());
- gPipeline.popRenderTypeMask();
+ mRenderTypeMask = render_mask;
}
BOOL render_local = gSavedSettings.getBOOL("RenderDeferredLocalLights");
@@ -6671,15 +6603,6 @@ void LLPipeline::renderDeferredLighting()
continue;
}
- if (volume->isAttachment())
- {
- if (!sRenderAttachedLights)
- {
- continue;
- }
- }
-
-
LLVector3 center = drawablep->getPositionAgent();
F32* c = center.mV;
F32 s = volume->getLightRadius()*1.5f;
@@ -6730,7 +6653,7 @@ void LLPipeline::renderDeferredLighting()
{ //draw box if camera is outside box
if (render_local)
{
- if (volume->isLightSpotlight())
+ if (volume->getLightTexture())
{
drawablep->getVOVolume()->updateSpotLightPriority();
spot_lights.push_back(drawablep);
@@ -6747,7 +6670,7 @@ void LLPipeline::renderDeferredLighting()
}
else if (render_fullscreen)
{
- if (volume->isLightSpotlight())
+ if (volume->getLightTexture())
{
drawablep->getVOVolume()->updateSpotLightPriority();
fullscreen_spot_lights.push_back(drawablep);
@@ -6948,48 +6871,29 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
LLGLDisable stencil(GL_STENCIL_TEST);
- pushRenderTypeMask();
- andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA,
- LLPipeline::RENDER_TYPE_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_VOLUME,
- LLPipeline::RENDER_TYPE_GLOW,
- LLPipeline::RENDER_TYPE_BUMP,
- LLPipeline::RENDER_TYPE_PASS_SIMPLE,
- LLPipeline::RENDER_TYPE_PASS_ALPHA,
- LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
- LLPipeline::RENDER_TYPE_PASS_BUMP,
- LLPipeline::RENDER_TYPE_PASS_POST_BUMP,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
- LLPipeline::RENDER_TYPE_PASS_GLOW,
- LLPipeline::RENDER_TYPE_PASS_GRASS,
- LLPipeline::RENDER_TYPE_PASS_SHINY,
- LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
- LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
- LLPipeline::RENDER_TYPE_AVATAR,
- END_RENDER_TYPES);
+ U32 render_mask = mRenderTypeMask;
+ mRenderTypeMask = mRenderTypeMask &
+ ((1 << LLPipeline::RENDER_TYPE_ALPHA) |
+ (1 << LLPipeline::RENDER_TYPE_FULLBRIGHT) |
+ (1 << LLPipeline::RENDER_TYPE_VOLUME) |
+ (1 << LLPipeline::RENDER_TYPE_GLOW) |
+ (1 << LLPipeline::RENDER_TYPE_BUMP) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_GLOW) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_GRASS) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY) |
+ (1 << LLPipeline::RENDER_TYPE_AVATAR));
renderGeomPostDeferred(*LLViewerCamera::getInstance());
- popRenderTypeMask();
- }
-
- {
- //render highlights, etc.
- renderHighlights();
- mHighlightFaces.clear();
-
- renderDebug();
-
- LLVertexBuffer::unbind();
-
- if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
- {
- // Render debugging beacons.
- gObjectList.renderObjectBeacons();
- LLHUDObject::renderAll();
- gObjectList.resetObjectBeacons();
- }
+ mRenderTypeMask = render_mask;
}
mScreen.flush();
@@ -7225,7 +7129,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
LLPipeline::sUseOcclusion = llmin(occlusion, 1);
- gPipeline.pushRenderTypeMask();
+ U32 type_mask = gPipeline.mRenderTypeMask;
glh::matrix4f projection = glh_get_current_projection();
glh::matrix4f mat;
@@ -7294,47 +7198,43 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
glCullFace(GL_FRONT);
static LLCullResult ref_result;
-
+ U32 ref_mask = 0;
if (LLDrawPoolWater::sNeedsDistortionUpdate)
{
//initial sky pass (no user clip plane)
{ //mask out everything but the sky
- gPipeline.pushRenderTypeMask();
- gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::END_RENDER_TYPES);
+ U32 tmp = mRenderTypeMask;
+ mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) |
+ (1 << LLPipeline::RENDER_TYPE_WL_SKY));
static LLCullResult result;
updateCull(camera, result);
stateSort(camera, result);
- andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::END_RENDER_TYPES);
-
+ mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) |
+ (1 << LLPipeline::RENDER_TYPE_CLOUDS) |
+ (1 << LLPipeline::RENDER_TYPE_WL_SKY));
renderGeom(camera, TRUE);
- gPipeline.popRenderTypeMask();
+ mRenderTypeMask = tmp;
}
- gPipeline.pushRenderTypeMask();
+ U32 mask = mRenderTypeMask;
+ mRenderTypeMask &= ~((1<<LLPipeline::RENDER_TYPE_WATER) |
+ (1<<LLPipeline::RENDER_TYPE_GROUND) |
+ (1<<LLPipeline::RENDER_TYPE_SKY) |
+ (1<<LLPipeline::RENDER_TYPE_CLOUDS));
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
- LLPipeline::RENDER_TYPE_GROUND,
- LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::END_RENDER_TYPES);
+ if (gSavedSettings.getBOOL("RenderWaterReflections"))
+ { //mask out selected geometry based on reflection detail
S32 detail = gSavedSettings.getS32("RenderReflectionDetail");
- if (detail > 0)
- { //mask out selected geometry based on reflection detail
- if (detail < 4)
- {
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES);
if (detail < 3)
{
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
+ mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_PARTICLES);
if (detail < 2)
{
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES);
+ mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_AVATAR);
+ if (detail < 1)
+ {
+ mRenderTypeMask &= ~(1 << LLPipeline::RENDER_TYPE_VOLUME);
}
}
}
@@ -7345,18 +7245,19 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
stateSort(camera, ref_result);
}
+ ref_mask = mRenderTypeMask;
+ mRenderTypeMask = mask;
+ }
if (LLDrawPoolWater::sNeedsDistortionUpdate)
{
- if (gSavedSettings.getS32("RenderReflectionDetail") > 0)
+ mRenderTypeMask = ref_mask;
+ if (gSavedSettings.getBOOL("RenderWaterReflections"))
{
gPipeline.grabReferences(ref_result);
LLGLUserClipPlane clip_plane(plane, mat, projection);
renderGeom(camera);
}
}
-
- gPipeline.popRenderTypeMask();
- }
glCullFace(GL_BACK);
glPopMatrix();
mWaterRef.flush();
@@ -7369,20 +7270,18 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
if (last_update)
{
camera.setFar(camera_in.getFar());
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
- LLPipeline::RENDER_TYPE_GROUND,
- END_RENDER_TYPES);
+ mRenderTypeMask = type_mask & (~(1<<LLPipeline::RENDER_TYPE_WATER) |
+ (1<<LLPipeline::RENDER_TYPE_GROUND));
stop_glerror();
LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? FALSE : TRUE;
if (LLPipeline::sUnderWaterRender)
{
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_GROUND,
- LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::RENDER_TYPE_WL_SKY,
- END_RENDER_TYPES);
+ mRenderTypeMask &= ~((1<<LLPipeline::RENDER_TYPE_GROUND) |
+ (1<<LLPipeline::RENDER_TYPE_SKY) |
+ (1<<LLPipeline::RENDER_TYPE_CLOUDS) |
+ (1<<LLPipeline::RENDER_TYPE_WL_SKY));
}
LLViewerCamera::updateFrustumPlanes(camera);
@@ -7423,7 +7322,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
}
glClearColor(0.f, 0.f, 0.f, 0.f);
gViewerWindow->setup3DViewport();
- gPipeline.popRenderTypeMask();
+ mRenderTypeMask = type_mask;
LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd));
@@ -7614,169 +7513,112 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
LLPipeline::sShadowRender = FALSE;
}
-static LLFastTimer::DeclareTimer FTM_VISIBLE_CLOUD("Visible Cloud");
+
BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir)
{
- LLFastTimer t(FTM_VISIBLE_CLOUD);
//get point cloud of intersection of frust and min, max
+ //get set of planes
+ std::vector<LLPlane> ps;
+
if (getVisibleExtents(camera, min, max))
{
return FALSE;
}
- //get set of planes on bounding box
- std::vector<LLPlane> bp;
-
- bp.push_back(LLPlane(min, LLVector3(-1,0,0)));
- bp.push_back(LLPlane(min, LLVector3(0,-1,0)));
- bp.push_back(LLPlane(min, LLVector3(0,0,-1)));
- bp.push_back(LLPlane(max, LLVector3(1,0,0)));
- bp.push_back(LLPlane(max, LLVector3(0,1,0)));
- bp.push_back(LLPlane(max, LLVector3(0,0,1)));
-
- //potential points
- std::vector<LLVector3> pp;
+ ps.push_back(LLPlane(min, LLVector3(-1,0,0)));
+ ps.push_back(LLPlane(min, LLVector3(0,-1,0)));
+ ps.push_back(LLPlane(min, LLVector3(0,0,-1)));
+ ps.push_back(LLPlane(max, LLVector3(1,0,0)));
+ ps.push_back(LLPlane(max, LLVector3(0,1,0)));
+ ps.push_back(LLPlane(max, LLVector3(0,0,1)));
- //add corners of AABB
- pp.push_back(LLVector3(min.mV[0], min.mV[1], min.mV[2]));
- pp.push_back(LLVector3(max.mV[0], min.mV[1], min.mV[2]));
- pp.push_back(LLVector3(min.mV[0], max.mV[1], min.mV[2]));
- pp.push_back(LLVector3(max.mV[0], max.mV[1], min.mV[2]));
- pp.push_back(LLVector3(min.mV[0], min.mV[1], max.mV[2]));
- pp.push_back(LLVector3(max.mV[0], min.mV[1], max.mV[2]));
- pp.push_back(LLVector3(min.mV[0], max.mV[1], max.mV[2]));
- pp.push_back(LLVector3(max.mV[0], max.mV[1], max.mV[2]));
-
- //add corners of camera frustum
- for (U32 i = 0; i < 8; i++)
+ /*if (!light_dir.isExactlyZero())
{
- pp.push_back(camera.mAgentFrustum[i]);
- }
+ LLPlane ucp;
+ LLPlane mcp;
+ F32 maxd = -1.f;
+ F32 mind = 1.f;
- //bounding box line segments
- U32 bs[] =
- {
- 0,1,
- 1,3,
- 3,2,
- 2,0,
-
- 4,5,
- 5,7,
- 7,6,
- 6,4,
-
- 0,4,
- 1,5,
- 3,7,
- 2,6
- };
-
- for (U32 i = 0; i < 12; i++)
- { //for each line segment in bounding box
- for (U32 j = 0; j < 6; j++)
- { //for each plane in camera frustum
- const LLPlane& cp = camera.getAgentPlane(j);
- const LLVector3& v1 = pp[bs[i*2+0]];
- const LLVector3& v2 = pp[bs[i*2+1]];
- const LLVector3 n(cp.mV);
-
- LLVector3 line = v1-v2;
-
- F32 d1 = line*n;
- F32 d2 = -cp.dist(v2);
-
- F32 t = d2/d1;
-
- if (t > 0.f && t < 1.f)
+ for (U32 i = 0; i < ps.size(); ++i)
+ { //pick the plane most aligned to lightDir for user clip plane
+ LLVector3 n(ps[i].mV);
+ F32 da = n*light_dir;
+ if (da > maxd)
{
- LLVector3 intersect = v2+line*t;
- pp.push_back(intersect);
+ maxd = da;
+ ucp = ps[i];
}
+
+ if (da < mind)
+ {
+ mind = da;
+ mcp = ps[i];
}
}
- //camera frustum line segments
- const U32 fs[] =
- {
- 0,1,
- 1,2,
- 2,3,
- 3,1,
-
- 4,5,
- 5,6,
- 6,7,
- 7,4,
+ camera.setUserClipPlane(ucp);
+
+ ps.clear();
+ ps.push_back(ucp);
+ ps.push_back(mcp);
+ }*/
- 0,4,
- 1,5,
- 2,6,
- 3,7
- };
-
- LLVector3 center = (max+min)*0.5f;
- LLVector3 size = (max-min)*0.5f;
+ for (U32 i = 0; i < 6; i++)
+ {
+ ps.push_back(camera.getAgentPlane(i));
+ }
+
+ //get set of points where planes intersect and points are not above any plane
+ fp.clear();
- for (U32 i = 0; i < 12; i++)
+ for (U32 i = 0; i < ps.size(); ++i)
{
- for (U32 j = 0; j < 6; ++j)
+ for (U32 j = 0; j < ps.size(); ++j)
{
- const LLVector3& v1 = pp[fs[i*2+0]+8];
- const LLVector3& v2 = pp[fs[i*2+1]+8];
- const LLPlane& cp = bp[j];
- const LLVector3 n(cp.mV);
-
- LLVector3 line = v1-v2;
-
- F32 d1 = line*n;
- F32 d2 = -cp.dist(v2);
-
- F32 t = d2/d1;
-
- if (t > 0.f && t < 1.f)
+ for (U32 k = 0; k < ps.size(); ++k)
{
- LLVector3 intersect = v2+line*t;
- pp.push_back(intersect);
- }
- }
+ if (i == j ||
+ i == k ||
+ k == j)
+ {
+ continue;
}
- LLVector3 ext[] = { min-LLVector3(0.05f,0.05f,0.05f),
- max+LLVector3(0.05f,0.05f,0.05f) };
+ LLVector3 n1,n2,n3;
+ F32 d1,d2,d3;
- for (U32 i = 0; i < pp.size(); ++i)
- {
- bool found = true;
+ n1.setVec(ps[i].mV);
+ n2.setVec(ps[j].mV);
+ n3.setVec(ps[k].mV);
- const F32* p = pp[i].mV;
+ d1 = ps[i].mV[3];
+ d2 = ps[j].mV[3];
+ d3 = ps[k].mV[3];
- for (U32 j = 0; j < 3; ++j)
- {
- if (p[j] < ext[0].mV[j] ||
- p[j] > ext[1].mV[j])
- {
- found = false;
- break;
- }
- }
+ //get point of intersection of 3 planes "p"
+ LLVector3 p = (-d1*(n2%n3)-d2*(n3%n1)-d3*(n1%n2))/(n1*(n2%n3));
- for (U32 j = 0; j < 6; ++j)
- {
- const LLPlane& cp = camera.getAgentPlane(j);
- F32 dist = cp.dist(pp[i]);
- if (dist > 0.05f) //point is above some plane, not contained
+ if (llround(p*n1+d1, 0.0001f) == 0.f &&
+ llround(p*n2+d2, 0.0001f) == 0.f &&
+ llround(p*n3+d3, 0.0001f) == 0.f)
+ { //point is on all three planes
+ BOOL found = TRUE;
+ for (U32 l = 0; l < ps.size() && found; ++l)
{
- found = false;
- break;
+ if (llround(ps[l].dist(p), 0.0001f) > 0.0f)
+ { //point is above some plane, not contained
+ found = FALSE;
}
}
if (found)
{
- fp.push_back(pp[i]);
+ fp.push_back(p);
+ }
+ }
+ }
}
}
@@ -7877,22 +7719,21 @@ void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<L
sun_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
static LLCullResult result;
- pushRenderTypeMask();
+ U32 type_mask = mRenderTypeMask;
- andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
- LLPipeline::RENDER_TYPE_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_BUMP,
- LLPipeline::RENDER_TYPE_VOLUME,
- LLPipeline::RENDER_TYPE_TREE,
- LLPipeline::RENDER_TYPE_TERRAIN,
- LLPipeline::RENDER_TYPE_WATER,
- LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW,
- LLPipeline::RENDER_TYPE_AVATAR,
- LLPipeline::RENDER_TYPE_PASS_SIMPLE,
- LLPipeline::RENDER_TYPE_PASS_BUMP,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_PASS_SHINY,
- END_RENDER_TYPES);
+ mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) |
+ (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
+ (1<<LLPipeline::RENDER_TYPE_BUMP) |
+ (1<<LLPipeline::RENDER_TYPE_VOLUME) |
+ (1<<LLPipeline::RENDER_TYPE_TREE) |
+ (1<<LLPipeline::RENDER_TYPE_TERRAIN) |
+ (1<<LLPipeline::RENDER_TYPE_WATER) |
+ (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) |
+ (1<<LLPipeline::RENDER_TYPE_AVATAR) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SHINY));
@@ -7961,7 +7802,7 @@ void LLPipeline::generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<L
LLPipeline::sShadowRender = FALSE;
sMinRenderSize = 0.f;
- popRenderTypeMask();
+ mRenderTypeMask = type_mask;
}
@@ -8045,11 +7886,30 @@ void LLPipeline::generateHighlight(LLCamera& camera)
void LLPipeline::generateSunShadow(LLCamera& camera)
{
- if (!sRenderDeferred || gSavedSettings.getS32("RenderShadowDetail") <= 0)
+ if (!sRenderDeferred || !gSavedSettings.getBOOL("RenderDeferredShadow"))
{
return;
}
+ //temporary hack to disable shadows but keep local lights
+ static BOOL clear = TRUE;
+ BOOL gen_shadow = gSavedSettings.getBOOL("RenderDeferredSunShadow");
+ if (!gen_shadow)
+ {
+ if (clear)
+ {
+ clear = FALSE;
+ for (U32 i = 0; i < 6; i++)
+ {
+ mShadow[i].bindTarget();
+ mShadow[i].clear();
+ mShadow[i].flush();
+ }
+ }
+ return;
+ }
+ clear = TRUE;
+
F64 last_modelview[16];
F64 last_projection[16];
for (U32 i = 0; i < 16; i++)
@@ -8058,24 +7918,23 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
last_projection[i] = gGLLastProjection[i];
}
- pushRenderTypeMask();
- andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
- LLPipeline::RENDER_TYPE_ALPHA,
- LLPipeline::RENDER_TYPE_GRASS,
- LLPipeline::RENDER_TYPE_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_BUMP,
- LLPipeline::RENDER_TYPE_VOLUME,
- LLPipeline::RENDER_TYPE_AVATAR,
- LLPipeline::RENDER_TYPE_TREE,
- LLPipeline::RENDER_TYPE_TERRAIN,
- LLPipeline::RENDER_TYPE_WATER,
- LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW,
- LLPipeline::RENDER_TYPE_PASS_SIMPLE,
- LLPipeline::RENDER_TYPE_PASS_BUMP,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_PASS_SHINY,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
- END_RENDER_TYPES);
+ U32 type_mask = mRenderTypeMask;
+ mRenderTypeMask = type_mask & ((1<<LLPipeline::RENDER_TYPE_SIMPLE) |
+ (1<<LLPipeline::RENDER_TYPE_ALPHA) |
+ (1<<LLPipeline::RENDER_TYPE_GRASS) |
+ (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
+ (1<<LLPipeline::RENDER_TYPE_BUMP) |
+ (1<<LLPipeline::RENDER_TYPE_VOLUME) |
+ (1<<LLPipeline::RENDER_TYPE_AVATAR) |
+ (1<<LLPipeline::RENDER_TYPE_TREE) |
+ (1<<LLPipeline::RENDER_TYPE_TERRAIN) |
+ (1<<LLPipeline::RENDER_TYPE_WATER) |
+ (1<<LLPipeline::RENDER_TYPE_PASS_ALPHA_SHADOW) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_BUMP) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY));
gGL.setColorMask(false, false);
@@ -8127,32 +7986,17 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
at.normVec();
- LLCamera main_camera = camera;
-
F32 near_clip = 0.f;
{
//get visible point cloud
std::vector<LLVector3> fp;
- main_camera.calcAgentFrustumPlanes(main_camera.mAgentFrustum);
-
LLVector3 min,max;
- getVisiblePointCloud(main_camera,min,max,fp);
+ getVisiblePointCloud(camera,min,max,fp);
if (fp.empty())
{
- if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA))
- {
- mShadowCamera[0] = main_camera;
- mShadowExtents[0][0] = min;
- mShadowExtents[0][1] = max;
-
- mShadowFrustPoints[0].clear();
- mShadowFrustPoints[1].clear();
- mShadowFrustPoints[2].clear();
- mShadowFrustPoints[3].clear();
- }
- popRenderTypeMask();
+ mRenderTypeMask = type_mask;
return;
}
@@ -8226,7 +8070,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
shadow_cam = camera;
shadow_cam.setFar(16.f);
- LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
+ LLViewerCamera::updateFrustumPlanes(shadow_cam);
LLVector3* frust = shadow_cam.mAgentFrustum;
@@ -8238,11 +8082,10 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
for (U32 i = 0; i < 4; i++)
{
LLVector3 delta = frust[i+4]-eye;
- delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f;
delta.normVec();
F32 dp = delta*pn;
- frust[i] = eye + (delta*dist[j]*0.95f)/dp;
- frust[i+4] = eye + (delta*dist[j+1]*1.05f)/dp;
+ frust[i] = eye + (delta*dist[j])/dp;
+ frust[i+4] = eye + (delta*dist[j+1])/dp;
}
shadow_cam.calcAgentFrustumPlanes(frust);
@@ -8583,13 +8426,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
}
- //hack to disable projector shadows
- static bool clear = true;
- bool gen_shadow = gSavedSettings.getS32("RenderShadowDetail") > 1;
- if (gen_shadow)
- {
- clear = true;
F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
//update shadow targets
@@ -8717,20 +8554,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
mShadow[i+4].flush();
}
- }
- else
- {
- if (clear)
- {
- clear = false;
- for (U32 i = 4; i < 6; i++)
- {
- mShadow[i].bindTarget();
- mShadow[i].clear();
- mShadow[i].flush();
- }
- }
- }
if (!gSavedSettings.getBOOL("CameraOffset"))
{
@@ -8754,7 +8577,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
gGLLastProjection[i] = last_projection[i];
}
- popRenderTypeMask();
+ mRenderTypeMask = type_mask;
}
void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture)
@@ -8790,36 +8613,38 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
assertInitialized();
+ U32 mask;
BOOL muted = LLMuteList::getInstance()->isMuted(avatar->getID());
- pushRenderTypeMask();
-
if (muted)
{
- andRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, END_RENDER_TYPES);
+ mask = 1 << LLPipeline::RENDER_TYPE_AVATAR;
}
else
{
- andRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME,
- LLPipeline::RENDER_TYPE_AVATAR,
- LLPipeline::RENDER_TYPE_BUMP,
- LLPipeline::RENDER_TYPE_GRASS,
- LLPipeline::RENDER_TYPE_SIMPLE,
- LLPipeline::RENDER_TYPE_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_ALPHA,
- LLPipeline::RENDER_TYPE_INVISIBLE,
- LLPipeline::RENDER_TYPE_PASS_SIMPLE,
- LLPipeline::RENDER_TYPE_PASS_ALPHA,
- LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK,
- LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY,
- LLPipeline::RENDER_TYPE_PASS_SHINY,
- LLPipeline::RENDER_TYPE_PASS_INVISIBLE,
- LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY,
- END_RENDER_TYPES);
+ mask = (1<<LLPipeline::RENDER_TYPE_VOLUME) |
+ (1<<LLPipeline::RENDER_TYPE_AVATAR) |
+ (1<<LLPipeline::RENDER_TYPE_BUMP) |
+ (1<<LLPipeline::RENDER_TYPE_GRASS) |
+ (1<<LLPipeline::RENDER_TYPE_SIMPLE) |
+ (1<<LLPipeline::RENDER_TYPE_FULLBRIGHT) |
+ (1<<LLPipeline::RENDER_TYPE_ALPHA) |
+ (1<<LLPipeline::RENDER_TYPE_INVISIBLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SIMPLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_FULLBRIGHT_SHINY) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_SHINY) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_INVISIBLE) |
+ (1 << LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY);
}
+ mask = mask & gPipeline.getRenderTypeMask();
+ U32 saved_mask = gPipeline.mRenderTypeMask;
+ gPipeline.mRenderTypeMask = mask;
+
S32 occlusion = sUseOcclusion;
sUseOcclusion = 0;
sReflectionRender = sRenderDeferred ? FALSE : TRUE;
@@ -8993,7 +8818,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
sReflectionRender = FALSE;
sImpostorRender = FALSE;
sShadowRender = FALSE;
- popRenderTypeMask();
+ gPipeline.mRenderTypeMask = saved_mask;
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@@ -9034,121 +8859,4 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
return sCull->endAlphaGroups();
}
-BOOL LLPipeline::hasRenderType(const U32 type) const
-{
- return mRenderTypeEnabled[type];
-}
-
-void LLPipeline::setRenderTypeMask(U32 type, ...)
-{
- va_list args;
-
- va_start(args, type);
- while (type < END_RENDER_TYPES)
- {
- mRenderTypeEnabled[type] = TRUE;
- type = va_arg(args, U32);
- }
- va_end(args);
-
- if (type > END_RENDER_TYPES)
- {
- llerrs << "Invalid render type." << llendl;
- }
-}
-
-BOOL LLPipeline::hasAnyRenderType(U32 type, ...) const
-{
- va_list args;
-
- va_start(args, type);
- while (type < END_RENDER_TYPES)
- {
- if (mRenderTypeEnabled[type])
- {
- return TRUE;
- }
- type = va_arg(args, U32);
- }
- va_end(args);
-
- if (type > END_RENDER_TYPES)
- {
- llerrs << "Invalid render type." << llendl;
- }
-
- return FALSE;
-}
-
-void LLPipeline::pushRenderTypeMask()
-{
- std::string cur_mask;
- cur_mask.assign((const char*) mRenderTypeEnabled, sizeof(mRenderTypeEnabled));
- mRenderTypeEnableStack.push(cur_mask);
-}
-
-void LLPipeline::popRenderTypeMask()
-{
- if (mRenderTypeEnableStack.empty())
- {
- llerrs << "Depleted render type stack." << llendl;
- }
-
- memcpy(mRenderTypeEnabled, mRenderTypeEnableStack.top().data(), sizeof(mRenderTypeEnabled));
- mRenderTypeEnableStack.pop();
-}
-
-void LLPipeline::andRenderTypeMask(U32 type, ...)
-{
- va_list args;
-
- BOOL tmp[NUM_RENDER_TYPES];
- for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
- {
- tmp[i] = FALSE;
- }
-
- va_start(args, type);
- while (type < END_RENDER_TYPES)
- {
- if (mRenderTypeEnabled[type])
- {
- tmp[type] = TRUE;
- }
-
- type = va_arg(args, U32);
- }
- va_end(args);
-
- if (type > END_RENDER_TYPES)
- {
- llerrs << "Invalid render type." << llendl;
- }
-
- for (U32 i = 0; i < LLPipeline::NUM_RENDER_TYPES; ++i)
- {
- mRenderTypeEnabled[i] = tmp[i];
- }
-
-}
-
-void LLPipeline::clearRenderTypeMask(U32 type, ...)
-{
- va_list args;
-
- va_start(args, type);
- while (type < END_RENDER_TYPES)
- {
- mRenderTypeEnabled[type] = FALSE;
-
- type = va_arg(args, U32);
- }
- va_end(args);
-
- if (type > END_RENDER_TYPES)
- {
- llerrs << "Invalid render type." << llendl;
- }
-}
-