diff options
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r-- | indra/newview/pipeline.cpp | 132 |
1 files changed, 120 insertions, 12 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 64d247a202..76414b5e4e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3878,6 +3878,20 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LLGLEnable cull(GL_CULL_FACE); + bool done_atmospherics = LLPipeline::sRenderingHUDs; //skip atmospherics on huds + bool done_water_haze = done_atmospherics; + + // do atmospheric haze just before post water alpha + U32 atmospherics_pass = LLDrawPool::POOL_ALPHA_POST_WATER; + + if (LLPipeline::sUnderWaterRender) + { // if under water, do atmospherics just before the water pass + atmospherics_pass = LLDrawPool::POOL_WATER; + } + + // do water haze just before pre water alpha + U32 water_haze_pass = LLDrawPool::POOL_ALPHA_PRE_WATER; + calcNearbyLights(camera); setupHWLights(); @@ -3897,6 +3911,18 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) cur_type = poolp->getType(); + if (cur_type >= atmospherics_pass && !done_atmospherics) + { // do atmospherics against depth buffer before rendering alpha + doAtmospherics(); + done_atmospherics = true; + } + + if (cur_type >= water_haze_pass && !done_water_haze) + { // do water haze against depth buffer before rendering alpha + doWaterHaze(); + done_water_haze = true; + } + pool_set_t::iterator iter2 = iter1; if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0) { @@ -7877,7 +7903,7 @@ void LLPipeline::renderDeferredLighting() if (RenderDeferredAtmospheric) { // apply sunlight contribution - LLGLSLShader &soften_shader = LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram; + LLGLSLShader &soften_shader = gDeferredSoftenProgram; LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - atmospherics"); LL_PROFILE_GPU_ZONE("atmospherics"); @@ -7906,7 +7932,7 @@ void LLPipeline::renderDeferredLighting() mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); } - unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram); + unbindDeferredShader(gDeferredSoftenProgram); } static LLCachedControl<S32> local_light_count(gSavedSettings, "RenderLocalLightCount", 256); @@ -8058,7 +8084,7 @@ void LLPipeline::renderDeferredLighting() LLVector4a center; center.load3(drawablep->getPositionAgent().mV); - const F32 *c = center.getF32ptr(); + const F32* c = center.getF32ptr(); F32 s = volume->getLightRadius() * 1.5f; sVisibleLightCount++; @@ -8107,8 +8133,8 @@ void LLPipeline::renderDeferredLighting() U32 idx = count - 1; bindDeferredShader(gDeferredMultiLightProgram[idx]); gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat *) light); - gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat *) col); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*)light); + gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*)col); gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; count = 0; @@ -8126,11 +8152,11 @@ void LLPipeline::renderDeferredLighting() for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter) { - LLDrawable *drawablep = *iter; - LLVOVolume *volume = drawablep->getVOVolume(); - LLVector3 center = drawablep->getPositionAgent(); - F32 * c = center.mV; - F32 light_size_final = volume->getLightRadius() * 1.5f; + 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++; @@ -8155,13 +8181,11 @@ void LLPipeline::renderDeferredLighting() } } - gGL.setColorMask(true, true); } { // render non-deferred geometry (alpha, fullbright, glow) LLGLDisable blend(GL_BLEND); - //LLGLDisable stencil(GL_STENCIL_TEST); pushRenderTypeMask(); andRenderTypeMask(LLPipeline::RENDER_TYPE_ALPHA, @@ -8212,6 +8236,90 @@ void LLPipeline::renderDeferredLighting() gGL.setColorMask(true, true); } +void LLPipeline::doAtmospherics() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + + if (RenderDeferredAtmospheric) + { + LLGLEnable blend(GL_BLEND); + gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); + + gGL.setColorMask(true, true); + + // apply haze + LLGLSLShader& haze_shader = gHazeProgram; + + LL_PROFILE_GPU_ZONE("haze"); + bindDeferredShader(haze_shader); + + LLEnvironment& environment = LLEnvironment::instance(); + haze_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + haze_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + + haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); + + LLGLDepthTest depth(GL_FALSE); + + // full screen blit + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + unbindDeferredShader(haze_shader); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + } +} + +void LLPipeline::doWaterHaze() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + + if (RenderDeferredAtmospheric) + { + LLGLEnable blend(GL_BLEND); + gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_SOURCE_ALPHA); + + gGL.setColorMask(true, true); + + // apply haze + LLGLSLShader& haze_shader = gHazeWaterProgram; + + LL_PROFILE_GPU_ZONE("haze"); + bindDeferredShader(haze_shader); + + haze_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); + + static LLStaticHashedString above_water_str("above_water"); + haze_shader.uniform1i(above_water_str, sUnderWaterRender ? -1 : 1); + + if (LLPipeline::sUnderWaterRender) + { + LLGLDepthTest depth(GL_FALSE); + + // full screen blit + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + } + else + { + //render water patches like LLDrawPoolWater does + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); + LLGLDisable cull(GL_CULL_FACE); + + gGLLastMatrix = NULL; + gGL.loadMatrix(gGLModelView); + + mWaterPool->pushFaceGeometry(); + } + + unbindDeferredShader(haze_shader); + + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + } +} + void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) { //construct frustum |