aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llglslshader.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/newview/llglslshader.h
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/newview/llglslshader.h')
-rw-r--r--linden/indra/newview/llglslshader.h232
1 files changed, 232 insertions, 0 deletions
diff --git a/linden/indra/newview/llglslshader.h b/linden/indra/newview/llglslshader.h
new file mode 100644
index 0000000..bbf91a8
--- /dev/null
+++ b/linden/indra/newview/llglslshader.h
@@ -0,0 +1,232 @@
1/**
2 * @file llglslshader.h
3 * @brief GLSL shader wrappers
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_LLGLSLSHADER_H
30#define LL_LLGLSLSHADER_H
31
32#include "llgl.h"
33
34class LLGLSLShader
35{
36public:
37 LLGLSLShader();
38
39 void unload();
40 void attachObject(GLhandleARB object);
41 void attachObjects(GLhandleARB* objects = NULL, S32 count = 0);
42 BOOL mapAttributes(const char** attrib_names = NULL, S32 count = 0);
43 BOOL mapUniforms(const char** uniform_names = NULL, S32 count = 0);
44 void mapUniform(GLint index, const char** uniform_names = NULL, S32 count = 0);
45 void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
46 void vertexAttrib4fv(U32 index, GLfloat* v);
47
48 GLint mapUniformTextureChannel(GLint location, GLenum type);
49
50
51 //enable/disable texture channel for specified uniform
52 //if given texture uniform is active in the shader,
53 //the corresponding channel will be active upon return
54 //returns channel texture is enabled in from [0-MAX)
55 S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D);
56 S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D);
57
58 BOOL link(BOOL suppress_errors = FALSE);
59 void bind();
60 void unbind();
61
62 GLhandleARB mProgramObject;
63 std::vector<GLint> mAttribute;
64 std::vector<GLint> mUniform;
65 std::vector<GLint> mTexture;
66 S32 mActiveTextureChannels;
67};
68
69class LLScatterShader
70{
71public:
72 static void init(GLhandleARB shader, int map_stage);
73};
74
75class LLShaderMgr
76{
77public:
78 static void setShaders();
79 static void unloadShaders();
80 static void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE);
81 static BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE);
82 static BOOL validateProgramObject(GLhandleARB obj);
83 static GLhandleARB loadShader(const LLString& filename, S32 cls, GLenum type);
84 static S32 getVertexShaderLevel(S32 type);
85 static S32 getMaxVertexShaderLevel(S32 type);
86 static BOOL loadShadersLighting();
87 static BOOL loadShadersObject();
88 static BOOL loadShadersAvatar();
89 static BOOL loadShadersEnvironment();
90 static BOOL loadShadersInterface();
91 static S32 sVertexShaderLevel[];
92 static S32 sMaxVertexShaderLevel[];
93 //global (reserved slot) shader parameters
94 static const char* sReservedAttribs[];
95 static U32 sReservedAttribCount;
96
97 enum EShaderClass
98 {
99 SHADER_LIGHTING,
100 SHADER_OBJECT,
101 SHADER_AVATAR,
102 SHADER_ENVIRONMENT,
103 SHADER_INTERFACE,
104 SHADER_COUNT
105 };
106
107 typedef enum
108 {
109 MATERIAL_COLOR = 0,
110 SPECULAR_COLOR,
111 BINORMAL,
112 END_RESERVED_ATTRIBS
113 } eGLSLReservedAttribs;
114
115 static const char* sReservedUniforms[];
116 static U32 sReservedUniformCount;
117
118 typedef enum
119 {
120 DIFFUSE_MAP = 0,
121 SPECULAR_MAP,
122 BUMP_MAP,
123 ENVIRONMENT_MAP,
124 END_RESERVED_UNIFORMS
125 } eGLSLReservedUniforms;
126
127 static const char* sShinyUniforms[];
128 static U32 sShinyUniformCount;
129
130 typedef enum
131 {
132 SHINY_ORIGIN = END_RESERVED_UNIFORMS
133 } eShinyUniforms;
134
135 //water parameters
136 static const char* sWaterUniforms[];
137 static U32 sWaterUniformCount;
138
139 typedef enum
140 {
141 WATER_SCREENTEX = END_RESERVED_UNIFORMS,
142 WATER_EYEVEC,
143 WATER_TIME,
144 WATER_WAVE_DIR1,
145 WATER_WAVE_DIR2,
146 WATER_LIGHT_DIR,
147 WATER_SPECULAR,
148 WATER_SPECULAR_EXP,
149 WATER_FBSCALE,
150 WATER_REFSCALE
151 } eWaterUniforms;
152
153 //terrain parameters
154 static const char* sTerrainUniforms[];
155 static U32 sTerrainUniformCount;
156
157 typedef enum
158 {
159 TERRAIN_DETAIL0 = END_RESERVED_UNIFORMS,
160 TERRAIN_DETAIL1,
161 TERRAIN_ALPHARAMP
162 } eTerrainUniforms;
163
164 //glow parameters
165 static const char* sGlowUniforms[];
166 static U32 sGlowUniformCount;
167
168 typedef enum
169 {
170 GLOW_DELTA = END_RESERVED_UNIFORMS
171 } eGlowUniforms;
172
173 //avatar shader parameter tables
174 static const char* sAvatarAttribs[];
175 static U32 sAvatarAttribCount;
176
177 typedef enum
178 {
179 AVATAR_WEIGHT = END_RESERVED_ATTRIBS,
180 AVATAR_CLOTHING,
181 AVATAR_WIND,
182 AVATAR_SINWAVE,
183 AVATAR_GRAVITY
184 } eAvatarAttribs;
185
186 static const char* sAvatarUniforms[];
187 static U32 sAvatarUniformCount;
188
189 typedef enum
190 {
191 AVATAR_MATRIX = END_RESERVED_UNIFORMS
192 } eAvatarUniforms;
193
194}; //LLSL
195
196//utility shader objects (not shader programs)
197extern GLhandleARB gLightVertex;
198extern GLhandleARB gLightFragment;
199extern GLhandleARB gScatterVertex;
200extern GLhandleARB gScatterFragment;
201
202extern LLVector4 gShinyOrigin;
203
204//object shaders
205extern LLGLSLShader gObjectSimpleProgram;
206extern LLGLSLShader gObjectAlphaProgram;
207extern LLGLSLShader gObjectBumpProgram;
208extern LLGLSLShader gObjectShinyProgram;
209
210//environment shaders
211extern LLGLSLShader gTerrainProgram;
212extern LLGLSLShader gGlowProgram;
213extern LLGLSLShader gGroundProgram;
214extern LLGLSLShader gWaterProgram;
215
216//interface shaders
217extern LLGLSLShader gHighlightProgram;
218
219//avatar skinning utility shader object
220extern GLhandleARB gAvatarSkinVertex;
221
222//avatar shader handles
223extern LLGLSLShader gAvatarProgram;
224extern LLGLSLShader gAvatarEyeballProgram;
225extern LLGLSLShader gAvatarPickProgram;
226
227//current avatar shader parameter pointer
228extern GLint gAvatarMatrixParam;
229extern GLint gMaterialIndex;
230extern GLint gSpecularIndex;
231
232#endif