lldrawpoolmaterials.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * @file lldrawpoolmaterials.h
  3. * @brief LLDrawPoolMaterials and LLDrawPoolMatPBR class definitions
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewergpl$
  6. *
  7. * Copyright (c) 2012-2022, 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. #ifndef LL_LLDRAWPOOLMATERIALS_H
  33. #define LL_LLDRAWPOOLMATERIALS_H
  34. #include "llvector2.h"
  35. #include "llvector3.h"
  36. #include "llcolor4u.h"
  37. #include "lldrawpool.h"
  38. class LLViewerTexture;
  39. class LLDrawInfo;
  40. class LLGLSLShader;
  41. ///////////////////////////////////////////////////////////////////////////////
  42. // LLDrawPoolMaterials class
  43. ///////////////////////////////////////////////////////////////////////////////
  44. class LLDrawPoolMaterials final : public LLRenderPass
  45. {
  46. public:
  47. LLDrawPoolMaterials();
  48. enum
  49. {
  50. VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX |
  51. LLVertexBuffer::MAP_NORMAL |
  52. LLVertexBuffer::MAP_TEXCOORD0 |
  53. LLVertexBuffer::MAP_TEXCOORD1 |
  54. LLVertexBuffer::MAP_TEXCOORD2 |
  55. LLVertexBuffer::MAP_COLOR |
  56. LLVertexBuffer::MAP_TANGENT
  57. };
  58. LL_INLINE U32 getVertexDataMask() override { return VERTEX_DATA_MASK; }
  59. void prerender() override;
  60. // Not used by the EE forward renderer.
  61. LL_INLINE S32 getNumPasses() override { return 0; }
  62. // 12 render passes times 2 (one for each rigged and non rigged)
  63. LL_INLINE S32 getNumDeferredPasses() override { return 24; }
  64. void beginDeferredPass(S32 pass) override;
  65. void endDeferredPass(S32 pass) override;
  66. void renderDeferred(S32 pass) override;
  67. // The following methods are for EE rendering only
  68. void bindSpecularMap(LLViewerTexture* texp);
  69. void bindNormalMap(LLViewerTexture* texp);
  70. private:
  71. // For EE rendering only
  72. void pushMaterialsBatch(LLDrawInfo& params, U32 mask);
  73. // For PBR rendering only
  74. void renderDeferredPBR(S32 pass);
  75. private:
  76. LLGLSLShader* mShader;
  77. };
  78. ///////////////////////////////////////////////////////////////////////////////
  79. // LLDrawPoolMatPBR class
  80. //
  81. // In LL's original code, this class is named LLDrawPoolGLTFPBR and held in a
  82. // separate lldrawpoolpbropaque.h/cpp module. I renamed it for consistency and
  83. // moved it here, where it logically belongs to, since it is used to render PBR
  84. // *materials*. HB
  85. ///////////////////////////////////////////////////////////////////////////////
  86. class LLDrawPoolMatPBR final : public LLRenderPass
  87. {
  88. public:
  89. LLDrawPoolMatPBR(U32 type);
  90. // This value returned by this method is ignored by the PBR renderer.
  91. LL_INLINE U32 getVertexDataMask() override { return 0; }
  92. // Not used by the EE forward renderer. HB
  93. LL_INLINE S32 getNumPasses() override { return 0; }
  94. // Returns 0 in EE rendering mode, or 1 in PBR mode. HB
  95. S32 getNumDeferredPasses() override;
  96. void renderDeferred(S32 pass) override;
  97. LL_INLINE S32 getNumPostDeferredPasses() override
  98. {
  99. return getNumDeferredPasses();
  100. }
  101. void renderPostDeferred(S32 pass) override;
  102. public:
  103. U32 mRenderType;
  104. };
  105. #endif // LL_LLDRAWPOOLMATERIALS_H