PageRenderTime 26ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/lldrawpoolbump.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 197 lines | 123 code | 45 blank | 29 comment | 0 complexity | 0b1df2c318f360ae0a7a3db273fe68c7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lldrawpoolbump.h
  3. * @brief LLDrawPoolBump class definition
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLDRAWPOOLBUMP_H
  27. #define LL_LLDRAWPOOLBUMP_H
  28. #include "lldrawpool.h"
  29. #include "llstring.h"
  30. #include "lltextureentry.h"
  31. #include "lluuid.h"
  32. class LLImageRaw;
  33. class LLSpatialGroup;
  34. class LLDrawInfo;
  35. class LLGLSLShader;
  36. class LLViewerFetchedTexture;
  37. class LLDrawPoolBump : public LLRenderPass
  38. {
  39. protected :
  40. LLDrawPoolBump(const U32 type):LLRenderPass(type) { mShiny = FALSE; }
  41. public:
  42. static U32 sVertexMask;
  43. BOOL mShiny;
  44. virtual U32 getVertexDataMask() { return sVertexMask; }
  45. LLDrawPoolBump();
  46. virtual void render(S32 pass = 0);
  47. virtual void beginRenderPass( S32 pass );
  48. virtual void endRenderPass( S32 pass );
  49. virtual S32 getNumPasses();
  50. /*virtual*/ void prerender();
  51. /*virtual*/ void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE);
  52. void renderBump(U32 type, U32 mask);
  53. void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture);
  54. S32 numBumpPasses();
  55. void beginShiny(bool invisible = false);
  56. void renderShiny(bool invisible = false);
  57. void endShiny(bool invisible = false);
  58. void beginFullbrightShiny();
  59. void renderFullbrightShiny();
  60. void endFullbrightShiny();
  61. void beginBump(U32 pass = LLRenderPass::PASS_BUMP);
  62. void renderBump(U32 pass = LLRenderPass::PASS_BUMP);
  63. void endBump(U32 pass = LLRenderPass::PASS_BUMP);
  64. static void bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
  65. static void unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
  66. virtual S32 getNumDeferredPasses();
  67. /*virtual*/ void beginDeferredPass(S32 pass);
  68. /*virtual*/ void endDeferredPass(S32 pass);
  69. /*virtual*/ void renderDeferred(S32 pass);
  70. virtual S32 getNumPostDeferredPasses() { return 2; }
  71. /*virtual*/ void beginPostDeferredPass(S32 pass);
  72. /*virtual*/ void endPostDeferredPass(S32 pass);
  73. /*virtual*/ void renderPostDeferred(S32 pass);
  74. static BOOL bindBumpMap(LLDrawInfo& params, S32 channel = -2);
  75. static BOOL bindBumpMap(LLFace* face, S32 channel = -2);
  76. private:
  77. static BOOL bindBumpMap(U8 bump_code, LLViewerTexture* tex, F32 vsize, S32 channel);
  78. };
  79. enum EBumpEffect
  80. {
  81. BE_NO_BUMP = 0,
  82. BE_BRIGHTNESS = 1,
  83. BE_DARKNESS = 2,
  84. BE_STANDARD_0 = 3, // Standard must always be the last one
  85. BE_COUNT = 4
  86. };
  87. ////////////////////////////////////////////////////////////////
  88. // List of standard bumpmaps that are specificed by LLTextureEntry::mBump's lower bits
  89. class LLStandardBumpmap
  90. {
  91. public:
  92. LLStandardBumpmap() : mLabel() {}
  93. LLStandardBumpmap( const std::string& label ) : mLabel(label) {}
  94. std::string mLabel;
  95. LLPointer<LLViewerFetchedTexture> mImage;
  96. static U32 sStandardBumpmapCount; // Number of valid values in gStandardBumpmapList[]
  97. static void clear();
  98. static void addstandard();
  99. static void init();
  100. static void shutdown();
  101. static void restoreGL();
  102. static void destroyGL();
  103. };
  104. extern LLStandardBumpmap gStandardBumpmapList[TEM_BUMPMAP_COUNT];
  105. ////////////////////////////////////////////////////////////////
  106. // List of one-component bump-maps created from other texures.
  107. struct LLBumpImageEntry;
  108. class LLBumpImageList
  109. {
  110. public:
  111. LLBumpImageList() {}
  112. ~LLBumpImageList();
  113. void init();
  114. void shutdown();
  115. void clear();
  116. void destroyGL();
  117. void restoreGL();
  118. void updateImages();
  119. LLViewerTexture* getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code);
  120. void addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size);
  121. static void onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
  122. static void onSourceDarknessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
  123. static void onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
  124. static void generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nrm_image);
  125. private:
  126. static void onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump );
  127. private:
  128. typedef std::map<LLUUID, LLPointer<LLViewerTexture> > bump_image_map_t;
  129. bump_image_map_t mBrightnessEntries;
  130. bump_image_map_t mDarknessEntries;
  131. };
  132. extern LLBumpImageList gBumpImageList;
  133. class LLDrawPoolInvisible : public LLDrawPoolBump
  134. {
  135. public:
  136. LLDrawPoolInvisible() : LLDrawPoolBump(LLDrawPool::POOL_INVISIBLE) { }
  137. enum
  138. {
  139. VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX
  140. };
  141. virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; }
  142. virtual void prerender() { }
  143. virtual void render(S32 pass = 0);
  144. virtual void beginRenderPass( S32 pass ) { }
  145. virtual void endRenderPass( S32 pass ) { }
  146. virtual S32 getNumPasses() {return 1;}
  147. virtual S32 getNumDeferredPasses() { return 1; }
  148. /*virtual*/ void beginDeferredPass(S32 pass);
  149. /*virtual*/ void endDeferredPass(S32 pass);
  150. /*virtual*/ void renderDeferred(S32 pass);
  151. };
  152. #endif // LL_LLDRAWPOOLBUMP_H