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