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.cpp262
1 files changed, 179 insertions, 83 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 7a26404138..27672a05cb 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -138,7 +138,7 @@ const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f;
const S32 MAX_OFFSCREEN_GEOMETRY_CHANGES_PER_FRAME = 10;
const U32 REFLECTION_MAP_RES = 128;
-
+const U32 DEFERRED_VB_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1;
// Max number of occluders to search for. JC
const S32 MAX_OCCLUDER_COUNT = 2;
@@ -457,6 +457,8 @@ void LLPipeline::init()
mSpotLightFade[i] = 1.f;
}
+ mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0);
+ mDeferredVB->allocateBuffer(8, 0, true);
setLightingDetail(-1);
}
@@ -535,6 +537,8 @@ void LLPipeline::cleanup()
mMovedBridge.clear();
mInitialized = FALSE;
+
+ mDeferredVB = NULL;
}
//============================================================================
@@ -669,6 +673,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (!addDeferredAttachments(mDeferredScreen)) return false;
if (!mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
+ if (!mFXAABuffer.allocate(nhpo2(resX), nhpo2(resY), GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
#if LL_DARWIN
// As of OS X 10.6.7, Apple doesn't support multiple color formats in a single FBO
@@ -778,6 +783,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
mShadow[i].release();
}
+ mFXAABuffer.release();
mScreen.release();
mDeferredScreen.release(); //make sure to release any render targets that share a depth buffer with mDeferredScreen first
mDeferredDepth.release();
@@ -863,6 +869,7 @@ void LLPipeline::releaseScreenBuffers()
{
mUIScreen.release();
mScreen.release();
+ mFXAABuffer.release();
mPhysicsDisplay.release();
mDeferredScreen.release();
mDeferredDepth.release();
@@ -3493,7 +3500,7 @@ void LLPipeline::renderHighlights()
if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
{
gHighlightProgram.bind();
- gHighlightProgram.vertexAttrib4f(LLViewerShaderMgr::MATERIAL_COLOR,1,1,1,0.5f);
+ gHighlightProgram.uniform4f("highlight_color",1,1,1,0.5f);
}
if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED))
@@ -3525,7 +3532,7 @@ void LLPipeline::renderHighlights()
color.setVec(1.f, 0.f, 0.f, 0.5f);
if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
{
- gHighlightProgram.vertexAttrib4f(LLViewerShaderMgr::MATERIAL_COLOR,1,0,0,0.5f);
+ gHighlightProgram.uniform4f("highlight_color",1,0,0,0.5f);
}
int count = mHighlightFaces.size();
for (S32 i = 0; i < count; i++)
@@ -4119,6 +4126,11 @@ void LLPipeline::renderPhysicsDisplay()
gGL.setColorMask(true, false);
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ gDebugProgram.bind();
+ }
+
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
@@ -4148,8 +4160,13 @@ void LLPipeline::renderPhysicsDisplay()
}
}
-
gGL.flush();
+
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ gDebugProgram.unbind();
+ }
+
mPhysicsDisplay.flush();
}
@@ -4230,6 +4247,11 @@ void LLPipeline::renderDebug()
}
}
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ gUIProgram.bind();
+ }
+
if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA))
{
LLVertexBuffer::unbind();
@@ -4454,6 +4476,10 @@ void LLPipeline::renderDebug()
}
gGL.flush();
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ gUIProgram.unbind();
+ }
gPipeline.renderPhysicsDisplay();
}
@@ -6121,8 +6147,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
{
LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM);
if (!(gPipeline.canUseVertexShaders() &&
- sRenderGlow) ||
- (!sRenderDeferred && hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)))
+ sRenderGlow))
{
return;
}
@@ -6299,7 +6324,31 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
if (LLPipeline::sRenderDeferred)
{
bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater();
+ {
+ //bake out texture2D with RGBL for FXAA shader
+ mFXAABuffer.bindTarget();
+
+ S32 width = mScreen.getWidth();
+ S32 height = mScreen.getHeight();
+ glViewport(0, 0, width, height);
+
+ gGlowCombineFXAAProgram.bind();
+ gGlowCombineFXAAProgram.uniform2f("screen_res", width, height);
+
+ gGL.getTexUnit(0)->bind(&mGlow[1]);
+ gGL.getTexUnit(1)->bind(&mScreen);
+
+ gGL.begin(LLRender::TRIANGLE_STRIP);
+ gGL.vertex2f(-1,-1);
+ gGL.vertex2f(-1,3);
+ gGL.vertex2f(3,-1);
+ gGL.end();
+ gGlowCombineFXAAProgram.unbind();
+ mFXAABuffer.flush();
+ gViewerWindow->setup3DViewport();
+ }
+
LLGLSLShader* shader = &gDeferredPostProgram;
if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 2)
{
@@ -6316,6 +6365,16 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
LLGLDisable blend(GL_BLEND);
bindDeferredShader(*shader);
+ S32 width = mScreen.getWidth();
+ S32 height = mScreen.getHeight();
+
+ F32 scale_x = (F32) width/mFXAABuffer.getWidth();
+ F32 scale_y = (F32) height/mFXAABuffer.getHeight();
+ shader->uniform2f("tc_scale", scale_x, scale_y);
+ shader->uniform2f("rcp_screen_res", 1.f/width*scale_x, 1.f/height*scale_y);
+ shader->uniform4f("rcp_frame_opt", -0.5f/width*scale_x, -0.5f/height*scale_y, 0.5f/width*scale_x, 0.5f/height*scale_y);
+ shader->uniform4f("rcp_frame_opt2", -2.f/width*scale_x, -2.f/height*scale_y, 2.f/width*scale_x, 2.f/height*scale_y);
+
if (dof_enabled)
{
//depth of field focal plane calculations
@@ -6428,17 +6487,13 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
shader->uniform1f("magnification", magnification);
}
- S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
+ S32 channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP, mFXAABuffer.getUsage());
if (channel > -1)
{
- mScreen.bindTexture(0, channel);
+ mFXAABuffer.bindTexture(0, channel);
+ gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
}
- //channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE);
- //if (channel > -1)
- //{
- //gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
- //}
-
+
gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
gGL.vertex2f(-1,-1);
@@ -6523,19 +6578,13 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
}
- 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);
- }
-
gGL.setSceneBlendType(LLRender::BT_ALPHA);
if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES))
{
if (LLGLSLShader::sNoFixedFunction)
{
- gUIProgram.bind();
+ gSplatTextureRectProgram.bind();
}
gGL.setColorMask(true, false);
@@ -6549,7 +6598,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
gGL.getTexUnit(0)->bind(&mPhysicsDisplay);
- gGL.begin(LLRender::TRIANGLE_STRIP);
+ gGL.begin(LLRender::TRIANGLES);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
gGL.vertex2f(-1,-1);
@@ -6564,10 +6613,17 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
if (LLGLSLShader::sNoFixedFunction)
{
- gUIProgram.unbind();
+ gSplatTextureRectProgram.unbind();
}
+ }
+
+ 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);
}
+
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@@ -6929,6 +6985,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
shader.uniform1f("lum_scale", gSavedSettings.getF32("RenderLuminanceScale"));
shader.uniform1f("sun_lum_scale", gSavedSettings.getF32("RenderSunLuminanceScale"));
shader.uniform1f("sun_lum_offset", gSavedSettings.getF32("RenderSunLuminanceOffset"));
+ shader.uniform3fv("sun_dir", 1, mTransformedSunDir.mV);
shader.uniform1f("lum_lod", gSavedSettings.getF32("RenderLuminanceDetail"));
shader.uniform1f("gi_range", gSavedSettings.getF32("RenderGIRange"));
shader.uniform1f("gi_brightness", gSavedSettings.getF32("RenderGIBrightness"));
@@ -7003,21 +7060,23 @@ void LLPipeline::renderDeferredLighting()
glh::matrix4f mat = glh_copy_matrix(gGLModelView);
- F32 vert[] =
- {
- -1,1,
- -1,-3,
- 3,1,
- };
- glVertexPointer(2, GL_FLOAT, 0, vert);
- glColor3f(1,1,1);
+ LLStrider<LLVector3> vert;
+ mDeferredVB->getVertexStrider(vert);
+ LLStrider<LLVector2> tc0;
+ LLStrider<LLVector2> tc1;
+ mDeferredVB->getTexCoord0Strider(tc0);
+ mDeferredVB->getTexCoord1Strider(tc1);
+ vert[0].set(-1,1,0);
+ vert[1].set(-1,-3,0);
+ vert[2].set(3,1,0);
+
{
setupHWLights(NULL); //to set mSunDir;
LLVector4 dir(mSunDir, 0.f);
glh::vec4f tc(dir.mV);
mat.mult_matrix_vec(tc);
- glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], 0);
+ mTransformedSunDir.set(tc.v);
}
glPushMatrix();
@@ -7032,7 +7091,7 @@ void LLPipeline::renderDeferredLighting()
{ //paint shadow/SSAO light map (direct lighting lightmap)
LLFastTimer ftm(FTM_SUN_SHADOW);
bindDeferredShader(gDeferredSunProgram, 0);
-
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
glClearColor(1,1,1,1);
mDeferredLight[0].clear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,0);
@@ -7063,7 +7122,7 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
stop_glerror();
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
stop_glerror();
}
@@ -7087,7 +7146,8 @@ void LLPipeline::renderDeferredLighting()
gDeferredEdgeProgram.bind();
mEdgeMap.bindTarget();
bindDeferredShader(gDeferredEdgeProgram);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
unbindDeferredShader(gDeferredEdgeProgram);
mEdgeMap.flush();
}
@@ -7109,7 +7169,8 @@ void LLPipeline::renderDeferredLighting()
gLuminanceGatherProgram.uniform2f("screen_res", mDeferredLight[0].getWidth(), mDeferredLight[0].getHeight());
mLuminanceMap.bindTarget();
bindDeferredShader(gLuminanceGatherProgram);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
unbindDeferredShader(gLuminanceGatherProgram);
mLuminanceMap.flush();
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLuminanceMap.getTexture(), true);
@@ -7127,7 +7188,8 @@ void LLPipeline::renderDeferredLighting()
mGIMapPost[0].bindTarget();
bindDeferredShader(gDeferredGIProgram, 0, &mGIMap, 0, mTrueNoiseMap);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
unbindDeferredShader(gDeferredGIProgram);
mGIMapPost[0].flush();
}
@@ -7152,7 +7214,8 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_FALSE);
stop_glerror();
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
stop_glerror();
}
@@ -7167,7 +7230,8 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_FALSE);
stop_glerror();
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
stop_glerror();
}
mGIMapPost[0].flush();
@@ -7181,13 +7245,12 @@ void LLPipeline::renderDeferredLighting()
LLFastTimer ftm(FTM_SOFTEN_SHADOW);
//blur lightmap
mDeferredLight[1].bindTarget();
-
glClearColor(1,1,1,1);
mDeferredLight[1].clear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,0);
bindDeferredShader(gDeferredBlurLightProgram);
-
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian");
const U32 kern_length = 4;
F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize");
@@ -7215,7 +7278,7 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
stop_glerror();
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
stop_glerror();
}
@@ -7223,6 +7286,7 @@ void LLPipeline::renderDeferredLighting()
unbindDeferredShader(gDeferredBlurLightProgram);
bindDeferredShader(gDeferredBlurLightProgram, 1);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
mDeferredLight[0].bindTarget();
gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
@@ -7231,7 +7295,7 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
stop_glerror();
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
stop_glerror();
}
mDeferredLight[0].flush();
@@ -7281,10 +7345,10 @@ void LLPipeline::renderDeferredLighting()
glPushMatrix();
glLoadIdentity();
- glVertexPointer(2, GL_FLOAT, 0, vert);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
@@ -7293,7 +7357,7 @@ void LLPipeline::renderDeferredLighting()
unbindDeferredShader(gDeferredSoftenProgram);
}
- { //render sky
+ { //render non-deferred geometry (fullbright, alpha, etc)
LLGLDisable blend(GL_BLEND);
LLGLDisable stencil(GL_STENCIL_TEST);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -7334,12 +7398,12 @@ void LLPipeline::renderDeferredLighting()
std::list<LLVector4> light_colors;
LLVertexBuffer::unbind();
+ LLVector4a* v = (LLVector4a*) vert.get();
- F32 v[24];
- glVertexPointer(3, GL_FLOAT, 0, v);
-
{
bindDeferredShader(gDeferredLightProgram);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
for (LLDrawable::drawable_set_t::iterator iter = mLights.begin(); iter != mLights.end(); ++iter)
{
@@ -7394,15 +7458,15 @@ void LLPipeline::renderDeferredLighting()
//correspond to their axis facing, with bit position 3,2,1 matching
//axis facing x,y,z, bit set meaning positive facing, bit clear
//meaning negative facing
- v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000
- v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001
- v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010
- v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011
+ v[0].set(c[0]-s,c[1]-s,c[2]-s); // 0 - 0000
+ v[1].set(c[0]-s,c[1]-s,c[2]+s); // 1 - 0001
+ v[2].set(c[0]-s,c[1]+s,c[2]-s); // 2 - 0010
+ v[3].set(c[0]-s,c[1]+s,c[2]+s); // 3 - 0011
- v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100
- v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101
- v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110
- v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111
+ v[4].set(c[0]+s,c[1]-s,c[2]-s); // 4 - 0100
+ v[5].set(c[0]+s,c[1]-s,c[2]+s); // 5 - 0101
+ v[6].set(c[0]+s,c[1]+s,c[2]-s); // 6 - 0110
+ v[7].set(c[0]+s,c[1]+s,c[2]+s); // 7 - 0111
if (camera->getOrigin().mV[0] > c[0] + s + 0.2f ||
camera->getOrigin().mV[0] < c[0] - s - 0.2f ||
@@ -7421,8 +7485,12 @@ void LLPipeline::renderDeferredLighting()
}
LLFastTimer ftm(FTM_LOCAL_LIGHTS);
- glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s);
- glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f);
+ //glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s);
+ gDeferredLightProgram.uniform3fv("center", 1, tc.v);
+ gDeferredLightProgram.uniform1f("size", s*s);
+ gDeferredLightProgram.uniform3fv("color", 1, col.mV);
+ gDeferredLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f);
+ //gGL.diffuseColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f);
glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8,
GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center));
stop_glerror();
@@ -7449,6 +7517,8 @@ void LLPipeline::renderDeferredLighting()
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
bindDeferredShader(gDeferredSpotLightProgram);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+
gDeferredSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION);
for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter)
@@ -7477,18 +7547,20 @@ void LLPipeline::renderDeferredLighting()
//correspond to their axis facing, with bit position 3,2,1 matching
//axis facing x,y,z, bit set meaning positive facing, bit clear
//meaning negative facing
- v[0] = c[0]-s; v[1] = c[1]-s; v[2] = c[2]-s; // 0 - 0000
- v[3] = c[0]-s; v[4] = c[1]-s; v[5] = c[2]+s; // 1 - 0001
- v[6] = c[0]-s; v[7] = c[1]+s; v[8] = c[2]-s; // 2 - 0010
- v[9] = c[0]-s; v[10] = c[1]+s; v[11] = c[2]+s; // 3 - 0011
+ v[0].set(c[0]-s,c[1]-s,c[2]-s); // 0 - 0000
+ v[1].set(c[0]-s,c[1]-s,c[2]+s); // 1 - 0001
+ v[2].set(c[0]-s,c[1]+s,c[2]-s); // 2 - 0010
+ v[3].set(c[0]-s,c[1]+s,c[2]+s); // 3 - 0011
- v[12] = c[0]+s; v[13] = c[1]-s; v[14] = c[2]-s; // 4 - 0100
- v[15] = c[0]+s; v[16] = c[1]-s; v[17] = c[2]+s; // 5 - 0101
- v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110
- v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111
-
- glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s);
- glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f);
+ v[4].set(c[0]+s,c[1]-s,c[2]-s); // 4 - 0100
+ v[5].set(c[0]+s,c[1]-s,c[2]+s); // 5 - 0101
+ v[6].set(c[0]+s,c[1]+s,c[2]-s); // 6 - 0110
+ v[7].set(c[0]+s,c[1]+s,c[2]+s); // 7 - 0111
+
+ gDeferredSpotLightProgram.uniform3fv("center", 1, tc.v);
+ gDeferredSpotLightProgram.uniform1f("size", s*s);
+ gDeferredSpotLightProgram.uniform3fv("color", 1, col.mV);
+ gDeferredSpotLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f);
glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8,
GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center));
}
@@ -7496,9 +7568,16 @@ void LLPipeline::renderDeferredLighting()
unbindDeferredShader(gDeferredSpotLightProgram);
}
+ //reset mDeferredVB to fullscreen triangle
+ vert[0].set(-1,1,0);
+ vert[1].set(-1,-3,0);
+ vert[2].set(3,1,0);
+
{
bindDeferredShader(gDeferredMultiLightProgram);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+
LLGLDepthTest depth(GL_FALSE);
//full screen blit
@@ -7514,7 +7593,7 @@ void LLPipeline::renderDeferredLighting()
LLVector4 light[max_count];
LLVector4 col[max_count];
- glVertexPointer(2, GL_FLOAT, 0, vert);
+// glVertexPointer(2, GL_FLOAT, 0, vert);
F32 far_z = 0.f;
@@ -7537,7 +7616,8 @@ void LLPipeline::renderDeferredLighting()
gDeferredMultiLightProgram.uniform1f("far_z", far_z);
far_z = 0.f;
count = 0;
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
}
}
@@ -7547,6 +7627,8 @@ void LLPipeline::renderDeferredLighting()
gDeferredMultiSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+
for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter)
{
LLFastTimer ftm(FTM_PROJECTORS);
@@ -7568,9 +7650,11 @@ void LLPipeline::renderDeferredLighting()
LLColor3 col = volume->getLightColor();
col *= volume->getLightIntensity();
- glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s);
- glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ gDeferredMultiSpotLightProgram.uniform3fv("center", 1, tc.v);
+ gDeferredMultiSpotLightProgram.uniform1f("size", s*s);
+ gDeferredMultiSpotLightProgram.uniform3fv("color", 1, col.mV);
+ gDeferredMultiSpotLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f);
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
}
gDeferredMultiSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION);
@@ -7603,11 +7687,11 @@ void LLPipeline::renderDeferredLighting()
bindDeferredShader(gDeferredPostProgram, 0, &mGIMapPost[0]);
gDeferredPostProgram.bind();
-
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
LLVertexBuffer::unbind();
- glVertexPointer(2, GL_FLOAT, 0, vert);
- glColor3f(1,1,1);
+// glVertexPointer(2, GL_FLOAT, 0, vert);
+ gGL.diffuseColor3f(1,1,1);
glPushMatrix();
glLoadIdentity();
@@ -7615,8 +7699,8 @@ void LLPipeline::renderDeferredLighting()
glPushMatrix();
glLoadIdentity();
- glDrawArrays(GL_TRIANGLES, 0, 3);
-
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
@@ -8243,7 +8327,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- glColor4f(1,1,1,1);
+ gGL.diffuseColor4f(1,1,1,1);
stop_glerror();
@@ -8287,12 +8371,14 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
gDeferredShadowAlphaMaskProgram.bind();
gDeferredShadowAlphaMaskProgram.setAlphaRange(0.6f, 1.f);
renderObjects(LLRenderPass::PASS_ALPHA_SHADOW, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR, TRUE);
- glColor4f(1,1,1,1);
+ gDeferredTreeShadowProgram.bind();
+ gDeferredTreeShadowProgram.setAlphaRange(0.6f, 1.f);
renderObjects(LLRenderPass::PASS_GRASS, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, TRUE);
}
//glCullFace(GL_BACK);
+ gDeferredShadowProgram.bind();
gGLLastMatrix = NULL;
glLoadMatrixd(gGLModelView);
doOcclusion(shadow_cam);
@@ -9669,6 +9755,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
static const F32 clip_plane = 0.99999f;
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ gUIProgram.bind();
+ }
+
gGL.color4ub(64,64,64,255);
gGL.begin(LLRender::QUADS);
gGL.vertex3f(-1, -1, clip_plane);
@@ -9678,6 +9769,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
gGL.end();
gGL.flush();
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ gUIProgram.unbind();
+ }
+
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();