lldrawpoolsimple.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /**
  2. * @file lldrawpoolsimple.cpp
  3. * @brief LLDrawPoolSimple class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  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
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "lldrawpoolsimple.h"
  34. #include "llfasttimer.h"
  35. #include "llrender.h"
  36. #include "lldrawable.h"
  37. #include "llface.h"
  38. #include "llpipeline.h"
  39. #include "llsky.h"
  40. #include "llspatialpartition.h"
  41. #include "llviewercamera.h"
  42. #include "llviewershadermgr.h"
  43. // Only used by the EE renderer.
  44. static LLGLSLShader* sSimpleShader = NULL;
  45. // Helper functions
  46. static void setup_simple_shader(LLGLSLShader* shaderp)
  47. {
  48. shaderp->bind();
  49. if (!gUsePBRShaders)
  50. {
  51. S32 no_atmo = LLPipeline::sRenderingHUDs ? 1 : 0;
  52. shaderp->uniform1i(LLShaderMgr::NO_ATMO, no_atmo);
  53. }
  54. }
  55. static void setup_glow_shader(LLGLSLShader* shaderp)
  56. {
  57. shaderp->bind();
  58. if (gUsePBRShaders)
  59. {
  60. if (LLPipeline::sRenderingHUDs)
  61. {
  62. shaderp->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.f);
  63. }
  64. else
  65. {
  66. shaderp->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f);
  67. }
  68. return;
  69. }
  70. if (LLPipeline::sRenderingHUDs)
  71. {
  72. shaderp->uniform1i(LLShaderMgr::NO_ATMO, 1);
  73. shaderp->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.f);
  74. return;
  75. }
  76. shaderp->uniform1i(LLShaderMgr::NO_ATMO, 0);
  77. if (LLPipeline::sRenderDeferred)
  78. {
  79. shaderp->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f);
  80. }
  81. else
  82. {
  83. shaderp->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.f);
  84. }
  85. }
  86. static void setup_fullbright_shader(LLGLSLShader* shaderp)
  87. {
  88. setup_glow_shader(shaderp);
  89. if (gUsePBRShaders)
  90. {
  91. S32 channel = shaderp->enableTexture(LLShaderMgr::EXPOSURE_MAP);
  92. if (channel > -1)
  93. {
  94. gGL.getTexUnit(channel)->bind(&gPipeline.mExposureMap);
  95. }
  96. }
  97. shaderp->uniform1f(LLViewerShaderMgr::FULLBRIGHT, 1.f);
  98. }
  99. ///////////////////////////////////////////////////////////////////////////////
  100. // LLDrawPoolSimple class
  101. ///////////////////////////////////////////////////////////////////////////////
  102. LLDrawPoolSimple::LLDrawPoolSimple()
  103. : LLRenderPass(POOL_SIMPLE)
  104. {
  105. }
  106. //virtual
  107. void LLDrawPoolSimple::prerender()
  108. {
  109. mShaderLevel =
  110. gViewerShaderMgrp->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
  111. }
  112. // Only for use with the EE renderer
  113. //virtual
  114. void LLDrawPoolSimple::render(S32)
  115. {
  116. LL_FAST_TIMER(FTM_RENDER_SIMPLE);
  117. LLGLDisable blend(GL_BLEND);
  118. LLGLSLShader* shaderp;
  119. if (LLPipeline::sImpostorRender)
  120. {
  121. shaderp = &gObjectSimpleImpostorProgram;
  122. }
  123. else if (LLPipeline::sUnderWaterRender)
  124. {
  125. shaderp = &gObjectSimpleWaterProgram;
  126. }
  127. else
  128. {
  129. shaderp = &gObjectSimpleProgram;
  130. }
  131. gPipeline.enableLightsDynamic();
  132. U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX;
  133. // First pass: static objects
  134. setup_simple_shader(shaderp);
  135. pushBatches(PASS_SIMPLE, mask, true, true);
  136. if (LLPipeline::sRenderDeferred)
  137. {
  138. // If deferred rendering is enabled, bump faces are not registered as
  139. // simple render bump faces here as simple so bump faces will appear
  140. // under water
  141. pushBatches(PASS_BUMP, mask, true, true);
  142. pushBatches(PASS_MATERIAL, mask, true, true);
  143. pushBatches(PASS_SPECMAP, mask, true, true);
  144. pushBatches(PASS_NORMMAP, mask, true, true);
  145. pushBatches(PASS_NORMSPEC, mask, true, true);
  146. }
  147. // Second pass: rigged objects
  148. if (!shaderp->mRiggedVariant) // Paranoia
  149. {
  150. return;
  151. }
  152. setup_simple_shader(shaderp->mRiggedVariant);
  153. pushRiggedBatches(PASS_SIMPLE_RIGGED, mask, true, true);
  154. if (LLPipeline::sRenderDeferred)
  155. {
  156. // If deferred rendering is enabled, bump faces are not registered as
  157. // simple render bump faces here as simple so bump faces will appear
  158. // under water
  159. pushRiggedBatches(PASS_BUMP_RIGGED, mask, true, true);
  160. pushRiggedBatches(PASS_MATERIAL_RIGGED, mask, true, true);
  161. pushRiggedBatches(PASS_SPECMAP_RIGGED, mask, true, true);
  162. pushRiggedBatches(PASS_NORMMAP_RIGGED, mask, true, true);
  163. pushRiggedBatches(PASS_NORMSPEC_RIGGED, mask, true, true);
  164. }
  165. }
  166. //virtual
  167. void LLDrawPoolSimple::renderDeferred(S32)
  168. {
  169. LL_FAST_TIMER(FTM_RENDER_SIMPLE);
  170. LLGLDisable blend(GL_BLEND);
  171. LLGLSLShader* shaderp = &gDeferredDiffuseProgram;
  172. // Note: mask ignored by the PBR renderer
  173. U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX;
  174. // Render static
  175. setup_simple_shader(shaderp);
  176. pushBatches(PASS_SIMPLE, mask, true, true);
  177. // Render rigged
  178. if (!shaderp->mRiggedVariant) // Paranoia
  179. {
  180. return;
  181. }
  182. setup_simple_shader(shaderp->mRiggedVariant);
  183. pushRiggedBatches(PASS_SIMPLE_RIGGED, mask, true, true);
  184. }
  185. ///////////////////////////////////////////////////////////////////////////////
  186. // LLDrawPoolGrass class
  187. ///////////////////////////////////////////////////////////////////////////////
  188. // Grass drawpool
  189. LLDrawPoolGrass::LLDrawPoolGrass()
  190. : LLRenderPass(POOL_GRASS)
  191. {
  192. }
  193. //virtual
  194. void LLDrawPoolGrass::prerender()
  195. {
  196. mShaderLevel =
  197. gViewerShaderMgrp->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
  198. }
  199. //virtual
  200. void LLDrawPoolGrass::beginRenderPass(S32)
  201. {
  202. LL_FAST_TIMER(FTM_RENDER_GRASS);
  203. stop_glerror();
  204. if (LLPipeline::sUnderWaterRender)
  205. {
  206. sSimpleShader = &gObjectAlphaMaskNonIndexedWaterProgram;
  207. }
  208. else
  209. {
  210. sSimpleShader = &gObjectAlphaMaskNonIndexedProgram;
  211. }
  212. if (mShaderLevel > 0)
  213. {
  214. sSimpleShader->bind();
  215. sSimpleShader->setMinimumAlpha(0.5f);
  216. S32 no_atmo = LLPipeline::sRenderingHUDs ? 1 : 0;
  217. sSimpleShader->uniform1i(LLShaderMgr::NO_ATMO, no_atmo);
  218. }
  219. else
  220. {
  221. // Do not use shaders !
  222. LLGLSLShader::unbind(); // Also calls gGL.flush()
  223. }
  224. }
  225. //virtual
  226. void LLDrawPoolGrass::endRenderPass(S32 pass)
  227. {
  228. LL_FAST_TIMER(FTM_RENDER_GRASS);
  229. LLRenderPass::endRenderPass(pass);
  230. if (mShaderLevel > 0)
  231. {
  232. sSimpleShader->unbind();
  233. }
  234. else
  235. {
  236. gGL.flush();
  237. }
  238. }
  239. // Only for use with the EE renderer
  240. //virtual
  241. void LLDrawPoolGrass::render(S32)
  242. {
  243. LL_FAST_TIMER(FTM_RENDER_GRASS);
  244. LLGLDisable blend(GL_BLEND);
  245. gGL.setSceneBlendType(LLRender::BT_ALPHA);
  246. // Render grass
  247. LLRenderPass::pushBatches(PASS_GRASS, getVertexDataMask());
  248. }
  249. //virtual
  250. void LLDrawPoolGrass::renderDeferred(S32)
  251. {
  252. LL_FAST_TIMER(FTM_RENDER_GRASS);
  253. LLGLSLShader* shaderp = &gDeferredNonIndexedDiffuseAlphaMaskProgram;
  254. shaderp->bind();
  255. shaderp->setMinimumAlpha(0.5f);
  256. if (!gUsePBRShaders)
  257. {
  258. S32 no_atmo = LLPipeline::sRenderingHUDs ? 1 : 0;
  259. shaderp->uniform1i(LLShaderMgr::NO_ATMO, no_atmo);
  260. }
  261. // Render grass
  262. LLRenderPass::pushBatches(PASS_GRASS, getVertexDataMask());
  263. }
  264. ///////////////////////////////////////////////////////////////////////////////
  265. // LLDrawPoolAlphaMask class
  266. ///////////////////////////////////////////////////////////////////////////////
  267. LLDrawPoolAlphaMask::LLDrawPoolAlphaMask()
  268. : LLRenderPass(POOL_ALPHA_MASK)
  269. {
  270. }
  271. //virtual
  272. void LLDrawPoolAlphaMask::prerender()
  273. {
  274. mShaderLevel =
  275. gViewerShaderMgrp->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
  276. }
  277. // Only for use with the EE renderer
  278. //virtual
  279. void LLDrawPoolAlphaMask::render(S32 pass)
  280. {
  281. LL_TRACY_TIMER(TRC_RENDER_ALPHA_MASK);
  282. LLGLDisable blend(GL_BLEND);
  283. LLGLSLShader* shaderp = LLPipeline::sUnderWaterRender ?
  284. &gObjectSimpleWaterAlphaMaskProgram :
  285. &gObjectSimpleAlphaMaskProgram;
  286. U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX;
  287. // Render static
  288. setup_simple_shader(shaderp);
  289. pushMaskBatches(PASS_ALPHA_MASK, mask, true, true);
  290. pushMaskBatches(PASS_MATERIAL_ALPHA_MASK, mask, true, true);
  291. pushMaskBatches(PASS_SPECMAP_MASK, mask, true, true);
  292. pushMaskBatches(PASS_NORMMAP_MASK, mask, true, true);
  293. pushMaskBatches(PASS_NORMSPEC_MASK, mask, true, true);
  294. // Render rigged
  295. if (!shaderp->mRiggedVariant) // Paranoia
  296. {
  297. return;
  298. }
  299. setup_simple_shader(shaderp->mRiggedVariant);
  300. pushRiggedMaskBatches(PASS_ALPHA_MASK_RIGGED, mask, true, true);
  301. pushRiggedMaskBatches(PASS_MATERIAL_ALPHA_MASK_RIGGED, mask, true, true);
  302. pushRiggedMaskBatches(PASS_SPECMAP_MASK_RIGGED, mask, true, true);
  303. pushRiggedMaskBatches(PASS_NORMMAP_MASK_RIGGED, mask, true, true);
  304. pushRiggedMaskBatches(PASS_NORMSPEC_MASK_RIGGED, mask, true, true);
  305. }
  306. //virtual
  307. void LLDrawPoolAlphaMask::renderDeferred(S32)
  308. {
  309. LL_FAST_TIMER(FTM_RENDER_GRASS);
  310. LLGLSLShader* shaderp = &gDeferredDiffuseAlphaMaskProgram;
  311. // Note: mask ignored by the PBR renderer
  312. U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX;
  313. // Render static
  314. setup_simple_shader(shaderp);
  315. pushMaskBatches(PASS_ALPHA_MASK, mask, true, true);
  316. // Render rigged
  317. if (!shaderp->mRiggedVariant) // Paranoia
  318. {
  319. return;
  320. }
  321. setup_simple_shader(shaderp->mRiggedVariant);
  322. pushRiggedMaskBatches(PASS_ALPHA_MASK_RIGGED, mask, true, true);
  323. }
  324. ///////////////////////////////////////////////////////////////////////////////
  325. // LLDrawPoolFullbrightAlphaMask class
  326. ///////////////////////////////////////////////////////////////////////////////
  327. LLDrawPoolFullbrightAlphaMask::LLDrawPoolFullbrightAlphaMask()
  328. : LLRenderPass(POOL_FULLBRIGHT_ALPHA_MASK)
  329. {
  330. }
  331. //virtual
  332. void LLDrawPoolFullbrightAlphaMask::prerender()
  333. {
  334. mShaderLevel =
  335. gViewerShaderMgrp->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
  336. }
  337. // Only for use with the EE renderer
  338. //virtual
  339. void LLDrawPoolFullbrightAlphaMask::render(S32)
  340. {
  341. LL_TRACY_TIMER(TRC_RENDER_ALPHA_MASK);
  342. LLGLSLShader* shaderp = LLPipeline::sUnderWaterRender ?
  343. &gObjectFullbrightWaterAlphaMaskProgram :
  344. &gObjectFullbrightAlphaMaskProgram;
  345. U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX;
  346. // Render static
  347. setup_fullbright_shader(shaderp);
  348. pushMaskBatches(PASS_FULLBRIGHT_ALPHA_MASK, mask, true, true);
  349. // Render rigged
  350. if (!shaderp->mRiggedVariant) // Paranoia
  351. {
  352. return;
  353. }
  354. setup_fullbright_shader(shaderp->mRiggedVariant);
  355. pushRiggedMaskBatches(PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, mask, true, true);
  356. }
  357. //virtual
  358. void LLDrawPoolFullbrightAlphaMask::renderPostDeferred(S32)
  359. {
  360. LL_TRACY_TIMER(TRC_RENDER_FULLBRIGHT);
  361. LLGLSLShader* shaderp;
  362. if (gUsePBRShaders)
  363. {
  364. if (LLPipeline::sRenderingHUDs)
  365. {
  366. shaderp = &gHUDFullbrightAlphaMaskProgram;
  367. }
  368. else
  369. {
  370. shaderp = &gDeferredFullbrightAlphaMaskProgram;
  371. }
  372. }
  373. else if (LLPipeline::sRenderingHUDs || !LLPipeline::sRenderDeferred)
  374. {
  375. shaderp = &gObjectFullbrightAlphaMaskProgram;
  376. }
  377. else if (LLPipeline::sUnderWaterRender)
  378. {
  379. shaderp = &gDeferredFullbrightAlphaMaskWaterProgram;
  380. }
  381. else
  382. {
  383. shaderp = &gDeferredFullbrightAlphaMaskProgram;
  384. }
  385. LLGLDisable blend(GL_BLEND);
  386. // Note: mask ignored by the PBR renderer
  387. constexpr U32 mask = LLVertexBuffer::MAP_VERTEX |
  388. LLVertexBuffer::MAP_TEXCOORD0 |
  389. LLVertexBuffer::MAP_COLOR |
  390. LLVertexBuffer::MAP_TEXTURE_INDEX;
  391. // Render static
  392. setup_fullbright_shader(shaderp);
  393. pushMaskBatches(PASS_FULLBRIGHT_ALPHA_MASK, mask, true, true);
  394. // Render rigged
  395. if (!shaderp->mRiggedVariant || // Paranoia
  396. (gUsePBRShaders && LLPipeline::sRenderingHUDs))
  397. {
  398. return;
  399. }
  400. setup_fullbright_shader(shaderp->mRiggedVariant);
  401. pushRiggedMaskBatches(PASS_FULLBRIGHT_ALPHA_MASK_RIGGED, mask, true, true);
  402. }
  403. ///////////////////////////////////////////////////////////////////////////////
  404. // LLDrawPoolFullbright class
  405. ///////////////////////////////////////////////////////////////////////////////
  406. LLDrawPoolFullbright::LLDrawPoolFullbright()
  407. : LLRenderPass(POOL_FULLBRIGHT)
  408. {
  409. }
  410. //virtual
  411. void LLDrawPoolFullbright::prerender()
  412. {
  413. mShaderLevel =
  414. gViewerShaderMgrp->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
  415. }
  416. // Only for use with the EE renderer
  417. //virtual
  418. void LLDrawPoolFullbright::render(S32)
  419. {
  420. LL_FAST_TIMER(FTM_RENDER_FULLBRIGHT);
  421. gGL.setSceneBlendType(LLRender::BT_ALPHA);
  422. stop_glerror();
  423. LLGLSLShader* shaderp = LLPipeline::sUnderWaterRender ?
  424. &gObjectFullbrightWaterProgram :
  425. &gObjectFullbrightProgram;
  426. constexpr U32 mask = LLVertexBuffer::MAP_VERTEX |
  427. LLVertexBuffer::MAP_TEXCOORD0 |
  428. LLVertexBuffer::MAP_COLOR |
  429. LLVertexBuffer::MAP_TEXTURE_INDEX;
  430. // Render static
  431. setup_fullbright_shader(shaderp);
  432. pushBatches(PASS_FULLBRIGHT, mask, true, true);
  433. pushBatches(PASS_MATERIAL_ALPHA_EMISSIVE, mask, true, true);
  434. pushBatches(PASS_SPECMAP_EMISSIVE, mask, true, true);
  435. pushBatches(PASS_NORMMAP_EMISSIVE, mask, true, true);
  436. pushBatches(PASS_NORMSPEC_EMISSIVE, mask, true, true);
  437. // Render rigged
  438. if (!shaderp->mRiggedVariant) // Paranoia
  439. {
  440. return;
  441. }
  442. setup_fullbright_shader(shaderp->mRiggedVariant);
  443. pushRiggedBatches(PASS_FULLBRIGHT_RIGGED, mask, true, true);
  444. pushRiggedBatches(PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED, mask, true, true);
  445. pushRiggedBatches(PASS_SPECMAP_EMISSIVE_RIGGED, mask, true, true);
  446. pushRiggedBatches(PASS_NORMMAP_EMISSIVE_RIGGED, mask, true, true);
  447. pushRiggedBatches(PASS_NORMSPEC_EMISSIVE_RIGGED, mask, true, true);
  448. }
  449. //virtual
  450. void LLDrawPoolFullbright::renderPostDeferred(S32)
  451. {
  452. LL_FAST_TIMER(FTM_RENDER_FULLBRIGHT);
  453. LLGLSLShader* shaderp;
  454. if (gUsePBRShaders && LLPipeline::sRenderingHUDs)
  455. {
  456. shaderp = &gHUDFullbrightProgram;
  457. }
  458. else if (LLPipeline::sUnderWaterRender && !gUsePBRShaders)
  459. {
  460. shaderp = &gDeferredFullbrightWaterProgram;
  461. }
  462. else
  463. {
  464. shaderp = &gDeferredFullbrightProgram;
  465. }
  466. gGL.setSceneBlendType(LLRender::BT_ALPHA);
  467. // Note: mask ignored by the PBR renderer
  468. constexpr U32 mask = LLVertexBuffer::MAP_VERTEX |
  469. LLVertexBuffer::MAP_TEXCOORD0 |
  470. LLVertexBuffer::MAP_COLOR |
  471. LLVertexBuffer::MAP_TEXTURE_INDEX;
  472. // Render static
  473. setup_fullbright_shader(shaderp);
  474. pushBatches(PASS_FULLBRIGHT, mask, true, true);
  475. // Render rigged
  476. if (!shaderp->mRiggedVariant || // Paranoia
  477. (gUsePBRShaders && LLPipeline::sRenderingHUDs))
  478. {
  479. return;
  480. }
  481. setup_fullbright_shader(shaderp->mRiggedVariant);
  482. pushRiggedBatches(PASS_FULLBRIGHT_RIGGED, mask, true, true);
  483. }
  484. ///////////////////////////////////////////////////////////////////////////////
  485. // LLDrawPoolGlow class
  486. ///////////////////////////////////////////////////////////////////////////////
  487. // Only for use with the EE renderer
  488. //virtual
  489. void LLDrawPoolGlow::render(S32 pass)
  490. {
  491. LL_FAST_TIMER(FTM_RENDER_GLOW);
  492. LLGLSLShader* shaderp =
  493. LLPipeline::sUnderWaterRender ? &gObjectEmissiveWaterProgram
  494. : &gObjectEmissiveProgram;
  495. render(shaderp);
  496. }
  497. //virtual
  498. void LLDrawPoolGlow::renderPostDeferred(S32 pass)
  499. {
  500. render(&gDeferredEmissiveProgram);
  501. }
  502. void LLDrawPoolGlow::render(LLGLSLShader* shaderp)
  503. {
  504. LL_FAST_TIMER(FTM_RENDER_GLOW);
  505. LLGLEnable blend(GL_BLEND);
  506. gGL.flush();
  507. // Get rid of Z-fighting with non-glow pass.
  508. LLGLEnable poly_offset(GL_POLYGON_OFFSET_FILL);
  509. glPolygonOffset(-1.f, -1.f);
  510. gGL.setSceneBlendType(LLRender::BT_ADD);
  511. LLGLDepthTest depth(GL_TRUE, GL_FALSE);
  512. gGL.setColorMask(false, true);
  513. // Note: mask ignored by the PBR renderer
  514. U32 mask = getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX;
  515. // First pass: static objects
  516. setup_glow_shader(shaderp);
  517. pushBatches(PASS_GLOW, mask, true, true);
  518. // Second pass: rigged objects
  519. if (shaderp->mRiggedVariant) // Paranoia
  520. {
  521. setup_glow_shader(shaderp->mRiggedVariant);
  522. pushRiggedBatches(PASS_GLOW_RIGGED, mask, true, true);
  523. }
  524. gGL.setColorMask(true, false);
  525. gGL.setSceneBlendType(LLRender::BT_ALPHA);
  526. }