aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolbump.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:50 -0500
committerJacek Antonelli2008-08-15 23:45:50 -0500
commit2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch)
tree95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/newview/lldrawpoolbump.cpp
parentSecond Life viewer sources 1.20.6 (diff)
downloadmeta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz
Second Life viewer sources 1.20.7
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lldrawpoolbump.cpp97
1 files changed, 35 insertions, 62 deletions
diff --git a/linden/indra/newview/lldrawpoolbump.cpp b/linden/indra/newview/lldrawpoolbump.cpp
index 7e8b9d6..303b8d5 100644
--- a/linden/indra/newview/lldrawpoolbump.cpp
+++ b/linden/indra/newview/lldrawpoolbump.cpp
@@ -41,7 +41,7 @@
41#include "m4math.h" 41#include "m4math.h"
42#include "v4math.h" 42#include "v4math.h"
43#include "llglheaders.h" 43#include "llglheaders.h"
44#include "llglimmediate.h" 44#include "llrender.h"
45 45
46#include "llagent.h" 46#include "llagent.h"
47#include "llcubemap.h" 47#include "llcubemap.h"
@@ -100,7 +100,7 @@ void LLStandardBumpmap::restoreGL()
100 gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness"); // BE_DARKNESS 100 gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness"); // BE_DARKNESS
101 101
102 std::string file_name = gDirUtilp->getExpandedFilename( LL_PATH_APP_SETTINGS, "std_bump.ini" ); 102 std::string file_name = gDirUtilp->getExpandedFilename( LL_PATH_APP_SETTINGS, "std_bump.ini" );
103 FILE* file = LLFile::fopen( file_name.c_str(), "rt" ); /*Flawfinder: ignore*/ 103 LLFILE* file = LLFile::fopen( file_name.c_str(), "rt" ); /*Flawfinder: ignore*/
104 if( !file ) 104 if( !file )
105 { 105 {
106 llwarns << "Could not open std_bump <" << file_name << ">" << llendl; 106 llwarns << "Could not open std_bump <" << file_name << ">" << llendl;
@@ -371,17 +371,8 @@ void LLDrawPoolBump::beginShiny(bool invisible)
371 cube_map->setMatrix(0); 371 cube_map->setMatrix(0);
372 cube_map->bind(); 372 cube_map->bind();
373 373
374 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 374 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR);
375 375 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_ALPHA);
376 //use RGB from texture
377 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
378 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
379 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
380
381 // use alpha from color
382 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
383 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR);
384 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
385 } 376 }
386 } 377 }
387} 378}
@@ -443,15 +434,17 @@ void LLDrawPoolBump::endShiny(bool invisible)
443 } 434 }
444 435
445 shader->unbind(); 436 shader->unbind();
446 glActiveTextureARB(GL_TEXTURE0_ARB); 437 gGL.getTexUnit(0)->activate();
447 glEnable(GL_TEXTURE_2D); 438 glEnable(GL_TEXTURE_2D);
448 } 439 }
449 440 if (cube_channel >= 0)
450 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 441 {
442 gGL.getTexUnit(cube_channel)->setTextureBlendType(LLTexUnit::TB_MULT);
443 }
451 } 444 }
452 445
453 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 446 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
454 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 447 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
455 448
456 diffuse_channel = -1; 449 diffuse_channel = -1;
457 cube_channel = 0; 450 cube_channel = 0;
@@ -540,16 +533,16 @@ void LLDrawPoolBump::endFullbrightShiny()
540 { 533 {
541 shader->disableTexture(LLShaderMgr::DIFFUSE_MAP); 534 shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
542 } 535 }
543 glActiveTextureARB(GL_TEXTURE0_ARB); 536 gGL.getTexUnit(0)->activate();
544 glEnable(GL_TEXTURE_2D); 537 glEnable(GL_TEXTURE_2D);
545 538
546 shader->unbind(); 539 shader->unbind();
547 540
548 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 541 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
549 } 542 }
550 543
551 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 544 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
552 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 545 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
553 546
554 diffuse_channel = -1; 547 diffuse_channel = -1;
555 cube_channel = 0; 548 cube_channel = 0;
@@ -650,37 +643,18 @@ void LLDrawPoolBump::beginBump()
650 643
651 // TEXTURE UNIT 0 644 // TEXTURE UNIT 0
652 // Output.rgb = texture at texture coord 0 645 // Output.rgb = texture at texture coord 0
653 glActiveTextureARB(GL_TEXTURE0_ARB); 646 gGL.getTexUnit(0)->activate();
654
655 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
656 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
657
658 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
659 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_ALPHA);
660 647
661 // Don't care about alpha output 648 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA);
662 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); 649 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA);
663 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
664 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
665 650
666 // TEXTURE UNIT 1 651 // TEXTURE UNIT 1
667 glActiveTextureARB(GL_TEXTURE1_ARB); 652 gGL.getTexUnit(1)->activate();
668 653
669 glEnable(GL_TEXTURE_2D); // Texture unit 1 654 glEnable(GL_TEXTURE_2D); // Texture unit 1
670 655
671 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 656 gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA);
672 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB); 657 gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA);
673
674 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
675 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
676
677 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
678 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA);
679
680 // Don't care about alpha output
681 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
682 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
683 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
684 658
685 // src = tex0 + (1 - tex1) - 0.5 659 // src = tex0 + (1 - tex1) - 0.5
686 // = (bump0/2 + 0.5) + (1 - (bump1/2 + 0.5)) - 0.5 660 // = (bump0/2 + 0.5) + (1 - (bump1/2 + 0.5)) - 0.5
@@ -692,9 +666,8 @@ void LLDrawPoolBump::beginBump()
692 // = 2 * ((1 + bump0 - bump1) / 2) * dst [0 - 2 * dst] 666 // = 2 * ((1 + bump0 - bump1) / 2) * dst [0 - 2 * dst]
693 // = (1 + bump0 - bump1) * dst.rgb 667 // = (1 + bump0 - bump1) * dst.rgb
694 // = dst.rgb + dst.rgb * (bump0 - bump1) 668 // = dst.rgb + dst.rgb * (bump0 - bump1)
695 gGL.blendFunc(GL_DST_COLOR, GL_SRC_COLOR); 669 gGL.setSceneBlendType(LLRender::BT_MULT_X2);
696// gGL.blendFunc(GL_ONE, GL_ZERO); // temp 670 gGL.getTexUnit(0)->activate();
697 glActiveTextureARB(GL_TEXTURE0_ARB);
698 stop_glerror(); 671 stop_glerror();
699 672
700 LLViewerImage::unbindTexture(1, GL_TEXTURE_2D); 673 LLViewerImage::unbindTexture(1, GL_TEXTURE_2D);
@@ -728,15 +701,15 @@ void LLDrawPoolBump::endBump()
728 } 701 }
729 702
730 // Disable texture unit 1 703 // Disable texture unit 1
731 glActiveTextureARB(GL_TEXTURE1_ARB); 704 gGL.getTexUnit(1)->activate();
732 glDisable(GL_TEXTURE_2D); // Texture unit 1 705 glDisable(GL_TEXTURE_2D); // Texture unit 1
733 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 706 gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT);
734 707
735 // Disable texture unit 0 708 // Disable texture unit 0
736 glActiveTextureARB(GL_TEXTURE0_ARB); 709 gGL.getTexUnit(0)->activate();
737 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 710 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
738 711
739 gGL.blendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 712 gGL.setSceneBlendType(LLRender::BT_ALPHA);
740} 713}
741 714
742//////////////////////////////////////////////////////////////// 715////////////////////////////////////////////////////////////////
@@ -1101,16 +1074,16 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
1101 { 1074 {
1102 if (mShiny) 1075 if (mShiny)
1103 { 1076 {
1104 glActiveTextureARB(GL_TEXTURE0_ARB); 1077 gGL.getTexUnit(0)->activate();
1105 glMatrixMode(GL_TEXTURE); 1078 glMatrixMode(GL_TEXTURE);
1106 } 1079 }
1107 else 1080 else
1108 { 1081 {
1109 glActiveTextureARB(GL_TEXTURE1_ARB); 1082 gGL.getTexUnit(1)->activate();
1110 glMatrixMode(GL_TEXTURE); 1083 glMatrixMode(GL_TEXTURE);
1111 glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); 1084 glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
1112 gPipeline.mTextureMatrixOps++; 1085 gPipeline.mTextureMatrixOps++;
1113 glActiveTextureARB(GL_TEXTURE0_ARB); 1086 gGL.getTexUnit(0)->activate();
1114 } 1087 }
1115 1088
1116 glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); 1089 glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
@@ -1153,13 +1126,13 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
1153 { 1126 {
1154 if (mShiny) 1127 if (mShiny)
1155 { 1128 {
1156 glActiveTextureARB(GL_TEXTURE0_ARB); 1129 gGL.getTexUnit(0)->activate();
1157 } 1130 }
1158 else 1131 else
1159 { 1132 {
1160 glActiveTextureARB(GL_TEXTURE1_ARB); 1133 gGL.getTexUnit(1)->activate();
1161 glLoadIdentity(); 1134 glLoadIdentity();
1162 glActiveTextureARB(GL_TEXTURE0_ARB); 1135 gGL.getTexUnit(0)->activate();
1163 } 1136 }
1164 glLoadIdentity(); 1137 glLoadIdentity();
1165 glMatrixMode(GL_MODELVIEW); 1138 glMatrixMode(GL_MODELVIEW);
@@ -1172,9 +1145,9 @@ void LLDrawPoolInvisible::render(S32 pass)
1172 1145
1173 U32 invisi_mask = LLVertexBuffer::MAP_VERTEX; 1146 U32 invisi_mask = LLVertexBuffer::MAP_VERTEX;
1174 glStencilMask(0); 1147 glStencilMask(0);
1175 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 1148 gGL.setColorMask(false, false);
1176 pushBatches(LLRenderPass::PASS_INVISIBLE, invisi_mask, FALSE); 1149 pushBatches(LLRenderPass::PASS_INVISIBLE, invisi_mask, FALSE);
1177 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 1150 gGL.setColorMask(true, false);
1178 glStencilMask(0xFFFFFFFF); 1151 glStencilMask(0xFFFFFFFF);
1179 1152
1180 if (gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)) 1153 if (gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY))