PageRenderTime 42ms CodeModel.GetById 18ms app.highlight 21ms RepoModel.GetById 1ms 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
  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
 27#ifndef LL_LLDRAWPOOLBUMP_H
 28#define LL_LLDRAWPOOLBUMP_H
 29
 30#include "lldrawpool.h"
 31#include "llstring.h"
 32#include "lltextureentry.h"
 33#include "lluuid.h"
 34
 35class LLImageRaw;
 36class LLSpatialGroup;
 37class LLDrawInfo;
 38class LLGLSLShader;
 39class LLViewerFetchedTexture;
 40
 41class LLDrawPoolBump : public LLRenderPass
 42{
 43protected :
 44	LLDrawPoolBump(const U32 type):LLRenderPass(type) { mShiny = FALSE; }
 45public:
 46	static U32 sVertexMask;
 47	BOOL mShiny;
 48	
 49	virtual U32 getVertexDataMask() { return sVertexMask; }
 50
 51	LLDrawPoolBump();
 52
 53	virtual void render(S32 pass = 0);
 54	virtual void beginRenderPass( S32 pass );
 55	virtual void endRenderPass( S32 pass );
 56	virtual S32	 getNumPasses();
 57	/*virtual*/ void prerender();
 58	/*virtual*/ void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE);
 59
 60	void renderBump(U32 type, U32 mask);
 61	void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture);
 62		
 63	S32 numBumpPasses();
 64	
 65	void beginShiny(bool invisible = false);
 66	void renderShiny(bool invisible = false);
 67	void endShiny(bool invisible = false);
 68	
 69	void beginFullbrightShiny();
 70	void renderFullbrightShiny();
 71	void endFullbrightShiny();
 72
 73	void beginBump(U32 pass = LLRenderPass::PASS_BUMP);
 74	void renderBump(U32 pass = LLRenderPass::PASS_BUMP);
 75	void endBump(U32 pass = LLRenderPass::PASS_BUMP);
 76
 77	static void bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
 78	static void unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& diffuse_channel, S32& cube_channel, bool invisible);
 79
 80	virtual S32 getNumDeferredPasses();
 81	/*virtual*/ void beginDeferredPass(S32 pass);
 82	/*virtual*/ void endDeferredPass(S32 pass);
 83	/*virtual*/ void renderDeferred(S32 pass);
 84
 85	virtual S32 getNumPostDeferredPasses() { return 2; }
 86	/*virtual*/ void beginPostDeferredPass(S32 pass);
 87	/*virtual*/ void endPostDeferredPass(S32 pass);
 88	/*virtual*/ void renderPostDeferred(S32 pass);
 89
 90	static BOOL bindBumpMap(LLDrawInfo& params, S32 channel = -2);
 91	static BOOL bindBumpMap(LLFace* face, S32 channel = -2);
 92
 93private:
 94	static BOOL bindBumpMap(U8 bump_code, LLViewerTexture* tex, F32 vsize, S32 channel);
 95
 96};
 97
 98enum EBumpEffect
 99{
100	BE_NO_BUMP = 0,
101	BE_BRIGHTNESS = 1,
102	BE_DARKNESS = 2,
103	BE_STANDARD_0 = 3,  // Standard must always be the last one
104	BE_COUNT = 4
105};
106
107////////////////////////////////////////////////////////////////
108// List of standard bumpmaps that are specificed by LLTextureEntry::mBump's lower bits
109
110class LLStandardBumpmap
111{
112public: 
113	LLStandardBumpmap() : mLabel() {} 
114	LLStandardBumpmap( const std::string& label ) : mLabel(label) {}
115	
116	std::string	mLabel;
117	LLPointer<LLViewerFetchedTexture> mImage;
118
119	static	U32 sStandardBumpmapCount;  // Number of valid values in gStandardBumpmapList[]
120
121	static void clear();
122	static void addstandard();
123
124	static void init();
125	static void shutdown();
126	static void restoreGL();
127	static void destroyGL();
128};
129
130extern LLStandardBumpmap gStandardBumpmapList[TEM_BUMPMAP_COUNT];
131
132////////////////////////////////////////////////////////////////
133// List of one-component bump-maps created from other texures.
134
135struct LLBumpImageEntry;
136
137class LLBumpImageList
138{
139public:
140	LLBumpImageList() {}
141	~LLBumpImageList();
142
143	void		init();
144	void		shutdown();
145	void            clear();
146	void		destroyGL();
147	void		restoreGL();
148	void		updateImages();
149
150
151	LLViewerTexture*	getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code);
152	void		addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size);
153
154	static void onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
155	static void onSourceDarknessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
156	static void onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
157	static void generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nrm_image);
158
159
160private:
161	static void onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump );
162
163private:
164	typedef std::map<LLUUID, LLPointer<LLViewerTexture> > bump_image_map_t;
165	bump_image_map_t mBrightnessEntries;
166	bump_image_map_t mDarknessEntries;
167};
168
169extern LLBumpImageList gBumpImageList;
170
171class LLDrawPoolInvisible : public LLDrawPoolBump
172{
173public:
174	LLDrawPoolInvisible() : LLDrawPoolBump(LLDrawPool::POOL_INVISIBLE) { }
175
176	enum
177	{
178		VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX
179	};
180	
181	virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; }
182
183	virtual void prerender() { }
184
185	virtual void render(S32 pass = 0);
186	virtual void beginRenderPass( S32 pass ) { }
187	virtual void endRenderPass( S32 pass ) { }
188	virtual S32	 getNumPasses() {return 1;}
189
190	virtual S32 getNumDeferredPasses() { return 1; }
191	/*virtual*/ void beginDeferredPass(S32 pass);
192	/*virtual*/ void endDeferredPass(S32 pass);
193	/*virtual*/ void renderDeferred(S32 pass);
194};
195
196
197#endif // LL_LLDRAWPOOLBUMP_H