aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewershadermgr.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llviewershadermgr.h
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llviewershadermgr.h')
-rw-r--r--linden/indra/newview/llviewershadermgr.h313
1 files changed, 313 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewershadermgr.h b/linden/indra/newview/llviewershadermgr.h
new file mode 100644
index 0000000..3894cd5
--- /dev/null
+++ b/linden/indra/newview/llviewershadermgr.h
@@ -0,0 +1,313 @@
1/**
2 * @file llviewershadermgr.h
3 * @brief Viewer Shader Manager
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_VIEWER_SHADER_MGR_H
33#define LL_VIEWER_SHADER_MGR_H
34
35#include "llshadermgr.h"
36
37class LLViewerShaderMgr: public LLShaderMgr
38{
39public:
40 LLViewerShaderMgr();
41 /* virtual */ ~LLViewerShaderMgr();
42
43 // singleton pattern implementation
44 static LLViewerShaderMgr * instance();
45
46 void initAttribsAndUniforms(void);
47 void setShaders();
48 void unloadShaders();
49 S32 getVertexShaderLevel(S32 type);
50 BOOL loadBasicShaders();
51 BOOL loadShadersEffects();
52 BOOL loadShadersDeferred();
53 BOOL loadShadersObject();
54 BOOL loadShadersAvatar();
55 BOOL loadShadersEnvironment();
56 BOOL loadShadersWater();
57 BOOL loadShadersInterface();
58 BOOL loadShadersWindLight();
59
60 std::vector<S32> mVertexShaderLevel;
61 S32 mMaxAvatarShaderLevel;
62
63 enum EShaderClass
64 {
65 SHADER_LIGHTING,
66 SHADER_OBJECT,
67 SHADER_AVATAR,
68 SHADER_ENVIRONMENT,
69 SHADER_INTERFACE,
70 SHADER_EFFECT,
71 SHADER_WINDLIGHT,
72 SHADER_WATER,
73 SHADER_DEFERRED,
74 SHADER_COUNT
75 };
76
77 typedef enum
78 {
79 MATERIAL_COLOR = 0,
80 SPECULAR_COLOR,
81 BINORMAL,
82 END_RESERVED_ATTRIBS
83 } eGLSLReservedAttribs;
84
85 typedef enum
86 {
87 DIFFUSE_MAP = 0,
88 SPECULAR_MAP,
89 BUMP_MAP,
90 ENVIRONMENT_MAP,
91 CLOUD_NOISE_MAP,
92 FULLBRIGHT,
93 LIGHTNORM,
94 SUNLIGHT_COLOR,
95 AMBIENT,
96 BLUE_HORIZON,
97 BLUE_DENSITY,
98 HAZE_HORIZON,
99 HAZE_DENSITY,
100 CLOUD_SHADOW,
101 DENSITY_MULTIPLIER,
102 DISTANCE_MULTIPLIER,
103 MAX_Y,
104 GLOW,
105 CLOUD_COLOR,
106 CLOUD_POS_DENSITY1,
107 CLOUD_POS_DENSITY2,
108 CLOUD_SCALE,
109 GAMMA,
110 SCENE_LIGHT_STRENGTH,
111 END_RESERVED_UNIFORMS
112 } eGLSLReservedUniforms;
113
114 typedef enum
115 {
116 SHINY_ORIGIN = END_RESERVED_UNIFORMS
117 } eShinyUniforms;
118
119 typedef enum
120 {
121 WATER_SCREENTEX = END_RESERVED_UNIFORMS,
122 WATER_SCREENDEPTH,
123 WATER_REFTEX,
124 WATER_EYEVEC,
125 WATER_TIME,
126 WATER_WAVE_DIR1,
127 WATER_WAVE_DIR2,
128 WATER_LIGHT_DIR,
129 WATER_SPECULAR,
130 WATER_SPECULAR_EXP,
131 WATER_FOGCOLOR,
132 WATER_FOGDENSITY,
133 WATER_REFSCALE,
134 WATER_WATERHEIGHT,
135 } eWaterUniforms;
136
137 typedef enum
138 {
139 WL_CAMPOSLOCAL = END_RESERVED_UNIFORMS,
140 WL_WATERHEIGHT
141 } eWLUniforms;
142
143 typedef enum
144 {
145 TERRAIN_DETAIL0 = END_RESERVED_UNIFORMS,
146 TERRAIN_DETAIL1,
147 TERRAIN_DETAIL2,
148 TERRAIN_DETAIL3,
149 TERRAIN_ALPHARAMP
150 } eTerrainUniforms;
151
152 typedef enum
153 {
154 GLOW_DELTA = END_RESERVED_UNIFORMS
155 } eGlowUniforms;
156
157 typedef enum
158 {
159 AVATAR_WEIGHT = END_RESERVED_ATTRIBS,
160 AVATAR_CLOTHING,
161 AVATAR_WIND,
162 AVATAR_SINWAVE,
163 AVATAR_GRAVITY
164 } eAvatarAttribs;
165
166 typedef enum
167 {
168 AVATAR_MATRIX = END_RESERVED_UNIFORMS
169 } eAvatarUniforms;
170
171 // simple model of forward iterator
172 // http://www.sgi.com/tech/stl/ForwardIterator.html
173 class shader_iter
174 {
175 private:
176 friend bool operator == (shader_iter const & a, shader_iter const & b);
177 friend bool operator != (shader_iter const & a, shader_iter const & b);
178
179 typedef std::vector<LLGLSLShader *>::const_iterator base_iter_t;
180 public:
181 shader_iter()
182 {
183 }
184
185 shader_iter(base_iter_t iter) : mIter(iter)
186 {
187 }
188
189 LLGLSLShader & operator * () const
190 {
191 return **mIter;
192 }
193
194 LLGLSLShader * operator -> () const
195 {
196 return *mIter;
197 }
198
199 shader_iter & operator++ ()
200 {
201 ++mIter;
202 return *this;
203 }
204
205 shader_iter operator++ (int)
206 {
207 return mIter++;
208 }
209
210 private:
211 base_iter_t mIter;
212 };
213
214 shader_iter beginShaders() const
215 {
216 return mShaderList.begin();
217 }
218
219 shader_iter endShaders() const
220 {
221 return mShaderList.end();
222 }
223
224
225 /* virtual */ std::string getShaderDirPrefix(void); // Virtual
226
227 /* virtual */ void updateShaderUniforms(LLGLSLShader * shader); // Virtual
228
229private:
230
231 std::vector<std::string> mShinyUniforms;
232
233 //water parameters
234 std::vector<std::string> mWaterUniforms;
235
236 std::vector<std::string> mWLUniforms;
237
238 //terrain parameters
239 std::vector<std::string> mTerrainUniforms;
240
241 //glow parameters
242 std::vector<std::string> mGlowUniforms;
243
244 std::vector<std::string> mGlowExtractUniforms;
245
246 //avatar shader parameter tables
247 std::vector<std::string> mAvatarAttribs;
248
249 std::vector<std::string> mAvatarUniforms;
250
251 // the list of shaders we need to propagate parameters to.
252 std::vector<LLGLSLShader *> mShaderList;
253
254}; //LLViewerShaderMgr
255
256inline bool operator == (LLViewerShaderMgr::shader_iter const & a, LLViewerShaderMgr::shader_iter const & b)
257{
258 return a.mIter == b.mIter;
259}
260
261inline bool operator != (LLViewerShaderMgr::shader_iter const & a, LLViewerShaderMgr::shader_iter const & b)
262{
263 return a.mIter != b.mIter;
264}
265
266extern LLVector4 gShinyOrigin;
267
268//object shaders
269extern LLGLSLShader gObjectSimpleProgram;
270extern LLGLSLShader gObjectSimpleWaterProgram;
271extern LLGLSLShader gObjectFullbrightProgram;
272extern LLGLSLShader gObjectFullbrightWaterProgram;
273
274extern LLGLSLShader gObjectSimpleLODProgram;
275extern LLGLSLShader gObjectFullbrightLODProgram;
276
277extern LLGLSLShader gObjectFullbrightShinyProgram;
278extern LLGLSLShader gObjectShinyProgram;
279extern LLGLSLShader gObjectShinyWaterProgram;
280
281//environment shaders
282extern LLGLSLShader gTerrainProgram;
283extern LLGLSLShader gTerrainWaterProgram;
284extern LLGLSLShader gWaterProgram;
285extern LLGLSLShader gUnderWaterProgram;
286extern LLGLSLShader gGlowProgram;
287extern LLGLSLShader gGlowExtractProgram;
288
289//interface shaders
290extern LLGLSLShader gHighlightProgram;
291
292// avatar shader handles
293extern LLGLSLShader gAvatarProgram;
294extern LLGLSLShader gAvatarWaterProgram;
295extern LLGLSLShader gAvatarEyeballProgram;
296extern LLGLSLShader gAvatarPickProgram;
297
298// WindLight shader handles
299extern LLGLSLShader gWLSkyProgram;
300extern LLGLSLShader gWLCloudProgram;
301
302// Post Process Shaders
303extern LLGLSLShader gPostColorFilterProgram;
304extern LLGLSLShader gPostNightVisionProgram;
305
306// Deferred rendering shaders
307extern LLGLSLShader gDeferredDiffuseProgram;
308
309//current avatar shader parameter pointer
310extern GLint gAvatarMatrixParam;
311
312
313#endif