diff options
Diffstat (limited to 'linden/indra/newview/lldrawpoolterrain.cpp')
-rw-r--r-- | linden/indra/newview/lldrawpoolterrain.cpp | 121 |
1 files changed, 78 insertions, 43 deletions
diff --git a/linden/indra/newview/lldrawpoolterrain.cpp b/linden/indra/newview/lldrawpoolterrain.cpp index 6067ac8..2c644b0 100644 --- a/linden/indra/newview/lldrawpoolterrain.cpp +++ b/linden/indra/newview/lldrawpoolterrain.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -73,14 +74,14 @@ LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) : | |||
73 | LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); | 74 | LLUUID("e97cf410-8e61-7005-ec06-629eba4cd1fb")); |
74 | 75 | ||
75 | gGL.getTexUnit(0)->bind(mAlphaRampImagep.get()); | 76 | gGL.getTexUnit(0)->bind(mAlphaRampImagep.get()); |
76 | mAlphaRampImagep->setClamp(TRUE, TRUE); | 77 | mAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); |
77 | 78 | ||
78 | m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", | 79 | m2DAlphaRampImagep = gImageList.getImageFromFile("alpha_gradient_2d.j2c", |
79 | TRUE, TRUE, GL_ALPHA8, GL_ALPHA, | 80 | TRUE, TRUE, GL_ALPHA8, GL_ALPHA, |
80 | LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); | 81 | LLUUID("38b86f85-2575-52a9-a531-23108d8da837")); |
81 | 82 | ||
82 | gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); | 83 | gGL.getTexUnit(0)->bind(m2DAlphaRampImagep.get()); |
83 | m2DAlphaRampImagep->setClamp(TRUE, TRUE); | 84 | m2DAlphaRampImagep->setAddressMode(LLTexUnit::TAM_CLAMP); |
84 | 85 | ||
85 | mTexturep->setBoostLevel(LLViewerImage::BOOST_TERRAIN); | 86 | mTexturep->setBoostLevel(LLViewerImage::BOOST_TERRAIN); |
86 | 87 | ||
@@ -99,6 +100,18 @@ LLDrawPool *LLDrawPoolTerrain::instancePool() | |||
99 | } | 100 | } |
100 | 101 | ||
101 | 102 | ||
103 | U32 LLDrawPoolTerrain::getVertexDataMask() | ||
104 | { | ||
105 | if (LLPipeline::sShadowRender) | ||
106 | { | ||
107 | return LLVertexBuffer::MAP_VERTEX; | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | return VERTEX_DATA_MASK; | ||
112 | } | ||
113 | } | ||
114 | |||
102 | void LLDrawPoolTerrain::prerender() | 115 | void LLDrawPoolTerrain::prerender() |
103 | { | 116 | { |
104 | mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); | 117 | mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); |
@@ -216,6 +229,60 @@ void LLDrawPoolTerrain::render(S32 pass) | |||
216 | } | 229 | } |
217 | } | 230 | } |
218 | 231 | ||
232 | void LLDrawPoolTerrain::beginDeferredPass(S32 pass) | ||
233 | { | ||
234 | LLFastTimer t(LLFastTimer::FTM_RENDER_TERRAIN); | ||
235 | LLFacePool::beginRenderPass(pass); | ||
236 | |||
237 | sShader = &gDeferredTerrainProgram; | ||
238 | |||
239 | sShader->bind(); | ||
240 | } | ||
241 | |||
242 | void LLDrawPoolTerrain::endDeferredPass(S32 pass) | ||
243 | { | ||
244 | LLFastTimer t(LLFastTimer::FTM_RENDER_TERRAIN); | ||
245 | LLFacePool::endRenderPass(pass); | ||
246 | sShader->unbind(); | ||
247 | } | ||
248 | |||
249 | void LLDrawPoolTerrain::renderDeferred(S32 pass) | ||
250 | { | ||
251 | LLFastTimer t(LLFastTimer::FTM_RENDER_TERRAIN); | ||
252 | if (mDrawFace.empty()) | ||
253 | { | ||
254 | return; | ||
255 | } | ||
256 | renderFullShader(); | ||
257 | } | ||
258 | |||
259 | void LLDrawPoolTerrain::beginShadowPass(S32 pass) | ||
260 | { | ||
261 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TERRAIN); | ||
262 | LLFacePool::beginRenderPass(pass); | ||
263 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
264 | gDeferredShadowProgram.bind(); | ||
265 | } | ||
266 | |||
267 | void LLDrawPoolTerrain::endShadowPass(S32 pass) | ||
268 | { | ||
269 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TERRAIN); | ||
270 | LLFacePool::endRenderPass(pass); | ||
271 | gDeferredShadowProgram.unbind(); | ||
272 | } | ||
273 | |||
274 | void LLDrawPoolTerrain::renderShadow(S32 pass) | ||
275 | { | ||
276 | LLFastTimer t(LLFastTimer::FTM_SHADOW_TERRAIN); | ||
277 | if (mDrawFace.empty()) | ||
278 | { | ||
279 | return; | ||
280 | } | ||
281 | //LLGLEnable offset(GL_POLYGON_OFFSET); | ||
282 | //glCullFace(GL_FRONT); | ||
283 | drawLoop(); | ||
284 | //glCullFace(GL_BACK); | ||
285 | } | ||
219 | 286 | ||
220 | void LLDrawPoolTerrain::renderFullShader() | 287 | void LLDrawPoolTerrain::renderFullShader() |
221 | { | 288 | { |
@@ -359,9 +426,6 @@ void LLDrawPoolTerrain::renderFullShader() | |||
359 | 426 | ||
360 | void LLDrawPoolTerrain::renderFull4TU() | 427 | void LLDrawPoolTerrain::renderFull4TU() |
361 | { | 428 | { |
362 | glEnableClientState(GL_VERTEX_ARRAY); | ||
363 | glEnableClientState(GL_NORMAL_ARRAY); | ||
364 | |||
365 | // Hack! Get the region that this draw pool is rendering from! | 429 | // Hack! Get the region that this draw pool is rendering from! |
366 | LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); | 430 | LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); |
367 | LLVLComposition *compp = regionp->getComposition(); | 431 | LLVLComposition *compp = regionp->getComposition(); |
@@ -389,7 +453,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
389 | // | 453 | // |
390 | gGL.getTexUnit(0)->activate(); | 454 | gGL.getTexUnit(0)->activate(); |
391 | gGL.getTexUnit(0)->bind(detail_texture0p); | 455 | gGL.getTexUnit(0)->bind(detail_texture0p); |
392 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
393 | 456 | ||
394 | glEnable(GL_TEXTURE_GEN_S); | 457 | glEnable(GL_TEXTURE_GEN_S); |
395 | glEnable(GL_TEXTURE_GEN_T); | 458 | glEnable(GL_TEXTURE_GEN_T); |
@@ -408,9 +471,7 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
408 | gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); | 471 | gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); |
409 | gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); | 472 | gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); |
410 | gGL.getTexUnit(1)->activate(); | 473 | gGL.getTexUnit(1)->activate(); |
411 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 474 | |
412 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||
413 | |||
414 | // Care about alpha only | 475 | // Care about alpha only |
415 | gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); | 476 | gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); |
416 | gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); | 477 | gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); |
@@ -422,9 +483,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
422 | gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); | 483 | gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); |
423 | gGL.getTexUnit(2)->activate(); | 484 | gGL.getTexUnit(2)->activate(); |
424 | 485 | ||
425 | glClientActiveTextureARB(GL_TEXTURE2_ARB); | ||
426 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
427 | |||
428 | glEnable(GL_TEXTURE_GEN_S); | 486 | glEnable(GL_TEXTURE_GEN_S); |
429 | glEnable(GL_TEXTURE_GEN_T); | 487 | glEnable(GL_TEXTURE_GEN_T); |
430 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); | 488 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); |
@@ -440,14 +498,12 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
440 | gGL.getTexUnit(3)->bind(detail_texture1p); | 498 | gGL.getTexUnit(3)->bind(detail_texture1p); |
441 | gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); | 499 | gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); |
442 | gGL.getTexUnit(3)->activate(); | 500 | gGL.getTexUnit(3)->activate(); |
443 | glClientActiveTextureARB(GL_TEXTURE3_ARB); | 501 | |
444 | |||
445 | // Set alpha texture and do lighting modulation | 502 | // Set alpha texture and do lighting modulation |
446 | gGL.getTexUnit(3)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_VERT_COLOR); | 503 | gGL.getTexUnit(3)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_VERT_COLOR); |
447 | 504 | ||
448 | gGL.getTexUnit(0)->activate(); | 505 | gGL.getTexUnit(0)->activate(); |
449 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 506 | |
450 | |||
451 | // GL_BLEND disabled by default | 507 | // GL_BLEND disabled by default |
452 | drawLoop(); | 508 | drawLoop(); |
453 | 509 | ||
@@ -458,9 +514,7 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
458 | // | 514 | // |
459 | gGL.getTexUnit(0)->activate(); | 515 | gGL.getTexUnit(0)->activate(); |
460 | gGL.getTexUnit(0)->bind(detail_texture3p); | 516 | gGL.getTexUnit(0)->bind(detail_texture3p); |
461 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
462 | 517 | ||
463 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
464 | glEnable(GL_TEXTURE_GEN_S); | 518 | glEnable(GL_TEXTURE_GEN_S); |
465 | glEnable(GL_TEXTURE_GEN_T); | 519 | glEnable(GL_TEXTURE_GEN_T); |
466 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); | 520 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); |
@@ -476,9 +530,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
476 | gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); | 530 | gGL.getTexUnit(1)->bind(m2DAlphaRampImagep.get()); |
477 | gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); | 531 | gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); |
478 | gGL.getTexUnit(1)->activate(); | 532 | gGL.getTexUnit(1)->activate(); |
479 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | ||
480 | |||
481 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||
482 | 533 | ||
483 | // Set the texture matrix | 534 | // Set the texture matrix |
484 | glMatrixMode(GL_TEXTURE); | 535 | glMatrixMode(GL_TEXTURE); |
@@ -489,7 +540,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
489 | gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); | 540 | gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); |
490 | gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); | 541 | gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); |
491 | 542 | ||
492 | |||
493 | // | 543 | // |
494 | // Stage 2: Interpolate detail2 with existing based on ramp | 544 | // Stage 2: Interpolate detail2 with existing based on ramp |
495 | // | 545 | // |
@@ -497,9 +547,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
497 | gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); | 547 | gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); |
498 | gGL.getTexUnit(2)->activate(); | 548 | gGL.getTexUnit(2)->activate(); |
499 | 549 | ||
500 | glClientActiveTextureARB(GL_TEXTURE2_ARB); | ||
501 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
502 | |||
503 | glEnable(GL_TEXTURE_GEN_S); | 550 | glEnable(GL_TEXTURE_GEN_S); |
504 | glEnable(GL_TEXTURE_GEN_T); | 551 | glEnable(GL_TEXTURE_GEN_T); |
505 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); | 552 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); |
@@ -516,9 +563,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
516 | gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); | 563 | gGL.getTexUnit(3)->enable(LLTexUnit::TT_TEXTURE); |
517 | gGL.getTexUnit(3)->activate(); | 564 | gGL.getTexUnit(3)->activate(); |
518 | 565 | ||
519 | glClientActiveTextureARB(GL_TEXTURE3_ARB); | ||
520 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||
521 | |||
522 | // Set the texture matrix | 566 | // Set the texture matrix |
523 | glMatrixMode(GL_TEXTURE); | 567 | glMatrixMode(GL_TEXTURE); |
524 | glLoadIdentity(); | 568 | glLoadIdentity(); |
@@ -529,7 +573,6 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
529 | gGL.getTexUnit(3)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); | 573 | gGL.getTexUnit(3)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); |
530 | 574 | ||
531 | gGL.getTexUnit(0)->activate(); | 575 | gGL.getTexUnit(0)->activate(); |
532 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
533 | { | 576 | { |
534 | LLGLEnable blend(GL_BLEND); | 577 | LLGLEnable blend(GL_BLEND); |
535 | drawLoop(); | 578 | drawLoop(); |
@@ -540,9 +583,7 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
540 | gGL.getTexUnit(3)->unbind(LLTexUnit::TT_TEXTURE); | 583 | gGL.getTexUnit(3)->unbind(LLTexUnit::TT_TEXTURE); |
541 | gGL.getTexUnit(3)->disable(); | 584 | gGL.getTexUnit(3)->disable(); |
542 | gGL.getTexUnit(3)->activate(); | 585 | gGL.getTexUnit(3)->activate(); |
543 | glClientActiveTextureARB(GL_TEXTURE3_ARB); | 586 | |
544 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
545 | |||
546 | glMatrixMode(GL_TEXTURE); | 587 | glMatrixMode(GL_TEXTURE); |
547 | glLoadIdentity(); | 588 | glLoadIdentity(); |
548 | glMatrixMode(GL_MODELVIEW); | 589 | glMatrixMode(GL_MODELVIEW); |
@@ -550,9 +591,7 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
550 | gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); | 591 | gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); |
551 | gGL.getTexUnit(2)->disable(); | 592 | gGL.getTexUnit(2)->disable(); |
552 | gGL.getTexUnit(2)->activate(); | 593 | gGL.getTexUnit(2)->activate(); |
553 | glClientActiveTextureARB(GL_TEXTURE2_ARB); | 594 | |
554 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
555 | |||
556 | glDisable(GL_TEXTURE_GEN_S); | 595 | glDisable(GL_TEXTURE_GEN_S); |
557 | glDisable(GL_TEXTURE_GEN_T); | 596 | glDisable(GL_TEXTURE_GEN_T); |
558 | glMatrixMode(GL_TEXTURE); | 597 | glMatrixMode(GL_TEXTURE); |
@@ -562,9 +601,7 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
562 | gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); | 601 | gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); |
563 | gGL.getTexUnit(1)->disable(); | 602 | gGL.getTexUnit(1)->disable(); |
564 | gGL.getTexUnit(1)->activate(); | 603 | gGL.getTexUnit(1)->activate(); |
565 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 604 | |
566 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
567 | |||
568 | glMatrixMode(GL_TEXTURE); | 605 | glMatrixMode(GL_TEXTURE); |
569 | glLoadIdentity(); | 606 | glLoadIdentity(); |
570 | glMatrixMode(GL_MODELVIEW); | 607 | glMatrixMode(GL_MODELVIEW); |
@@ -578,9 +615,7 @@ void LLDrawPoolTerrain::renderFull4TU() | |||
578 | gGL.getTexUnit(0)->activate(); | 615 | gGL.getTexUnit(0)->activate(); |
579 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | 616 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
580 | 617 | ||
581 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 618 | |
582 | glDisableClientState(GL_NORMAL_ARRAY); | ||
583 | |||
584 | glDisable(GL_TEXTURE_GEN_S); | 619 | glDisable(GL_TEXTURE_GEN_S); |
585 | glDisable(GL_TEXTURE_GEN_T); | 620 | glDisable(GL_TEXTURE_GEN_T); |
586 | glMatrixMode(GL_TEXTURE); | 621 | glMatrixMode(GL_TEXTURE); |
@@ -855,7 +890,7 @@ void LLDrawPoolTerrain::renderOwnership() | |||
855 | { | 890 | { |
856 | LLFace *facep = *iter; | 891 | LLFace *facep = *iter; |
857 | facep->renderIndexed(LLVertexBuffer::MAP_VERTEX | | 892 | facep->renderIndexed(LLVertexBuffer::MAP_VERTEX | |
858 | LLVertexBuffer::MAP_TEXCOORD); | 893 | LLVertexBuffer::MAP_TEXCOORD0); |
859 | } | 894 | } |
860 | 895 | ||
861 | glMatrixMode(GL_TEXTURE); | 896 | glMatrixMode(GL_TEXTURE); |