1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://ogre.sourceforge.net/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __Pass_H__
|
---|
26 | #define __Pass_H__
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 | #include "OgreGpuProgram.h"
|
---|
30 | #include "OgreColourValue.h"
|
---|
31 | #include "OgreBlendMode.h"
|
---|
32 | #include "OgreCommon.h"
|
---|
33 | #include "OgreLight.h"
|
---|
34 |
|
---|
35 | namespace Ogre {
|
---|
36 | /** Class defining a single pass of a Technique (of a Material), ie
|
---|
37 | a single rendering call.
|
---|
38 | @remarks
|
---|
39 | Rendering can be repeated with many passes for more complex effects.
|
---|
40 | Each pass is either a fixed-function pass (meaning it does not use
|
---|
41 | a vertex or fragment program) or a programmable pass (meaning it does
|
---|
42 | use either a vertex and fragment program, or both).
|
---|
43 | @par
|
---|
44 | Programmable passes are complex to define, because they require custom
|
---|
45 | programs and you have to set all constant inputs to the programs (like
|
---|
46 | the position of lights, any base material colours you wish to use etc), but
|
---|
47 | they do give you much total flexibility over the algorithms used to render your
|
---|
48 | pass, and you can create some effects which are impossible with a fixed-function pass.
|
---|
49 | On the other hand, you can define a fixed-function pass in very little time, and
|
---|
50 | you can use a range of fixed-function effects like environment mapping very
|
---|
51 | easily, plus your pass will be more likely to be compatible with older hardware.
|
---|
52 | There are pros and cons to both, just remember that if you use a programmable
|
---|
53 | pass to create some great effects, allow more time for definition and testing.
|
---|
54 | */
|
---|
55 | class _OgreExport Pass
|
---|
56 | {
|
---|
57 | protected:
|
---|
58 | Technique* mParent;
|
---|
59 | unsigned short mIndex; // pass index
|
---|
60 | String mName; // optional name for the pass
|
---|
61 | uint32 mHash; // pass hash
|
---|
62 | //-------------------------------------------------------------------------
|
---|
63 | // Colour properties, only applicable in fixed-function passes
|
---|
64 | ColourValue mAmbient;
|
---|
65 | ColourValue mDiffuse;
|
---|
66 | ColourValue mSpecular;
|
---|
67 | ColourValue mEmissive;
|
---|
68 | Real mShininess;
|
---|
69 | TrackVertexColourType mTracking;
|
---|
70 | //-------------------------------------------------------------------------
|
---|
71 |
|
---|
72 | //-------------------------------------------------------------------------
|
---|
73 | // Blending factors
|
---|
74 | SceneBlendFactor mSourceBlendFactor;
|
---|
75 | SceneBlendFactor mDestBlendFactor;
|
---|
76 | //-------------------------------------------------------------------------
|
---|
77 |
|
---|
78 | //-------------------------------------------------------------------------
|
---|
79 | // Depth buffer settings
|
---|
80 | bool mDepthCheck;
|
---|
81 | bool mDepthWrite;
|
---|
82 | CompareFunction mDepthFunc;
|
---|
83 | ushort mDepthBias;
|
---|
84 |
|
---|
85 | // Colour buffer settings
|
---|
86 | bool mColourWrite;
|
---|
87 |
|
---|
88 | // Alpha reject settings
|
---|
89 | CompareFunction mAlphaRejectFunc;
|
---|
90 | unsigned char mAlphaRejectVal;
|
---|
91 | //-------------------------------------------------------------------------
|
---|
92 |
|
---|
93 | //-------------------------------------------------------------------------
|
---|
94 | // Culling mode
|
---|
95 | CullingMode mCullMode;
|
---|
96 | ManualCullingMode mManualCullMode;
|
---|
97 | //-------------------------------------------------------------------------
|
---|
98 |
|
---|
99 | /// Lighting enabled?
|
---|
100 | bool mLightingEnabled;
|
---|
101 | /// Max simultaneous lights
|
---|
102 | unsigned short mMaxSimultaneousLights;
|
---|
103 | /// Run this pass once per light?
|
---|
104 | bool mIteratePerLight;
|
---|
105 | // Should it only be run for a certain light type?
|
---|
106 | bool mRunOnlyForOneLightType;
|
---|
107 | Light::LightTypes mOnlyLightType;
|
---|
108 |
|
---|
109 | /// Shading options
|
---|
110 | ShadeOptions mShadeOptions;
|
---|
111 | /// Polygon mode
|
---|
112 | PolygonMode mPolygonMode;
|
---|
113 |
|
---|
114 | //-------------------------------------------------------------------------
|
---|
115 | // Fog
|
---|
116 | bool mFogOverride;
|
---|
117 | FogMode mFogMode;
|
---|
118 | ColourValue mFogColour;
|
---|
119 | Real mFogStart;
|
---|
120 | Real mFogEnd;
|
---|
121 | Real mFogDensity;
|
---|
122 | //-------------------------------------------------------------------------
|
---|
123 |
|
---|
124 | /// Storage of texture unit states
|
---|
125 | typedef std::vector<TextureUnitState*> TextureUnitStates;
|
---|
126 | TextureUnitStates mTextureUnitStates;
|
---|
127 |
|
---|
128 | // Vertex program details
|
---|
129 | GpuProgramUsage *mVertexProgramUsage;
|
---|
130 | // Vertex program details
|
---|
131 | GpuProgramUsage *mShadowCasterVertexProgramUsage;
|
---|
132 | // Vertex program details
|
---|
133 | GpuProgramUsage *mShadowReceiverVertexProgramUsage;
|
---|
134 | // Fragment program details
|
---|
135 | GpuProgramUsage *mFragmentProgramUsage;
|
---|
136 | // Fragment program details
|
---|
137 | GpuProgramUsage *mShadowReceiverFragmentProgramUsage;
|
---|
138 | // Is this pass queued for deletion?
|
---|
139 | bool mQueuedForDeletion;
|
---|
140 | // number of pass iterations to perform
|
---|
141 | size_t mPassIterationCount;
|
---|
142 | // point size, applies when not using per-vertex point size
|
---|
143 | Real mPointSize;
|
---|
144 | Real mPointMinSize;
|
---|
145 | Real mPointMaxSize;
|
---|
146 | bool mPointSpritesEnabled;
|
---|
147 | bool mPointAttenuationEnabled;
|
---|
148 | // constant, linear, quadratic coeffs
|
---|
149 | Real mPointAttenuationCoeffs[3];
|
---|
150 | public:
|
---|
151 | typedef std::set<Pass*> PassSet;
|
---|
152 | protected:
|
---|
153 | /// List of Passes whose hashes need recalculating
|
---|
154 | static PassSet msDirtyHashList;
|
---|
155 | /// The place where passes go to die
|
---|
156 | static PassSet msPassGraveyard;
|
---|
157 | public:
|
---|
158 | /// Default constructor
|
---|
159 | Pass(Technique* parent, unsigned short index);
|
---|
160 | /// Copy constructor
|
---|
161 | Pass(Technique* parent, unsigned short index, const Pass& oth );
|
---|
162 | /// Operator = overload
|
---|
163 | Pass& operator=(const Pass& oth);
|
---|
164 | ~Pass();
|
---|
165 |
|
---|
166 | /// Returns true if this pass is programmable ie includes either a vertex or fragment program.
|
---|
167 | bool isProgrammable(void) const { return mVertexProgramUsage || mFragmentProgramUsage; }
|
---|
168 | /// Returns true if this pass uses a programmable vertex pipeline
|
---|
169 | bool hasVertexProgram(void) const { return mVertexProgramUsage != NULL; }
|
---|
170 | /// Returns true if this pass uses a programmable fragment pipeline
|
---|
171 | bool hasFragmentProgram(void) const { return mFragmentProgramUsage != NULL; }
|
---|
172 | /// Returns true if this pass uses a shadow caster vertex program
|
---|
173 | bool hasShadowCasterVertexProgram(void) const { return mShadowCasterVertexProgramUsage != NULL; }
|
---|
174 | /// Returns true if this pass uses a shadow receiver vertex program
|
---|
175 | bool hasShadowReceiverVertexProgram(void) const { return mShadowReceiverVertexProgramUsage != NULL; }
|
---|
176 | /// Returns true if this pass uses a shadow receiver fragment program
|
---|
177 | bool hasShadowReceiverFragmentProgram(void) const { return mShadowReceiverFragmentProgramUsage != NULL; }
|
---|
178 |
|
---|
179 |
|
---|
180 | /// Gets the index of this Pass in the parent Technique
|
---|
181 | unsigned short getIndex(void) const { return mIndex; }
|
---|
182 | /* Set the name of the pass
|
---|
183 | @remarks
|
---|
184 | The name of the pass is optional. Its usefull in material scripts where a material could inherit
|
---|
185 | from another material and only want to modify a particalar pass.
|
---|
186 | */
|
---|
187 | void setName(const String& name);
|
---|
188 | /// get the name of the pass
|
---|
189 | const String& getName(void) const { return mName; }
|
---|
190 |
|
---|
191 | /** Sets the ambient colour reflectance properties of this pass.
|
---|
192 | @remarks
|
---|
193 | The base colour of a pass is determined by how much red, green and blue light is reflects
|
---|
194 | (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how
|
---|
195 | much ambient light (directionless global light) is reflected. The default is full white, meaning
|
---|
196 | objects are completely globally illuminated. Reduce this if you want to see diffuse or specular light
|
---|
197 | effects, or change the blend of colours to make the object have a base colour other than white.
|
---|
198 | @note
|
---|
199 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
200 | or if this is a programmable pass.
|
---|
201 | */
|
---|
202 | void setAmbient(Real red, Real green, Real blue);
|
---|
203 |
|
---|
204 | /** Sets the ambient colour reflectance properties of this pass.
|
---|
205 | @remarks
|
---|
206 | The base colour of a pass is determined by how much red, green and blue light is reflects
|
---|
207 | (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how
|
---|
208 | much ambient light (directionless global light) is reflected. The default is full white, meaning
|
---|
209 | objects are completely globally illuminated. Reduce this if you want to see diffuse or specular light
|
---|
210 | effects, or change the blend of colours to make the object have a base colour other than white.
|
---|
211 | @note
|
---|
212 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
213 | or if this is a programmable pass.
|
---|
214 | */
|
---|
215 |
|
---|
216 | void setAmbient(const ColourValue& ambient);
|
---|
217 |
|
---|
218 | /** Sets the diffuse colour reflectance properties of this pass.
|
---|
219 | @remarks
|
---|
220 | The base colour of a pass is determined by how much red, green and blue light is reflects
|
---|
221 | (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how
|
---|
222 | much diffuse light (light from instances of the Light class in the scene) is reflected. The default
|
---|
223 | is full white, meaning objects reflect the maximum white light they can from Light objects.
|
---|
224 | @note
|
---|
225 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
226 | or if this is a programmable pass.
|
---|
227 | */
|
---|
228 | void setDiffuse(Real red, Real green, Real blue, Real alpha);
|
---|
229 |
|
---|
230 | /** Sets the diffuse colour reflectance properties of this pass.
|
---|
231 | @remarks
|
---|
232 | The base colour of a pass is determined by how much red, green and blue light is reflects
|
---|
233 | (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how
|
---|
234 | much diffuse light (light from instances of the Light class in the scene) is reflected. The default
|
---|
235 | is full white, meaning objects reflect the maximum white light they can from Light objects.
|
---|
236 | @note
|
---|
237 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
238 | or if this is a programmable pass.
|
---|
239 | */
|
---|
240 | void setDiffuse(const ColourValue& diffuse);
|
---|
241 |
|
---|
242 | /** Sets the specular colour reflectance properties of this pass.
|
---|
243 | @remarks
|
---|
244 | The base colour of a pass is determined by how much red, green and blue light is reflects
|
---|
245 | (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how
|
---|
246 | much specular light (highlights from instances of the Light class in the scene) is reflected.
|
---|
247 | The default is to reflect no specular light.
|
---|
248 | @note
|
---|
249 | The size of the specular highlights is determined by the separate 'shininess' property.
|
---|
250 | @note
|
---|
251 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
252 | or if this is a programmable pass.
|
---|
253 | */
|
---|
254 | void setSpecular(Real red, Real green, Real blue, Real alpha);
|
---|
255 |
|
---|
256 | /** Sets the specular colour reflectance properties of this pass.
|
---|
257 | @remarks
|
---|
258 | The base colour of a pass is determined by how much red, green and blue light is reflects
|
---|
259 | (provided texture layer #0 has a blend mode other than LBO_REPLACE). This property determines how
|
---|
260 | much specular light (highlights from instances of the Light class in the scene) is reflected.
|
---|
261 | The default is to reflect no specular light.
|
---|
262 | @note
|
---|
263 | The size of the specular highlights is determined by the separate 'shininess' property.
|
---|
264 | @note
|
---|
265 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
266 | or if this is a programmable pass.
|
---|
267 | */
|
---|
268 | void setSpecular(const ColourValue& specular);
|
---|
269 |
|
---|
270 | /** Sets the shininess of the pass, affecting the size of specular highlights.
|
---|
271 | @note
|
---|
272 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
273 | or if this is a programmable pass.
|
---|
274 | */
|
---|
275 | void setShininess(Real val);
|
---|
276 |
|
---|
277 | /** Sets the amount of self-illumination an object has.
|
---|
278 | @remarks
|
---|
279 | If an object is self-illuminating, it does not need external sources to light it, ambient or
|
---|
280 | otherwise. It's like the object has it's own personal ambient light. This property is rarely useful since
|
---|
281 | you can already specify per-pass ambient light, but is here for completeness.
|
---|
282 | @note
|
---|
283 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
284 | or if this is a programmable pass.
|
---|
285 | */
|
---|
286 | void setSelfIllumination(Real red, Real green, Real blue);
|
---|
287 |
|
---|
288 | /** Sets the amount of self-illumination an object has.
|
---|
289 | @remarks
|
---|
290 | If an object is self-illuminating, it does not need external sources to light it, ambient or
|
---|
291 | otherwise. It's like the object has it's own personal ambient light. This property is rarely useful since
|
---|
292 | you can already specify per-pass ambient light, but is here for completeness.
|
---|
293 | @note
|
---|
294 | This setting has no effect if dynamic lighting is disabled (see Pass::setLightingEnabled),
|
---|
295 | or if this is a programmable pass.
|
---|
296 | */
|
---|
297 | void setSelfIllumination(const ColourValue& selfIllum);
|
---|
298 |
|
---|
299 | /** Sets which material properties follow the vertex colour
|
---|
300 | */
|
---|
301 | void setVertexColourTracking(TrackVertexColourType tracking);
|
---|
302 |
|
---|
303 | /** Gets the point size of the pass.
|
---|
304 | @remarks
|
---|
305 | This property determines what point size is used to render a point
|
---|
306 | list.
|
---|
307 | */
|
---|
308 | Real getPointSize(void) const;
|
---|
309 |
|
---|
310 | /** Sets the point size of this pass.
|
---|
311 | @remarks
|
---|
312 | This setting allows you to change the size of points when rendering
|
---|
313 | a point list, or a list of point sprites. The interpretation of this
|
---|
314 | command depends on the Pass::setPointSizeAttenuation option - if it
|
---|
315 | is off (the default), the point size is in screen pixels, if it is on,
|
---|
316 | it expressed as normalised screen coordinates (1.0 is the height of
|
---|
317 | the screen) when the point is at the origin.
|
---|
318 | @note
|
---|
319 | Some drivers have an upper limit on the size of points they support
|
---|
320 | - this can even vary between APIs on the same card! Don't rely on
|
---|
321 | point sizes that cause the point sprites to get very large on screen,
|
---|
322 | since they may get clamped on some cards. Upper sizes can range from
|
---|
323 | 64 to 256 pixels.
|
---|
324 | */
|
---|
325 | void setPointSize(Real ps);
|
---|
326 |
|
---|
327 | /** Sets whether or not rendering points using OT_POINT_LIST will
|
---|
328 | render point sprites (textured quads) or plain points (dots).
|
---|
329 | @param enabled True enables point sprites, false returns to normal
|
---|
330 | point rendering.
|
---|
331 | */
|
---|
332 | void setPointSpritesEnabled(bool enabled);
|
---|
333 |
|
---|
334 | /** Returns whether point sprites are enabled when rendering a
|
---|
335 | point list.
|
---|
336 | */
|
---|
337 | bool getPointSpritesEnabled(void) const;
|
---|
338 |
|
---|
339 | /** Sets how points are attenuated with distance.
|
---|
340 | @remarks
|
---|
341 | When performing point rendering or point sprite rendering,
|
---|
342 | point size can be attenuated with distance. The equation for
|
---|
343 | doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2).
|
---|
344 | @par
|
---|
345 | For example, to disable distance attenuation (constant screensize)
|
---|
346 | you would set constant to 1, and linear and quadratic to 0. A
|
---|
347 | standard perspective attenuation would be 0, 1, 0 respectively.
|
---|
348 | @note
|
---|
349 | The resulting size is clamped to the minimum and maximum point
|
---|
350 | size.
|
---|
351 | @param enabled Whether point attenuation is enabled
|
---|
352 | @param constant, linear, quadratic Parameters to the attentuation
|
---|
353 | function defined above
|
---|
354 | */
|
---|
355 | void setPointAttenuation(bool enabled,
|
---|
356 | Real constant = 0.0f, Real linear = 1.0f, Real quadratic = 0.0f);
|
---|
357 |
|
---|
358 | /** Returns whether points are attenuated with distance. */
|
---|
359 | bool isPointAttenuationEnabled(void) const;
|
---|
360 |
|
---|
361 | /** Returns the constant coefficient of point attenuation. */
|
---|
362 | Real getPointAttenuationConstant(void) const;
|
---|
363 | /** Returns the linear coefficient of point attenuation. */
|
---|
364 | Real getPointAttenuationLinear(void) const;
|
---|
365 | /** Returns the quadratic coefficient of point attenuation. */
|
---|
366 | Real getPointAttenuationQuadratic(void) const;
|
---|
367 |
|
---|
368 | /** Set the minimum point size, when point attenuation is in use. */
|
---|
369 | void setPointMinSize(Real min);
|
---|
370 | /** Get the minimum point size, when point attenuation is in use. */
|
---|
371 | Real getPointMinSize(void) const;
|
---|
372 | /** Set the maximum point size, when point attenuation is in use.
|
---|
373 | @remarks Setting this to 0 indicates the max size supported by the card.
|
---|
374 | */
|
---|
375 | void setPointMaxSize(Real max);
|
---|
376 | /** Get the maximum point size, when point attenuation is in use.
|
---|
377 | @remarks 0 indicates the max size supported by the card.
|
---|
378 | */
|
---|
379 | Real getPointMaxSize(void) const;
|
---|
380 |
|
---|
381 | /** Gets the ambient colour reflectance of the pass.
|
---|
382 | */
|
---|
383 | const ColourValue& getAmbient(void) const;
|
---|
384 |
|
---|
385 | /** Gets the diffuse colour reflectance of the pass.
|
---|
386 | */
|
---|
387 | const ColourValue& getDiffuse(void) const;
|
---|
388 |
|
---|
389 | /** Gets the specular colour reflectance of the pass.
|
---|
390 | */
|
---|
391 | const ColourValue& getSpecular(void) const;
|
---|
392 |
|
---|
393 | /** Gets the self illumination colour of the pass.
|
---|
394 | */
|
---|
395 | const ColourValue& getSelfIllumination(void) const;
|
---|
396 |
|
---|
397 | /** Gets the 'shininess' property of the pass (affects specular highlights).
|
---|
398 | */
|
---|
399 | Real getShininess(void) const;
|
---|
400 |
|
---|
401 | /** Gets which material properties follow the vertex colour
|
---|
402 | */
|
---|
403 | TrackVertexColourType getVertexColourTracking(void) const;
|
---|
404 |
|
---|
405 | /** Inserts a new TextureUnitState object into the Pass.
|
---|
406 | @remarks
|
---|
407 | This unit is is added on top of all previous units.
|
---|
408 | */
|
---|
409 | TextureUnitState* createTextureUnitState(void);
|
---|
410 | /** Inserts a new TextureUnitState object into the Pass.
|
---|
411 | @remarks
|
---|
412 | This unit is is added on top of all previous units.
|
---|
413 | @param
|
---|
414 | name The basic name of the texture e.g. brickwall.jpg, stonefloor.png
|
---|
415 | @param
|
---|
416 | texCoordSet The index of the texture coordinate set to use.
|
---|
417 | @note
|
---|
418 | Applies to both fixed-function and programmable passes.
|
---|
419 | */
|
---|
420 | TextureUnitState* createTextureUnitState( const String& textureName, unsigned short texCoordSet = 0);
|
---|
421 | /** Adds the passed in TextureUnitState, to the existing Pass.
|
---|
422 | @param
|
---|
423 | state The Texture Unit State to be attached to this pass. It must not be attached to another pass.
|
---|
424 | @note
|
---|
425 | Throws an exception if the TextureUnitState is attached to another Pass.*/
|
---|
426 | void addTextureUnitState(TextureUnitState* state);
|
---|
427 | /** Retrieves a pointer to a texture unit state so it may be modified.
|
---|
428 | */
|
---|
429 | TextureUnitState* getTextureUnitState(unsigned short index);
|
---|
430 | /** Retrieves the Texture Unit State matching name.
|
---|
431 | Returns 0 if name match is not found.
|
---|
432 | */
|
---|
433 | TextureUnitState* getTextureUnitState(const String& name);
|
---|
434 | /** Retrieves a const pointer to a texture unit state.
|
---|
435 | */
|
---|
436 | const TextureUnitState* getTextureUnitState(unsigned short index) const;
|
---|
437 | /** Retrieves the Texture Unit State matching name.
|
---|
438 | Returns 0 if name match is not found.
|
---|
439 | */
|
---|
440 | const TextureUnitState* getTextureUnitState(const String& name) const;
|
---|
441 |
|
---|
442 | /** Retrieve the index of the Texture Unit State in the pass.
|
---|
443 | @param
|
---|
444 | state The Texture Unit State this is attached to this pass.
|
---|
445 | @note
|
---|
446 | Throws an exception if the state is not attached to the pass.
|
---|
447 | */
|
---|
448 | unsigned short getTextureUnitStateIndex(const TextureUnitState* state);
|
---|
449 |
|
---|
450 | typedef VectorIterator<TextureUnitStates> TextureUnitStateIterator;
|
---|
451 | /** Get an iterator over the TextureUnitStates contained in this Pass. */
|
---|
452 | TextureUnitStateIterator getTextureUnitStateIterator(void);
|
---|
453 |
|
---|
454 | typedef ConstVectorIterator<TextureUnitStates> ConstTextureUnitStateIterator;
|
---|
455 | /** Get an iterator over the TextureUnitStates contained in this Pass. */
|
---|
456 | ConstTextureUnitStateIterator getTextureUnitStateIterator(void) const;
|
---|
457 |
|
---|
458 | /** Removes the indexed texture unit state from this pass.
|
---|
459 | @remarks
|
---|
460 | Note that removing a texture which is not the topmost will have a larger performance impact.
|
---|
461 | */
|
---|
462 | void removeTextureUnitState(unsigned short index);
|
---|
463 |
|
---|
464 | /** Removes all texture unit settings.
|
---|
465 | */
|
---|
466 | void removeAllTextureUnitStates(void);
|
---|
467 |
|
---|
468 | /** Returns the number of texture unit settings.
|
---|
469 | */
|
---|
470 | size_t getNumTextureUnitStates(void) const
|
---|
471 | {
|
---|
472 | return mTextureUnitStates.size();
|
---|
473 | }
|
---|
474 |
|
---|
475 | /** Sets the kind of blending this pass has with the existing contents of the scene.
|
---|
476 | @remarks
|
---|
477 | Wheras the texture blending operations seen in the TextureUnitState class are concerned with
|
---|
478 | blending between texture layers, this blending is about combining the output of the Pass
|
---|
479 | as a whole with the existing contents of the rendering target. This blending therefore allows
|
---|
480 | object transparency and other special effects. If all passes in a technique have a scene
|
---|
481 | blend, then the whole technique is considered to be transparent.
|
---|
482 | @par
|
---|
483 | This method allows you to select one of a number of predefined blending types. If you require more
|
---|
484 | control than this, use the alternative version of this method which allows you to specify source and
|
---|
485 | destination blend factors.
|
---|
486 | @note
|
---|
487 | This method is applicable for both the fixed-function and programmable pipelines.
|
---|
488 | @param
|
---|
489 | sbt One of the predefined SceneBlendType blending types
|
---|
490 | */
|
---|
491 | void setSceneBlending( const SceneBlendType sbt );
|
---|
492 |
|
---|
493 | /** Allows very fine control of blending this Pass with the existing contents of the scene.
|
---|
494 | @remarks
|
---|
495 | Wheras the texture blending operations seen in the TextureUnitState class are concerned with
|
---|
496 | blending between texture layers, this blending is about combining the output of the material
|
---|
497 | as a whole with the existing contents of the rendering target. This blending therefore allows
|
---|
498 | object transparency and other special effects.
|
---|
499 | @par
|
---|
500 | This version of the method allows complete control over the blending operation, by specifying the
|
---|
501 | source and destination blending factors. The result of the blending operation is:
|
---|
502 | <span align="center">
|
---|
503 | final = (texture * sourceFactor) + (pixel * destFactor)
|
---|
504 | </span>
|
---|
505 | @par
|
---|
506 | Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
|
---|
507 | enumerated type.
|
---|
508 | @param
|
---|
509 | sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
|
---|
510 | @param
|
---|
511 | destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
|
---|
512 | @note
|
---|
513 | This method is applicable for both the fixed-function and programmable pipelines.
|
---|
514 | */
|
---|
515 | void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
|
---|
516 |
|
---|
517 | /** Retrieves the source blending factor for the material (as set using Materiall::setSceneBlending).
|
---|
518 | */
|
---|
519 | SceneBlendFactor getSourceBlendFactor() const;
|
---|
520 |
|
---|
521 | /** Retrieves the destination blending factor for the material (as set using Materiall::setSceneBlending).
|
---|
522 | */
|
---|
523 | SceneBlendFactor getDestBlendFactor() const;
|
---|
524 |
|
---|
525 | /** Returns true if this pass has some element of transparency. */
|
---|
526 | bool isTransparent(void) const;
|
---|
527 |
|
---|
528 | /** Sets whether or not this pass renders with depth-buffer checking on or not.
|
---|
529 | @remarks
|
---|
530 | If depth-buffer checking is on, whenever a pixel is about to be written to the frame buffer
|
---|
531 | the depth buffer is checked to see if the pixel is in front of all other pixels written at that
|
---|
532 | point. If not, the pixel is not written.
|
---|
533 | @par
|
---|
534 | If depth checking is off, pixels are written no matter what has been rendered before.
|
---|
535 | Also see setDepthFunction for more advanced depth check configuration.
|
---|
536 | @see
|
---|
537 | setDepthFunction
|
---|
538 | */
|
---|
539 | void setDepthCheckEnabled(bool enabled);
|
---|
540 |
|
---|
541 | /** Returns whether or not this pass renders with depth-buffer checking on or not.
|
---|
542 | @see
|
---|
543 | setDepthCheckEnabled
|
---|
544 | */
|
---|
545 | bool getDepthCheckEnabled(void) const;
|
---|
546 |
|
---|
547 | /** Sets whether or not this pass renders with depth-buffer writing on or not.
|
---|
548 | @remarks
|
---|
549 | If depth-buffer writing is on, whenever a pixel is written to the frame buffer
|
---|
550 | the depth buffer is updated with the depth value of that new pixel, thus affecting future
|
---|
551 | rendering operations if future pixels are behind this one.
|
---|
552 | @par
|
---|
553 | If depth writing is off, pixels are written without updating the depth buffer Depth writing should
|
---|
554 | normally be on but can be turned off when rendering static backgrounds or when rendering a collection
|
---|
555 | of transparent objects at the end of a scene so that they overlap each other correctly.
|
---|
556 | */
|
---|
557 | void setDepthWriteEnabled(bool enabled);
|
---|
558 |
|
---|
559 | /** Returns whether or not this pass renders with depth-buffer writing on or not.
|
---|
560 | @see
|
---|
561 | setDepthWriteEnabled
|
---|
562 | */
|
---|
563 | bool getDepthWriteEnabled(void) const;
|
---|
564 |
|
---|
565 | /** Sets the function used to compare depth values when depth checking is on.
|
---|
566 | @remarks
|
---|
567 | If depth checking is enabled (see setDepthCheckEnabled) a comparison occurs between the depth
|
---|
568 | value of the pixel to be written and the current contents of the buffer. This comparison is
|
---|
569 | normally CMPF_LESS_EQUAL, i.e. the pixel is written if it is closer (or at the same distance)
|
---|
570 | than the current contents. If you wish you can change this comparison using this method.
|
---|
571 | */
|
---|
572 | void setDepthFunction( CompareFunction func );
|
---|
573 | /** Returns the function used to compare depth values when depth checking is on.
|
---|
574 | @see
|
---|
575 | setDepthFunction
|
---|
576 | */
|
---|
577 | CompareFunction getDepthFunction(void) const;
|
---|
578 |
|
---|
579 | /** Sets whether or not colour buffer writing is enabled for this Pass.
|
---|
580 | @remarks
|
---|
581 | For some effects, you might wish to turn off the colour write operation
|
---|
582 | when rendering geometry; this means that only the depth buffer will be
|
---|
583 | updated (provided you have depth buffer writing enabled, which you
|
---|
584 | probably will do, although you may wish to only update the stencil
|
---|
585 | buffer for example - stencil buffer state is managed at the RenderSystem
|
---|
586 | level only, not the Material since you are likely to want to manage it
|
---|
587 | at a higher level).
|
---|
588 | */
|
---|
589 | void setColourWriteEnabled(bool enabled);
|
---|
590 | /** Determines if colour buffer writing is enabled for this pass. */
|
---|
591 | bool getColourWriteEnabled(void) const;
|
---|
592 |
|
---|
593 | /** Sets the culling mode for this pass based on the 'vertex winding'.
|
---|
594 | @remarks
|
---|
595 | A typical way for the rendering engine to cull triangles is based on the 'vertex winding' of
|
---|
596 | triangles. Vertex winding refers to the direction in which the vertices are passed or indexed
|
---|
597 | to in the rendering operation as viewed from the camera, and will wither be clockwise or
|
---|
598 | anticlockwise (that's 'counterclockwise' for you Americans out there ;) The default is
|
---|
599 | CULL_CLOCKWISE i.e. that only triangles whose vertices are passed/indexed in anticlockwise order
|
---|
600 | are rendered - this is a common approach and is used in 3D studio models for example. You can
|
---|
601 | alter this culling mode if you wish but it is not advised unless you know what you are doing.
|
---|
602 | @par
|
---|
603 | You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
|
---|
604 | winding is uncertain.
|
---|
605 | */
|
---|
606 | void setCullingMode( CullingMode mode );
|
---|
607 |
|
---|
608 | /** Returns the culling mode for geometry rendered with this pass. See setCullingMode for more information.
|
---|
609 | */
|
---|
610 | CullingMode getCullingMode(void) const;
|
---|
611 |
|
---|
612 | /** Sets the manual culling mode, performed by CPU rather than hardware.
|
---|
613 | @pemarks
|
---|
614 | In some situations you want to use manual culling of triangles rather than sending the
|
---|
615 | triangles to the hardware and letting it cull them. This setting only takes effect on SceneManager's
|
---|
616 | that use it (since it is best used on large groups of planar world geometry rather than on movable
|
---|
617 | geometry since this would be expensive), but if used can cull geometry before it is sent to the
|
---|
618 | hardware.
|
---|
619 | @note
|
---|
620 | The default for this setting is MANUAL_CULL_BACK.
|
---|
621 | @param
|
---|
622 | mode The mode to use - see enum ManualCullingMode for details
|
---|
623 |
|
---|
624 | */
|
---|
625 | void setManualCullingMode( ManualCullingMode mode );
|
---|
626 |
|
---|
627 | /** Retrieves the manual culling mode for this pass
|
---|
628 | @see
|
---|
629 | setManualCullingMode
|
---|
630 | */
|
---|
631 | ManualCullingMode getManualCullingMode(void) const;
|
---|
632 |
|
---|
633 | /** Sets whether or not dynamic lighting is enabled.
|
---|
634 | @param
|
---|
635 | enabled
|
---|
636 | If true, dynamic lighting is performed on geometry with normals supplied, geometry without
|
---|
637 | normals will not be displayed.
|
---|
638 | @par
|
---|
639 | If false, no lighting is applied and all geometry will be full brightness.
|
---|
640 | */
|
---|
641 | void setLightingEnabled(bool enabled);
|
---|
642 |
|
---|
643 | /** Returns whether or not dynamic lighting is enabled.
|
---|
644 | */
|
---|
645 | bool getLightingEnabled(void) const;
|
---|
646 |
|
---|
647 | /** Sets the maximum number of lights to be used by this pass.
|
---|
648 | @remarks
|
---|
649 | During rendering, if lighting is enabled (or if the pass uses an automatic
|
---|
650 | program parameter based on a light) the engine will request the nearest lights
|
---|
651 | to the object being rendered in order to work out which ones to use. This
|
---|
652 | parameter sets the limit on the number of lights which should apply to objects
|
---|
653 | rendered with this pass.
|
---|
654 | */
|
---|
655 | void setMaxSimultaneousLights(unsigned short maxLights);
|
---|
656 | /** Gets the maximum number of lights to be used by this pass. */
|
---|
657 | unsigned short getMaxSimultaneousLights(void) const;
|
---|
658 |
|
---|
659 | /** Sets the type of light shading required
|
---|
660 | @note
|
---|
661 | The default shading method is Gouraud shading.
|
---|
662 | */
|
---|
663 | void setShadingMode( ShadeOptions mode );
|
---|
664 |
|
---|
665 | /** Returns the type of light shading to be used.
|
---|
666 | */
|
---|
667 | ShadeOptions getShadingMode(void) const;
|
---|
668 |
|
---|
669 | /** Sets the type of polygon rendering required
|
---|
670 | @note
|
---|
671 | The default shading method is Solid
|
---|
672 | */
|
---|
673 | void setPolygonMode( PolygonMode mode );
|
---|
674 |
|
---|
675 | /** Returns the type of light shading to be used.
|
---|
676 | */
|
---|
677 | PolygonMode getPolygonMode(void) const;
|
---|
678 |
|
---|
679 | /** Sets the fogging mode applied to this pass.
|
---|
680 | @remarks
|
---|
681 | Fogging is an effect that is applied as polys are rendered. Sometimes, you want
|
---|
682 | fog to be applied to an entire scene. Other times, you want it to be applied to a few
|
---|
683 | polygons only. This pass-level specification of fog parameters lets you easily manage
|
---|
684 | both.
|
---|
685 | @par
|
---|
686 | The SceneManager class also has a setFog method which applies scene-level fog. This method
|
---|
687 | lets you change the fog behaviour for this pass compared to the standard scene-level fog.
|
---|
688 | @param
|
---|
689 | overrideScene If true, you authorise this pass to override the scene's fog params with it's own settings.
|
---|
690 | If you specify false, so other parameters are necessary, and this is the default behaviour for passs.
|
---|
691 | @param
|
---|
692 | mode Only applicable if overrideScene is true. You can disable fog which is turned on for the
|
---|
693 | rest of the scene by specifying FOG_NONE. Otherwise, set a pass-specific fog mode as
|
---|
694 | defined in the enum FogMode.
|
---|
695 | @param
|
---|
696 | colour The colour of the fog. Either set this to the same as your viewport background colour,
|
---|
697 | or to blend in with a skydome or skybox.
|
---|
698 | @param
|
---|
699 | expDensity The density of the fog in FOG_EXP or FOG_EXP2 mode, as a value between 0 and 1.
|
---|
700 | The default is 0.001.
|
---|
701 | @param
|
---|
702 | linearStart Distance in world units at which linear fog starts to encroach.
|
---|
703 | Only applicable if mode is FOG_LINEAR.
|
---|
704 | @param
|
---|
705 | linearEnd Distance in world units at which linear fog becomes completely opaque.
|
---|
706 | Only applicable if mode is FOG_LINEAR.
|
---|
707 | */
|
---|
708 | void setFog(
|
---|
709 | bool overrideScene,
|
---|
710 | FogMode mode = FOG_NONE,
|
---|
711 | const ColourValue& colour = ColourValue::White,
|
---|
712 | Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
|
---|
713 |
|
---|
714 | /** Returns true if this pass is to override the scene fog settings.
|
---|
715 | */
|
---|
716 | bool getFogOverride(void) const;
|
---|
717 |
|
---|
718 | /** Returns the fog mode for this pass.
|
---|
719 | @note
|
---|
720 | Only valid if getFogOverride is true.
|
---|
721 | */
|
---|
722 | FogMode getFogMode(void) const;
|
---|
723 |
|
---|
724 | /** Returns the fog colour for the scene.
|
---|
725 | */
|
---|
726 | const ColourValue& getFogColour(void) const;
|
---|
727 |
|
---|
728 | /** Returns the fog start distance for this pass.
|
---|
729 | @note
|
---|
730 | Only valid if getFogOverride is true.
|
---|
731 | */
|
---|
732 | Real getFogStart(void) const;
|
---|
733 |
|
---|
734 | /** Returns the fog end distance for this pass.
|
---|
735 | @note
|
---|
736 | Only valid if getFogOverride is true.
|
---|
737 | */
|
---|
738 | Real getFogEnd(void) const;
|
---|
739 |
|
---|
740 | /** Returns the fog density for this pass.
|
---|
741 | @note
|
---|
742 | Only valid if getFogOverride is true.
|
---|
743 | */
|
---|
744 | Real getFogDensity(void) const;
|
---|
745 |
|
---|
746 | /** Sets the depth bias to be used for this material.
|
---|
747 | @remarks
|
---|
748 | When polygons are coplanar, you can get problems with 'depth fighting' where
|
---|
749 | the pixels from the two polys compete for the same screen pixel. This is particularly
|
---|
750 | a problem for decals (polys attached to another surface to represent details such as
|
---|
751 | bulletholes etc.).
|
---|
752 | @par
|
---|
753 | A way to combat this problem is to use a depth bias to adjust the depth buffer value
|
---|
754 | used for the decal such that it is slightly higher than the true value, ensuring that
|
---|
755 | the decal appears on top.
|
---|
756 | @param bias The bias value, should be between 0 and 16.
|
---|
757 | */
|
---|
758 | void setDepthBias(ushort bias);
|
---|
759 |
|
---|
760 | /** Retrieves the depth bias value as set by setDepthValue. */
|
---|
761 | ushort getDepthBias(void) const;
|
---|
762 |
|
---|
763 | /** Sets the way the pass will have use alpha to totally reject pixels from the pipeline.
|
---|
764 | @remarks
|
---|
765 | The default is CMPF_ALWAYS_PASS i.e. alpha is not used to reject pixels.
|
---|
766 | @param func The comparison which must pass for the pixel to be written.
|
---|
767 | @param value 1 byte value against which alpha values will be tested(0-255)
|
---|
768 | @note
|
---|
769 | This option applies in both the fixed function and the programmable pipeline.
|
---|
770 | */
|
---|
771 | void setAlphaRejectSettings(CompareFunction func, unsigned char value);
|
---|
772 |
|
---|
773 | /** Sets the alpha reject function. See setAlphaRejectSettings for more information.
|
---|
774 | */
|
---|
775 | void setAlphaRejectFunction(CompareFunction func);
|
---|
776 |
|
---|
777 | /** Gets the alpha reject value. See setAlphaRejectSettings for more information.
|
---|
778 | */
|
---|
779 | void setAlphaRejectValue(unsigned char val);
|
---|
780 |
|
---|
781 | /** Gets the alpha reject function. See setAlphaRejectSettings for more information.
|
---|
782 | */
|
---|
783 | CompareFunction getAlphaRejectFunction(void) const { return mAlphaRejectFunc; }
|
---|
784 |
|
---|
785 | /** Gets the alpha reject value. See setAlphaRejectSettings for more information.
|
---|
786 | */
|
---|
787 | unsigned char getAlphaRejectValue(void) const { return mAlphaRejectVal; }
|
---|
788 | /** Sets whether or not this pass should iterate per light which
|
---|
789 | can affect the object being rendered.
|
---|
790 | @remarks
|
---|
791 | The default behaviour for a pass (when this option is 'false'), is
|
---|
792 | for a pass to be rendered only once (or the number of times set in
|
---|
793 | setPassIterationCount), with all the lights which could
|
---|
794 | affect this object set at the same time (up to the maximum lights
|
---|
795 | allowed in the render system, which is typically 8).
|
---|
796 | @par
|
---|
797 | Setting this option to 'true' changes this behaviour, such that
|
---|
798 | instead of trying to issue render this pass once per object, it
|
---|
799 | is run <b>per light</b> which can affect this object, the number of
|
---|
800 | times set in setPassIterationCount (default is once). In
|
---|
801 | this case, only light index 0 is ever used, and is a different light
|
---|
802 | every time the pass is issued, up to the total number of lights
|
---|
803 | which is affecting this object. This has 2 advantages:
|
---|
804 | <ul><li>There is no limit on the number of lights which can be
|
---|
805 | supported</li>
|
---|
806 | <li>It's easier to write vertex / fragment programs for this because
|
---|
807 | a single program can be used for any number of lights</li>
|
---|
808 | </ul>
|
---|
809 | However, this technique is a lot more expensive, and typically you
|
---|
810 | will want an additional ambient pass, because if no lights are
|
---|
811 | affecting the object it will not be rendered at all, which will look
|
---|
812 | odd even if ambient light is zero (imagine if there are lit objects
|
---|
813 | behind it - the objects silhouette would not show up). Therefore,
|
---|
814 | use this option with care, and you would be well advised to provide
|
---|
815 | a less expensive fallback technique for use in the distance.
|
---|
816 | @note
|
---|
817 | The number of times this pass runs is still limited by the maximum
|
---|
818 | number of lights allowed as set in setMaxSimultaneousLights, so
|
---|
819 | you will never get more passes than this.
|
---|
820 | @param enabled Whether this feature is enabled
|
---|
821 | @param onlyForOneLightType If true, the pass will only be run for a single type
|
---|
822 | of light, other light types will be ignored.
|
---|
823 | @param lightType The single light type which will be considered for this pass
|
---|
824 | */
|
---|
825 | void setIteratePerLight(bool enabled,
|
---|
826 | bool onlyForOneLightType = true, Light::LightTypes lightType = Light::LT_POINT);
|
---|
827 |
|
---|
828 | /** Does this pass run once for every light in range? */
|
---|
829 | bool getIteratePerLight(void) const { return mIteratePerLight; }
|
---|
830 | /** Does this pass run only for a single light type (if getIteratePerLight is true). */
|
---|
831 | bool getRunOnlyForOneLightType(void) const { return mRunOnlyForOneLightType; }
|
---|
832 | /** Gets the single light type this pass runs for if getIteratePerLight and
|
---|
833 | getRunOnlyForOneLightType are both true. */
|
---|
834 | Light::LightTypes getOnlyLightType() const { return mOnlyLightType; }
|
---|
835 |
|
---|
836 | /// Gets the parent Technique
|
---|
837 | Technique* getParent(void) { return mParent; }
|
---|
838 |
|
---|
839 | /// Gets the resource group of the ultimate parent Material
|
---|
840 | const String& getResourceGroup(void) const;
|
---|
841 |
|
---|
842 | /** Sets the details of the vertex program to use.
|
---|
843 | @remarks
|
---|
844 | Only applicable to programmable passes, this sets the details of
|
---|
845 | the vertex program to use in this pass. The program will not be
|
---|
846 | loaded until the parent Material is loaded.
|
---|
847 | @param name The name of the program - this must have been
|
---|
848 | created using GpuProgramManager by the time that this Pass
|
---|
849 | is loaded. If this parameter is blank, any vertex program in this pass is disabled.
|
---|
850 | @param resetParams
|
---|
851 | If true, this will create a fresh set of parameters from the
|
---|
852 | new program being linked, so if you had previously set parameters
|
---|
853 | you will have to set them again. If you set this to false, you must
|
---|
854 | be absolutely sure that the parameters match perfectly, and in the
|
---|
855 | case of named parameters refers to the indexes underlying them,
|
---|
856 | not just the names.
|
---|
857 | */
|
---|
858 | void setVertexProgram(const String& name, bool resetParams = true);
|
---|
859 | /** Sets the vertex program parameters.
|
---|
860 | @remarks
|
---|
861 | Only applicable to programmable passes, and this particular call is
|
---|
862 | designed for low-level programs; use the named parameter methods
|
---|
863 | for setting high-level program parameters.
|
---|
864 | */
|
---|
865 | void setVertexProgramParameters(GpuProgramParametersSharedPtr params);
|
---|
866 | /** Gets the name of the vertex program used by this pass. */
|
---|
867 | const String& getVertexProgramName(void) const;
|
---|
868 | /** Gets the vertex program parameters used by this pass. */
|
---|
869 | GpuProgramParametersSharedPtr getVertexProgramParameters(void) const;
|
---|
870 | /** Gets the vertex program used by this pass, only available after _load(). */
|
---|
871 | const GpuProgramPtr& getVertexProgram(void) const;
|
---|
872 |
|
---|
873 |
|
---|
874 | /** Sets the details of the vertex program to use when rendering as a
|
---|
875 | shadow caster.
|
---|
876 | @remarks
|
---|
877 | Texture-based shadows require that the caster is rendered to a texture
|
---|
878 | in a solid colour (the shadow colour in the case of modulative texture
|
---|
879 | shadows). Whilst Ogre can arrange this for the fixed function
|
---|
880 | pipeline, passes which use vertex programs might need the vertex
|
---|
881 | programs still to run in order to preserve any deformation etc
|
---|
882 | that it does. However, lighting calculations must be a lot simpler,
|
---|
883 | with only the ambient colour being used (which the engine will ensure
|
---|
884 | is bound to the shadow colour).
|
---|
885 | @par
|
---|
886 | Therefore, it is up to implemetors of vertex programs to provide an
|
---|
887 | alternative vertex program which can be used to render the object
|
---|
888 | to a shadow texture. Do all the same vertex transforms, but set the
|
---|
889 | colour of the vertex to the ambient colour, as bound using the
|
---|
890 | standard auto parameter binding mechanism.
|
---|
891 | @note
|
---|
892 | Some vertex programs will work without doing this, because Ogre ensures
|
---|
893 | that all lights except for ambient are set black. However, the chances
|
---|
894 | are that your vertex program is doing a lot of unnecessary work in this
|
---|
895 | case, since the other lights are having no effect, and it is good practice
|
---|
896 | to supply an alternative.
|
---|
897 | @note
|
---|
898 | This is only applicable to programmable passes.
|
---|
899 | @par
|
---|
900 | The default behaviour is for Ogre to switch to fixed-function
|
---|
901 | rendering if an explict vertex program alternative is not set.
|
---|
902 | */
|
---|
903 | void setShadowCasterVertexProgram(const String& name);
|
---|
904 | /** Sets the vertex program parameters for rendering as a shadow caster.
|
---|
905 | @remarks
|
---|
906 | Only applicable to programmable passes, and this particular call is
|
---|
907 | designed for low-level programs; use the named parameter methods
|
---|
908 | for setting high-level program parameters.
|
---|
909 | */
|
---|
910 | void setShadowCasterVertexProgramParameters(GpuProgramParametersSharedPtr params);
|
---|
911 | /** Gets the name of the vertex program used by this pass when rendering shadow casters. */
|
---|
912 | const String& getShadowCasterVertexProgramName(void) const;
|
---|
913 | /** Gets the vertex program parameters used by this pass when rendering shadow casters. */
|
---|
914 | GpuProgramParametersSharedPtr getShadowCasterVertexProgramParameters(void) const;
|
---|
915 | /** Gets the vertex program used by this pass when rendering shadow casters,
|
---|
916 | only available after _load(). */
|
---|
917 | const GpuProgramPtr& getShadowCasterVertexProgram(void) const;
|
---|
918 |
|
---|
919 | /** Sets the details of the vertex program to use when rendering as a
|
---|
920 | shadow receiver.
|
---|
921 | @remarks
|
---|
922 | Texture-based shadows require that the shadow receiver is rendered using
|
---|
923 | a projective texture. Whilst Ogre can arrange this for the fixed function
|
---|
924 | pipeline, passes which use vertex programs might need the vertex
|
---|
925 | programs still to run in order to preserve any deformation etc
|
---|
926 | that it does. So in this case, we need a vertex program which does the
|
---|
927 | appropriate vertex transformation, but generates projective texture
|
---|
928 | coordinates.
|
---|
929 | @par
|
---|
930 | Therefore, it is up to implemetors of vertex programs to provide an
|
---|
931 | alternative vertex program which can be used to render the object
|
---|
932 | as a shadow receiver. Do all the same vertex transforms, but generate
|
---|
933 | <strong>2 sets</strong> of texture coordinates using the auto parameter
|
---|
934 | ACT_TEXTURE_VIEWPROJ_MATRIX, which Ogre will bind to the parameter name /
|
---|
935 | index you supply as the second parameter to this method. 2 texture
|
---|
936 | sets are needed because Ogre needs to use 2 texture units for some
|
---|
937 | shadow effects.
|
---|
938 | @note
|
---|
939 | This is only applicable to programmable passes.
|
---|
940 | @par
|
---|
941 | The default behaviour is for Ogre to switch to fixed-function
|
---|
942 | rendering if an explict vertex program alternative is not set.
|
---|
943 | */
|
---|
944 | void setShadowReceiverVertexProgram(const String& name);
|
---|
945 | /** Sets the vertex program parameters for rendering as a shadow receiver.
|
---|
946 | @remarks
|
---|
947 | Only applicable to programmable passes, and this particular call is
|
---|
948 | designed for low-level programs; use the named parameter methods
|
---|
949 | for setting high-level program parameters.
|
---|
950 | */
|
---|
951 | void setShadowReceiverVertexProgramParameters(GpuProgramParametersSharedPtr params);
|
---|
952 |
|
---|
953 | /** This method allows you to specify a fragment program for use when
|
---|
954 | rendering a texture shadow receiver.
|
---|
955 | @remarks
|
---|
956 | Texture shadows are applied by rendering the receiver. Modulative texture
|
---|
957 | shadows are performed as a post-render darkening pass, and as such
|
---|
958 | fragment programs are generally not required per-object. Additive
|
---|
959 | texture shadows, however, are applied by accumulating light masked
|
---|
960 | out using a texture shadow (black & white by default, unless you
|
---|
961 | customise this using SceneManager::setCustomShadowCasterMaterial).
|
---|
962 | OGRE can do this for you for most materials, but if you use a custom
|
---|
963 | lighting program (e.g. per pixel lighting) then you'll need to provide
|
---|
964 | a custom version for receiving shadows. You don't need to provide
|
---|
965 | this for shadow casters if you don't use self-shadowing since they
|
---|
966 | will never be shadow receivers too.
|
---|
967 | @par
|
---|
968 | The shadow texture is always bound to texture unit 0 when rendering
|
---|
969 | texture shadow passes. Therefore your custom shadow receiver program
|
---|
970 | may well just need to shift it's texture unit usage up by one unit,
|
---|
971 | and take the shadow texture into account in its calculations.
|
---|
972 | */
|
---|
973 | void setShadowReceiverFragmentProgram(const String& name);
|
---|
974 | /** Sets the fragment program parameters for rendering as a shadow receiver.
|
---|
975 | @remarks
|
---|
976 | Only applicable to programmable passes, and this particular call is
|
---|
977 | designed for low-level programs; use the named parameter methods
|
---|
978 | for setting high-level program parameters.
|
---|
979 | */
|
---|
980 | void setShadowReceiverFragmentProgramParameters(GpuProgramParametersSharedPtr params);
|
---|
981 |
|
---|
982 | /** Gets the name of the vertex program used by this pass when rendering shadow receivers. */
|
---|
983 | const String& getShadowReceiverVertexProgramName(void) const;
|
---|
984 | /** Gets the vertex program parameters used by this pass when rendering shadow receivers. */
|
---|
985 | GpuProgramParametersSharedPtr getShadowReceiverVertexProgramParameters(void) const;
|
---|
986 | /** Gets the vertex program used by this pass when rendering shadow receivers,
|
---|
987 | only available after _load(). */
|
---|
988 | const GpuProgramPtr& getShadowReceiverVertexProgram(void) const;
|
---|
989 |
|
---|
990 | /** Gets the name of the fragment program used by this pass when rendering shadow receivers. */
|
---|
991 | const String& getShadowReceiverFragmentProgramName(void) const;
|
---|
992 | /** Gets the fragment program parameters used by this pass when rendering shadow receivers. */
|
---|
993 | GpuProgramParametersSharedPtr getShadowReceiverFragmentProgramParameters(void) const;
|
---|
994 | /** Gets the fragment program used by this pass when rendering shadow receivers,
|
---|
995 | only available after _load(). */
|
---|
996 | const GpuProgramPtr& getShadowReceiverFragmentProgram(void) const;
|
---|
997 |
|
---|
998 | /** Sets the details of the fragment program to use.
|
---|
999 | @remarks
|
---|
1000 | Only applicable to programmable passes, this sets the details of
|
---|
1001 | the fragment program to use in this pass. The program will not be
|
---|
1002 | loaded until the parent Material is loaded.
|
---|
1003 | @param name The name of the program - this must have been
|
---|
1004 | created using GpuProgramManager by the time that this Pass
|
---|
1005 | is loaded. If this parameter is blank, any fragment program in this pass is disabled.
|
---|
1006 | @param resetParams
|
---|
1007 | If true, this will create a fresh set of parameters from the
|
---|
1008 | new program being linked, so if you had previously set parameters
|
---|
1009 | you will have to set them again. If you set this to false, you must
|
---|
1010 | be absolutely sure that the parameters match perfectly, and in the
|
---|
1011 | case of named parameters refers to the indexes underlying them,
|
---|
1012 | not just the names.
|
---|
1013 | */
|
---|
1014 | void setFragmentProgram(const String& name, bool resetParams = true);
|
---|
1015 | /** Sets the vertex program parameters.
|
---|
1016 | @remarks
|
---|
1017 | Only applicable to programmable passes.
|
---|
1018 | */
|
---|
1019 | void setFragmentProgramParameters(GpuProgramParametersSharedPtr params);
|
---|
1020 | /** Gets the name of the fragment program used by this pass. */
|
---|
1021 | const String& getFragmentProgramName(void) const;
|
---|
1022 | /** Gets the vertex program parameters used by this pass. */
|
---|
1023 | GpuProgramParametersSharedPtr getFragmentProgramParameters(void) const;
|
---|
1024 | /** Gets the vertex program used by this pass, only available after _load(). */
|
---|
1025 | const GpuProgramPtr& getFragmentProgram(void) const;
|
---|
1026 |
|
---|
1027 | /** Splits this Pass to one which can be handled in the number of
|
---|
1028 | texture units specified.
|
---|
1029 | @remarks
|
---|
1030 | Only works on non-programmable passes, programmable passes cannot be
|
---|
1031 | split, it's up to the author to ensure that there is a fallback Technique
|
---|
1032 | for less capable cards.
|
---|
1033 | @param numUnits The target number of texture units
|
---|
1034 | @returns A new Pass which contains the remaining units, and a scene_blend
|
---|
1035 | setting appropriate to approximate the multitexture. This Pass will be
|
---|
1036 | attached to the parent Technique of this Pass.
|
---|
1037 | */
|
---|
1038 | Pass* _split(unsigned short numUnits);
|
---|
1039 |
|
---|
1040 | /** Internal method to adjust pass index. */
|
---|
1041 | void _notifyIndex(unsigned short index);
|
---|
1042 |
|
---|
1043 | /** Internal method for loading this pass. */
|
---|
1044 | void _load(void);
|
---|
1045 | /** Internal method for unloading this pass. */
|
---|
1046 | void _unload(void);
|
---|
1047 | // Is this loaded?
|
---|
1048 | bool isLoaded(void) const;
|
---|
1049 |
|
---|
1050 | /** Gets the 'hash' of this pass, ie a precomputed number to use for sorting
|
---|
1051 | @remarks
|
---|
1052 | This hash is used to sort passes, and for this reason the pass is hashed
|
---|
1053 | using firstly its index (so that all passes are rendered in order), then
|
---|
1054 | by the textures which it's TextureUnitState instances are using.
|
---|
1055 | */
|
---|
1056 | uint32 getHash(void) const;
|
---|
1057 | /// Mark the hash as dirty
|
---|
1058 | void _dirtyHash(void);
|
---|
1059 | /** Internal method for recalculating the hash.
|
---|
1060 | @remarks
|
---|
1061 | Do not call this unless you are sure the old hash is not still being
|
---|
1062 | used by anything. If in doubt, call _dirtyHash if you want to force
|
---|
1063 | recalculation of the has next time.
|
---|
1064 | */
|
---|
1065 | void _recalculateHash(void);
|
---|
1066 | /** Tells the pass that it needs recompilation. */
|
---|
1067 | void _notifyNeedsRecompile(void);
|
---|
1068 |
|
---|
1069 | /** Update any automatic parameters (except lights) on this pass */
|
---|
1070 | void _updateAutoParamsNoLights(const AutoParamDataSource& source) const;
|
---|
1071 | /** Update any automatic light parameters on this pass */
|
---|
1072 | void _updateAutoParamsLightsOnly(const AutoParamDataSource& source) const;
|
---|
1073 |
|
---|
1074 | /** Set texture filtering for every texture unit
|
---|
1075 | @note
|
---|
1076 | This property actually exists on the TextureUnitState class
|
---|
1077 | For simplicity, this method allows you to set these properties for
|
---|
1078 | every current TeextureUnitState, If you need more precision, retrieve the
|
---|
1079 | TextureUnitState instance and set the property there.
|
---|
1080 | @see TextureUnitState::setTextureFiltering
|
---|
1081 | */
|
---|
1082 | void setTextureFiltering(TextureFilterOptions filterType);
|
---|
1083 | /** Sets the anisotropy level to be used for all textures.
|
---|
1084 | @note
|
---|
1085 | This property has been moved to the TextureUnitState class, which is accessible via the
|
---|
1086 | Technique and Pass. For simplicity, this method allows you to set these properties for
|
---|
1087 | every current TeextureUnitState, If you need more precision, retrieve the Technique,
|
---|
1088 | Pass and TextureUnitState instances and set the property there.
|
---|
1089 | @see TextureUnitState::setTextureAnisotropy
|
---|
1090 | */
|
---|
1091 | void setTextureAnisotropy(unsigned int maxAniso);
|
---|
1092 | /** Static method to retrieve all the Passes which need their
|
---|
1093 | hash values recalculated.
|
---|
1094 | */
|
---|
1095 | static const PassSet& getDirtyHashList(void)
|
---|
1096 | { return msDirtyHashList; }
|
---|
1097 | /** Static method to retrieve all the Passes which are pending deletion.
|
---|
1098 | */
|
---|
1099 | static const PassSet& getPassGraveyard(void)
|
---|
1100 | { return msPassGraveyard; }
|
---|
1101 | /** Static method to reset the list of passes which need their hash
|
---|
1102 | values recalculated.
|
---|
1103 | @remarks
|
---|
1104 | For performance, the dirty list is not updated progressively as
|
---|
1105 | the hashes are recalculated, instead we expect the processor of the
|
---|
1106 | dirty hash list to clear the list when they are done.
|
---|
1107 | */
|
---|
1108 | static void clearDirtyHashList(void) { msDirtyHashList.clear(); }
|
---|
1109 |
|
---|
1110 | /** Process all dirty and pending deletion passes. */
|
---|
1111 | static void processPendingPassUpdates(void);
|
---|
1112 |
|
---|
1113 | /** Queue this pass for deletion when appropriate. */
|
---|
1114 | void queueForDeletion(void);
|
---|
1115 |
|
---|
1116 | /** Returns whether this pass is ambient only.
|
---|
1117 | */
|
---|
1118 | bool isAmbientOnly(void) const;
|
---|
1119 |
|
---|
1120 | /** set the number of iterations that this pass
|
---|
1121 | should perform when doing fast multi pass operation.
|
---|
1122 | @remarks
|
---|
1123 | Only applicable for programmable passes.
|
---|
1124 | @param count number of iterations to perform fast multi pass operations.
|
---|
1125 | A value greater than 0 will cause the pass to be executed count number of
|
---|
1126 | times without changing the render state. This is very usefull for passes
|
---|
1127 | that use programmable shaders that have to iterate more than once but don't
|
---|
1128 | need a render state change. Using multi pass can dramatically speed up rendering
|
---|
1129 | for materials that do things like fur, blur.
|
---|
1130 | A value of 0 turns off multi pass operation and the pass does
|
---|
1131 | the normal pass operation.
|
---|
1132 | */
|
---|
1133 | void setPassIterationCount(const size_t count) { mPassIterationCount = count; }
|
---|
1134 |
|
---|
1135 | /** Gets the multi pass count value.
|
---|
1136 | */
|
---|
1137 | size_t getPassIterationCount(void) const { return mPassIterationCount; }
|
---|
1138 |
|
---|
1139 | /** Applies texture names to Texture Unit State with matching texture name aliases.
|
---|
1140 | All Texture Unit States within the pass are checked.
|
---|
1141 | If matching texture aliases are found then true is returned.
|
---|
1142 |
|
---|
1143 | @param
|
---|
1144 | aliasList is a map container of texture alias, texture name pairs
|
---|
1145 | @param
|
---|
1146 | apply set true to apply the texture aliases else just test to see if texture alias matches are found.
|
---|
1147 | @return
|
---|
1148 | True if matching texture aliases were found in the pass.
|
---|
1149 | */
|
---|
1150 | bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
|
---|
1151 |
|
---|
1152 | };
|
---|
1153 |
|
---|
1154 | enum IlluminationStage
|
---|
1155 | {
|
---|
1156 | /// Part of the rendering which occurs without any kind of direct lighting
|
---|
1157 | IS_AMBIENT,
|
---|
1158 | /// Part of the rendering which occurs per light
|
---|
1159 | IS_PER_LIGHT,
|
---|
1160 | /// Post-lighting rendering
|
---|
1161 | IS_DECAL
|
---|
1162 | };
|
---|
1163 | /** Struct recording a pass which can be used for a specific illumination stage.
|
---|
1164 | @remarks
|
---|
1165 | This structure is used to record categorised passes which fit into a
|
---|
1166 | number of distinct illumination phases - ambient, diffuse / specular
|
---|
1167 | (per-light) and decal (post-lighting texturing).
|
---|
1168 | An original pass may fit into one of these categories already, or it
|
---|
1169 | may require splitting into its component parts in order to be categorised
|
---|
1170 | properly.
|
---|
1171 | */
|
---|
1172 | struct IlluminationPass
|
---|
1173 | {
|
---|
1174 | IlluminationStage stage;
|
---|
1175 | /// The pass to use in this stage
|
---|
1176 | Pass* pass;
|
---|
1177 | /// Whether this pass is one which should be deleted itself
|
---|
1178 | bool destroyOnShutdown;
|
---|
1179 | /// The original pass which spawned this one
|
---|
1180 | Pass* originalPass;
|
---|
1181 | };
|
---|
1182 |
|
---|
1183 | typedef std::vector<IlluminationPass*> IlluminationPassList;
|
---|
1184 |
|
---|
1185 |
|
---|
1186 | }
|
---|
1187 |
|
---|
1188 | #endif
|
---|