PageRenderTime 37ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llrender/llshadermgr.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 201 lines | 146 code | 23 blank | 32 comment | 0 complexity | f977c6caae494e4470ab35f0c542bf8f MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llshadermgr.h
  3. * @brief Shader Manager
  4. *
  5. * $LicenseInfo:firstyear=2001&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_SHADERMGR_H
  27. #define LL_SHADERMGR_H
  28. #include "llgl.h"
  29. #include "llglslshader.h"
  30. class LLShaderMgr
  31. {
  32. public:
  33. LLShaderMgr();
  34. virtual ~LLShaderMgr();
  35. typedef enum
  36. {
  37. MODELVIEW_MATRIX = 0,
  38. PROJECTION_MATRIX,
  39. INVERSE_PROJECTION_MATRIX,
  40. MODELVIEW_PROJECTION_MATRIX,
  41. NORMAL_MATRIX,
  42. TEXTURE_MATRIX0,
  43. TEXTURE_MATRIX1,
  44. TEXTURE_MATRIX2,
  45. TEXTURE_MATRIX3,
  46. VIEWPORT,
  47. LIGHT_POSITION,
  48. LIGHT_DIRECTION,
  49. LIGHT_ATTENUATION,
  50. LIGHT_DIFFUSE,
  51. LIGHT_AMBIENT,
  52. MULTI_LIGHT_COUNT,
  53. MULTI_LIGHT,
  54. MULTI_LIGHT_COL,
  55. MULTI_LIGHT_FAR_Z,
  56. PROJECTOR_MATRIX,
  57. PROJECTOR_NEAR,
  58. PROJECTOR_P,
  59. PROJECTOR_N,
  60. PROJECTOR_ORIGIN,
  61. PROJECTOR_RANGE,
  62. PROJECTOR_AMBIANCE,
  63. PROJECTOR_SHADOW_INDEX,
  64. PROJECTOR_SHADOW_FADE,
  65. PROJECTOR_FOCUS,
  66. PROJECTOR_LOD,
  67. PROJECTOR_AMBIENT_LOD,
  68. DIFFUSE_COLOR,
  69. DIFFUSE_MAP,
  70. SPECULAR_MAP,
  71. BUMP_MAP,
  72. ENVIRONMENT_MAP,
  73. CLOUD_NOISE_MAP,
  74. FULLBRIGHT,
  75. LIGHTNORM,
  76. SUNLIGHT_COLOR,
  77. AMBIENT,
  78. BLUE_HORIZON,
  79. BLUE_DENSITY,
  80. HAZE_HORIZON,
  81. HAZE_DENSITY,
  82. CLOUD_SHADOW,
  83. DENSITY_MULTIPLIER,
  84. DISTANCE_MULTIPLIER,
  85. MAX_Y,
  86. GLOW,
  87. CLOUD_COLOR,
  88. CLOUD_POS_DENSITY1,
  89. CLOUD_POS_DENSITY2,
  90. CLOUD_SCALE,
  91. GAMMA,
  92. SCENE_LIGHT_STRENGTH,
  93. LIGHT_CENTER,
  94. LIGHT_SIZE,
  95. LIGHT_FALLOFF,
  96. GLOW_MIN_LUMINANCE,
  97. GLOW_MAX_EXTRACT_ALPHA,
  98. GLOW_LUM_WEIGHTS,
  99. GLOW_WARMTH_WEIGHTS,
  100. GLOW_WARMTH_AMOUNT,
  101. GLOW_STRENGTH,
  102. GLOW_DELTA,
  103. MINIMUM_ALPHA,
  104. DEFERRED_SHADOW_MATRIX,
  105. DEFERRED_ENV_MAT,
  106. DEFERRED_SHADOW_CLIP,
  107. DEFERRED_SUN_WASH,
  108. DEFERRED_SHADOW_NOISE,
  109. DEFERRED_BLUR_SIZE,
  110. DEFERRED_SSAO_RADIUS,
  111. DEFERRED_SSAO_MAX_RADIUS,
  112. DEFERRED_SSAO_FACTOR,
  113. DEFERRED_SSAO_FACTOR_INV,
  114. DEFERRED_SSAO_EFFECT_MAT,
  115. DEFERRED_SCREEN_RES,
  116. DEFERRED_NEAR_CLIP,
  117. DEFERRED_SHADOW_OFFSET,
  118. DEFERRED_SHADOW_BIAS,
  119. DEFERRED_SPOT_SHADOW_BIAS,
  120. DEFERRED_SPOT_SHADOW_OFFSET,
  121. DEFERRED_SUN_DIR,
  122. DEFERRED_SHADOW_RES,
  123. DEFERRED_PROJ_SHADOW_RES,
  124. DEFERRED_DEPTH_CUTOFF,
  125. DEFERRED_NORM_CUTOFF,
  126. FXAA_TC_SCALE,
  127. FXAA_RCP_SCREEN_RES,
  128. FXAA_RCP_FRAME_OPT,
  129. FXAA_RCP_FRAME_OPT2,
  130. DOF_FOCAL_DISTANCE,
  131. DOF_BLUR_CONSTANT,
  132. DOF_TAN_PIXEL_ANGLE,
  133. DOF_MAGNIFICATION,
  134. DOF_MAX_COF,
  135. DOF_RES_SCALE,
  136. DEFERRED_DEPTH,
  137. DEFERRED_SHADOW0,
  138. DEFERRED_SHADOW1,
  139. DEFERRED_SHADOW2,
  140. DEFERRED_SHADOW3,
  141. DEFERRED_SHADOW4,
  142. DEFERRED_SHADOW5,
  143. DEFERRED_NORMAL,
  144. DEFERRED_POSITION,
  145. DEFERRED_DIFFUSE,
  146. DEFERRED_SPECULAR,
  147. DEFERRED_NOISE,
  148. DEFERRED_LIGHTFUNC,
  149. DEFERRED_LIGHT,
  150. DEFERRED_BLOOM,
  151. DEFERRED_PROJECTION,
  152. END_RESERVED_UNIFORMS
  153. } eGLSLReservedUniforms;
  154. // singleton pattern implementation
  155. static LLShaderMgr * instance();
  156. virtual void initAttribsAndUniforms(void);
  157. BOOL attachShaderFeatures(LLGLSLShader * shader);
  158. void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE);
  159. BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE);
  160. BOOL validateProgramObject(GLhandleARB obj);
  161. GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, S32 texture_index_channels = -1);
  162. // Implemented in the application to actually point to the shader directory.
  163. virtual std::string getShaderDirPrefix(void) = 0; // Pure Virtual
  164. // Implemented in the application to actually update out of date uniforms for a particular shader
  165. virtual void updateShaderUniforms(LLGLSLShader * shader) = 0; // Pure Virtual
  166. public:
  167. // Map of shader names to compiled
  168. std::map<std::string, GLhandleARB> mShaderObjects;
  169. //global (reserved slot) shader parameters
  170. std::vector<std::string> mReservedAttribs;
  171. std::vector<std::string> mReservedUniforms;
  172. //preprocessor definitions (name/value)
  173. std::map<std::string, std::string> mDefinitions;
  174. protected:
  175. // our parameter manager singleton instance
  176. static LLShaderMgr * sInstance;
  177. }; //LLShaderMgr
  178. #endif