/src/ogre/OgreMain/include/OgreTechnique.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #ifndef __Technique_H__ |
29 | | #define __Technique_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | #include "OgreCommon.h" |
33 | | #include "OgrePass.h" |
34 | | #include "OgreRenderSystemCapabilities.h" |
35 | | #include "OgreUserObjectBindings.h" |
36 | | #include "OgreHeaderPrefix.h" |
37 | | |
38 | | namespace Ogre { |
39 | | /** \addtogroup Core |
40 | | * @{ |
41 | | */ |
42 | | /** \addtogroup Materials |
43 | | * @{ |
44 | | */ |
45 | | /** Class representing an approach to rendering this particular Material. |
46 | | |
47 | | Ogre will attempt to use the best technique supported by the active hardware, |
48 | | unless you specifically request a lower detail technique (say for distant |
49 | | rendering). |
50 | | */ |
51 | | class _OgreExport Technique : public TechniqueAlloc |
52 | | { |
53 | | public: |
54 | | typedef std::vector<Pass*> Passes; |
55 | | |
56 | | private: |
57 | | /// Illumination pass state type |
58 | | enum IlluminationPassesState : int8 |
59 | | { |
60 | | IPS_COMPILE_DISABLED = -1, |
61 | | IPS_NOT_COMPILED = 0, |
62 | | IPS_COMPILED = 1 |
63 | | }; |
64 | | |
65 | | /// List of primary passes |
66 | | Passes mPasses; |
67 | | /// List of derived passes, categorised into IlluminationStage (ordered) |
68 | | IlluminationPassList mIlluminationPasses; |
69 | | // Raw pointer since we don't want child to stop parent's destruction |
70 | | Material* mParent; |
71 | | IlluminationPassesState mIlluminationPassesCompilationPhase; |
72 | | |
73 | | bool mIsSupported; |
74 | | /// LOD level |
75 | | unsigned short mLodIndex; |
76 | | /** Scheme index, derived from scheme name but the names are held on |
77 | | MaterialManager, for speed an index is used here. |
78 | | */ |
79 | | unsigned short mSchemeIndex; |
80 | | /// Optional name for the technique |
81 | | String mName; |
82 | | /// Internal method for clearing illumination pass list |
83 | | void clearIlluminationPasses(void); |
84 | | /// Internal method - check for manually assigned illumination passes |
85 | | bool checkManuallyOrganisedIlluminationPasses(); |
86 | | |
87 | | |
88 | | /** When casting shadow, if not using default Ogre shadow casting material, or |
89 | | * nor using fixed function casting, mShadowCasterMaterial let you customize per material |
90 | | * shadow caster behavior |
91 | | */ |
92 | | MaterialPtr mShadowCasterMaterial; |
93 | | /** When casting shadow, if not using default Ogre shadow casting material, or |
94 | | * nor using fixed function casting, mShadowCasterMaterial let you customize per material |
95 | | * shadow caster behavior.There only material name is stored so that it can be loaded once all file parsed in a resource group. |
96 | | */ |
97 | | String mShadowCasterMaterialName; |
98 | | /** When receiving shadow, if not using default Ogre shadow receiving material, or |
99 | | * nor using fixed function texture projection receiving, mShadowReceiverMaterial let you customize per material |
100 | | * shadow caster behavior |
101 | | */ |
102 | | MaterialPtr mShadowReceiverMaterial; |
103 | | /** When receiving shadow, if not using default Ogre shadow receiving material, or |
104 | | * nor using fixed function texture projection receiving, mShadowReceiverMaterial let you customize per material |
105 | | * shadow caster behavior. There only material name is stored so that it can be loaded once all file parsed in a resource group. |
106 | | */ |
107 | | String mShadowReceiverMaterialName; |
108 | | |
109 | | // User objects binding. |
110 | | UserObjectBindings mUserObjectBindings; |
111 | | public: |
112 | | /** Directive used to manually control technique support based on the |
113 | | inclusion or exclusion of some factor. |
114 | | */ |
115 | | enum IncludeOrExclude |
116 | | { |
117 | | /// Inclusive - only support if present |
118 | | INCLUDE = 0, |
119 | | /// Exclusive - do not support if present |
120 | | EXCLUDE = 1 |
121 | | }; |
122 | | /// Rule controlling whether technique is deemed supported based on GPU vendor |
123 | | struct GPUVendorRule |
124 | | { |
125 | | GPUVendor vendor; |
126 | | IncludeOrExclude includeOrExclude; |
127 | | GPUVendorRule() |
128 | 0 | : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {} |
129 | | GPUVendorRule(GPUVendor v, IncludeOrExclude ie) |
130 | 0 | : vendor(v), includeOrExclude(ie) {} |
131 | | }; |
132 | | /// Rule controlling whether technique is deemed supported based on GPU device name |
133 | | struct GPUDeviceNameRule |
134 | | { |
135 | | String devicePattern; |
136 | | IncludeOrExclude includeOrExclude; |
137 | | bool caseSensitive; |
138 | | GPUDeviceNameRule() |
139 | 0 | : includeOrExclude(EXCLUDE), caseSensitive(false) {} |
140 | | GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen) |
141 | 0 | : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {} |
142 | | }; |
143 | | typedef std::vector<GPUVendorRule> GPUVendorRuleList; |
144 | | typedef std::vector<GPUDeviceNameRule> GPUDeviceNameRuleList; |
145 | | private: |
146 | | GPUVendorRuleList mGPUVendorRules; |
147 | | GPUDeviceNameRuleList mGPUDeviceNameRules; |
148 | | public: |
149 | | /// Constructor |
150 | | Technique(Material* parent); |
151 | | /// Copy constructor |
152 | | Technique(Material* parent, const Technique& oth); |
153 | | ~Technique(); |
154 | | /** Indicates if this technique is supported by the current graphics card. |
155 | | |
156 | | This will only be correct after the Technique has been compiled, which is |
157 | | usually done from Material::compile. |
158 | | */ |
159 | | bool isSupported(void) const; |
160 | | /** Internal compilation method; see Material::compile. |
161 | | @return Any information explaining problems with the compile. |
162 | | */ |
163 | | String _compile(bool autoManageTextureUnits); |
164 | | /// Internal method for checking hardware support |
165 | | bool checkHardwareSupport(bool autoManageTextureUnits, StringStream& compileErrors); |
166 | | size_t calculateSize(void) const; |
167 | | |
168 | | typedef VectorIterator<Passes> PassIterator; |
169 | | typedef VectorIterator<IlluminationPassList> IlluminationPassIterator; |
170 | | /// @name Passes |
171 | | /// @{ |
172 | | /** Creates a new Pass for this Technique. |
173 | | |
174 | | A Pass is a single rendering pass, i.e. a single draw of the given material. |
175 | | Note that if you create a pass without a fragment program, during compilation of the |
176 | | material the pass may be split into multiple passes if the graphics card cannot |
177 | | handle the number of texture units requested. For passes with fragment programs, however, |
178 | | the number of passes you create will never be altered, so you have to make sure |
179 | | that you create an alternative fallback Technique for if a card does not have |
180 | | enough facilities for what you're asking for. |
181 | | */ |
182 | | Pass* createPass(void); |
183 | | /** Retrieves the Pass with the given index.*/ |
184 | 0 | Pass* getPass(size_t index) const { return mPasses.at(index); } |
185 | | /** Retrieves the Pass matching name. |
186 | | Returns 0 if name match is not found. |
187 | | */ |
188 | | Pass* getPass(const String& name) const; |
189 | | /** Retrieves the number of passes. */ |
190 | 0 | size_t getNumPasses(void) const { return mPasses.size(); } |
191 | | /** Removes the Pass with the given index. */ |
192 | | void removePass(unsigned short index); |
193 | | /** Removes all Passes from this Technique. */ |
194 | | void removeAllPasses(void); |
195 | | /** Move a pass from source index to destination index. |
196 | | If successful then returns true. |
197 | | */ |
198 | | bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex); |
199 | | |
200 | | /** Gets an iterator over the passes in this Technique. |
201 | | * @deprecated use getPasses() */ |
202 | | OGRE_DEPRECATED const PassIterator getPassIterator(void); |
203 | | |
204 | | /** Gets the passes in this Technique. */ |
205 | 0 | const Passes& getPasses(void) const { |
206 | 0 | return mPasses; |
207 | 0 | } |
208 | | |
209 | | /** Gets the illumination-stage categorised passes |
210 | | * @note triggers compilation if needed */ |
211 | | const IlluminationPassList& getIlluminationPasses(); |
212 | | |
213 | | /** Internal method for splitting the passes into illumination passes. */ |
214 | | void _compileIlluminationPasses(void); |
215 | | /// @} |
216 | | |
217 | | /// Gets the parent Material |
218 | 0 | Material* getParent(void) const { return mParent; } |
219 | | |
220 | | /** Overloaded operator to copy on Technique to another. */ |
221 | | Technique& operator=(const Technique& rhs); |
222 | | |
223 | | /// Gets the resource group of the ultimate parent Material |
224 | | const String& getResourceGroup(void) const; |
225 | | |
226 | | /** Returns true if this Technique involves transparency. |
227 | | |
228 | | This basically boils down to whether the first pass |
229 | | has a scene blending factor. Even if the other passes |
230 | | do not, the base colour, including parts of the original |
231 | | scene, may be used for blending, therefore we have to treat |
232 | | the whole Technique as transparent. |
233 | | */ |
234 | | bool isTransparent(void) const; |
235 | | |
236 | | /** Returns true if this Technique has transparent sorting enabled. |
237 | | |
238 | | This basically boils down to whether the first pass |
239 | | has transparent sorting enabled or not |
240 | | */ |
241 | | bool isTransparentSortingEnabled(void) const; |
242 | | |
243 | | /** Returns true if this Technique has transparent sorting forced. |
244 | | |
245 | | This basically boils down to whether the first pass |
246 | | has transparent sorting forced or not |
247 | | */ |
248 | | bool isTransparentSortingForced(void) const; |
249 | | |
250 | | /** Internal prepare method, derived from call to Material::prepare. */ |
251 | | void _prepare(void); |
252 | | /** Internal unprepare method, derived from call to Material::unprepare. */ |
253 | | void _unprepare(void); |
254 | | /** Internal load method, derived from call to Material::load. */ |
255 | | void _load(void); |
256 | | /** Internal unload method, derived from call to Material::unload. */ |
257 | | void _unload(void); |
258 | | |
259 | | /// Is this loaded? |
260 | | bool isLoaded(void) const; |
261 | | |
262 | | /** Tells the technique that it needs recompilation. */ |
263 | | void _notifyNeedsRecompile(void); |
264 | | |
265 | | /// @name Shadow Materials |
266 | | /// @{ |
267 | | /** return this material specific shadow casting specific material |
268 | | */ |
269 | | MaterialPtr getShadowCasterMaterial() const; |
270 | | /** Sets the details of the material to use when rendering as a |
271 | | shadow caster. |
272 | | |
273 | | Texture-based shadows require that the caster is rendered to a texture |
274 | | in a solid colour (the shadow colour in the case of modulative texture |
275 | | shadows). Whilst Ogre can arrange this for the fixed function |
276 | | pipeline, passes which use vertex programs might need the vertex |
277 | | programs still to run in order to preserve any deformation etc |
278 | | that it does. However, lighting calculations must be a lot simpler, |
279 | | with only the ambient colour being used (which the engine will ensure |
280 | | is bound to the shadow colour). |
281 | | @par |
282 | | Therefore, it is up to implementors of vertex programs to provide an |
283 | | alternative material which can be used to render the object |
284 | | to a shadow texture. Do all the same vertex transforms, but set the |
285 | | colour of the vertex to the ambient colour, as bound using the |
286 | | standard auto parameter binding mechanism. |
287 | | */ |
288 | | void setShadowCasterMaterial(MaterialPtr val); |
289 | | /** set this material specific shadow casting specific material |
290 | | */ |
291 | | void setShadowCasterMaterial(const String &name); |
292 | | /** return this material specific shadow receiving specific material |
293 | | */ |
294 | | MaterialPtr getShadowReceiverMaterial() const; |
295 | | /** set this material specific shadow receiving specific material |
296 | | */ |
297 | | void setShadowReceiverMaterial(MaterialPtr val); |
298 | | /** set this material specific shadow receiving specific material |
299 | | */ |
300 | | void setShadowReceiverMaterial(const String &name); |
301 | | /// @} |
302 | | |
303 | | /** @name Forwarded Pass Properties |
304 | | |
305 | | The following methods are to make migration from previous versions simpler |
306 | | and to make code easier to write when dealing with simple materials |
307 | | They set the properties which have been moved to Pass for all Techniques and all Passes |
308 | | */ |
309 | | |
310 | | /// @{ |
311 | | /** Sets the point size properties for every Pass in this Technique. |
312 | | @note |
313 | | This property actually exists on the Pass class. For simplicity, this method allows |
314 | | you to set these properties for every current Pass within this Technique. If |
315 | | you need more precision, retrieve the Pass instance and set the |
316 | | property there. |
317 | | @see Pass::setPointSize |
318 | | */ |
319 | | void setPointSize(Real ps); |
320 | | |
321 | | /** Sets the ambient colour reflectance properties for every Pass in every Technique. |
322 | | @note |
323 | | This property actually exists on the Pass class. For simplicity, this method allows |
324 | | you to set these properties for every current Pass within this Technique. If |
325 | | you need more precision, retrieve the Pass instance and set the |
326 | | property there. |
327 | | @see Pass::setAmbient |
328 | | */ |
329 | | void setAmbient(float red, float green, float blue); |
330 | | |
331 | | /// @overload |
332 | | void setAmbient(const ColourValue& ambient); |
333 | | |
334 | | /** Sets the diffuse colour reflectance properties of every Pass in every Technique. |
335 | | @note |
336 | | This property actually exists on the Pass class. For simplicity, this method allows |
337 | | you to set these properties for every current Pass within this Technique. If |
338 | | you need more precision, retrieve the Pass instance and set the |
339 | | property there. |
340 | | @see Pass::setDiffuse |
341 | | */ |
342 | | void setDiffuse(float red, float green, float blue, float alpha); |
343 | | |
344 | | /// @overload |
345 | | void setDiffuse(const ColourValue& diffuse); |
346 | | |
347 | | /** Sets the specular colour reflectance properties of every Pass in every Technique. |
348 | | @note |
349 | | This property actually exists on the Pass class. For simplicity, this method allows |
350 | | you to set these properties for every current Pass within this Technique. If |
351 | | you need more precision, retrieve the Pass instance and set the |
352 | | property there. |
353 | | @see Pass::setSpecular |
354 | | */ |
355 | | void setSpecular(float red, float green, float blue, float alpha); |
356 | | |
357 | | /// @overload |
358 | | void setSpecular(const ColourValue& specular); |
359 | | |
360 | | /** Sets the shininess properties of every Pass in every Technique. |
361 | | @note |
362 | | This property actually exists on the Pass class. For simplicity, this method allows |
363 | | you to set these properties for every current Pass within this Technique. If |
364 | | you need more precision, retrieve the Pass instance and set the |
365 | | property there. |
366 | | @see Pass::setShininess |
367 | | */ |
368 | | void setShininess(Real val); |
369 | | |
370 | | /** Sets the amount of self-illumination of every Pass in every Technique. |
371 | | @note |
372 | | This property actually exists on the Pass class. For simplicity, this method allows |
373 | | you to set these properties for every current Pass within this Technique. If |
374 | | you need more precision, retrieve the Pass instance and set the |
375 | | property there. |
376 | | @see Pass::setSelfIllumination |
377 | | */ |
378 | | void setSelfIllumination(float red, float green, float blue); |
379 | | |
380 | | /// @overload |
381 | | void setSelfIllumination(const ColourValue& selfIllum); |
382 | | |
383 | | /** Sets whether or not each Pass renders with depth-buffer checking on or not. |
384 | | @note |
385 | | This property actually exists on the Pass class. For simplicity, this method allows |
386 | | you to set these properties for every current Pass within this Technique. If |
387 | | you need more precision, retrieve the Pass instance and set the |
388 | | property there. |
389 | | @see Pass::setDepthCheckEnabled |
390 | | */ |
391 | | void setDepthCheckEnabled(bool enabled); |
392 | | |
393 | | /** Sets whether or not each Pass renders with depth-buffer writing on or not. |
394 | | @note |
395 | | This property actually exists on the Pass class. For simplicity, this method allows |
396 | | you to set these properties for every current Pass within this Technique. If |
397 | | you need more precision, retrieve the Pass instance and set the |
398 | | property there. |
399 | | @see Pass::setDepthWriteEnabled |
400 | | */ |
401 | | void setDepthWriteEnabled(bool enabled); |
402 | | |
403 | | /** Sets the function used to compare depth values when depth checking is on. |
404 | | @note |
405 | | This property actually exists on the Pass class. For simplicity, this method allows |
406 | | you to set these properties for every current Pass within this Technique. If |
407 | | you need more precision, retrieve the Pass instance and set the |
408 | | property there. |
409 | | @see Pass::setDepthFunction |
410 | | */ |
411 | | void setDepthFunction( CompareFunction func ); |
412 | | |
413 | | /** Sets whether or not colour buffer writing is enabled for each Pass. |
414 | | @note |
415 | | This property actually exists on the Pass class. For simplicity, this method allows |
416 | | you to set these properties for every current Pass within this Technique. If |
417 | | you need more precision, retrieve the Pass instance and set the |
418 | | property there. |
419 | | @see Pass::setColourWriteEnabled |
420 | | */ |
421 | | void setColourWriteEnabled(bool enabled); |
422 | | |
423 | | /** Sets which colour buffer channels are enabled for writing for each Pass. |
424 | | @see Pass::setColourWriteEnabled |
425 | | */ |
426 | | void setColourWriteEnabled(bool red, bool green, bool blue, bool alpha); |
427 | | |
428 | | /** Sets the culling mode for each pass based on the 'vertex winding'. |
429 | | @note |
430 | | This property actually exists on the Pass class. For simplicity, this method allows |
431 | | you to set these properties for every current Pass within this Technique. If |
432 | | you need more precision, retrieve the Pass instance and set the |
433 | | property there. |
434 | | @see Pass::setCullingMode |
435 | | */ |
436 | | void setCullingMode( CullingMode mode ); |
437 | | |
438 | | /** Sets the manual culling mode, performed by CPU rather than hardware. |
439 | | @note |
440 | | This property actually exists on the Pass class. For simplicity, this method allows |
441 | | you to set these properties for every current Pass within this Technique. If |
442 | | you need more precision, retrieve the Pass instance and set the |
443 | | property there. |
444 | | @see Pass::setManualCullingMode |
445 | | */ |
446 | | void setManualCullingMode( ManualCullingMode mode ); |
447 | | |
448 | | /** Sets whether or not dynamic lighting is enabled for every Pass. |
449 | | @note |
450 | | This property actually exists on the Pass class. For simplicity, this method allows |
451 | | you to set these properties for every current Pass within this Technique. If |
452 | | you need more precision, retrieve the Pass instance and set the |
453 | | property there. |
454 | | @see Pass::setLightingEnabled |
455 | | */ |
456 | | void setLightingEnabled(bool enabled); |
457 | | |
458 | | /** Sets the type of light shading required |
459 | | @note |
460 | | This property actually exists on the Pass class. For simplicity, this method allows |
461 | | you to set these properties for every current Pass within this Technique. If |
462 | | you need more precision, retrieve the Pass instance and set the |
463 | | property there. |
464 | | @see Pass::setShadingMode |
465 | | */ |
466 | | void setShadingMode( ShadeOptions mode ); |
467 | | |
468 | | /** Sets the fogging mode applied to each pass. |
469 | | @note |
470 | | This property actually exists on the Pass class. For simplicity, this method allows |
471 | | you to set these properties for every current Pass within this Technique. If |
472 | | you need more precision, retrieve the Pass instance and set the |
473 | | property there. |
474 | | @see Pass::setFog |
475 | | */ |
476 | | void setFog( |
477 | | bool overrideScene, |
478 | | FogMode mode = FOG_NONE, |
479 | | const ColourValue& colour = ColourValue::White, |
480 | | Real expDensity = 0.001f, Real linearStart = 0.0f, Real linearEnd = 1.0f ); |
481 | | |
482 | | /** Sets the depth bias to be used for each Pass. |
483 | | @note |
484 | | This property actually exists on the Pass class. For simplicity, this method allows |
485 | | you to set these properties for every current Pass within this Technique. If |
486 | | you need more precision, retrieve the Pass instance and set the |
487 | | property there. |
488 | | @see Pass::setDepthBias |
489 | | */ |
490 | | void setDepthBias(float constantBias, float slopeScaleBias); |
491 | | |
492 | | /** Set texture filtering for every texture unit in every Pass |
493 | | @note |
494 | | This property actually exists on the TextureUnitState class |
495 | | For simplicity, this method allows you to set these properties for |
496 | | every current TeextureUnitState, If you need more precision, retrieve the |
497 | | Pass and TextureUnitState instances and set the property there. |
498 | | @see TextureUnitState::setTextureFiltering |
499 | | */ |
500 | | void setTextureFiltering(TextureFilterOptions filterType); |
501 | | /** Sets the anisotropy level to be used for all textures. |
502 | | @note |
503 | | This property has been moved to the TextureUnitState class, which is accessible via the |
504 | | Technique and Pass. For simplicity, this method allows you to set these properties for |
505 | | every current TeextureUnitState, If you need more precision, retrieve the Technique, |
506 | | Pass and TextureUnitState instances and set the property there. |
507 | | @see TextureUnitState::setTextureAnisotropy |
508 | | */ |
509 | | void setTextureAnisotropy(unsigned int maxAniso); |
510 | | |
511 | | /** Sets the kind of blending every pass has with the existing contents of the scene. |
512 | | @note |
513 | | This property actually exists on the Pass class. For simplicity, this method allows |
514 | | you to set these properties for every current Pass within this Technique. If |
515 | | you need more precision, retrieve the Pass instance and set the |
516 | | property there. |
517 | | @see Pass::setSceneBlending |
518 | | */ |
519 | | void setSceneBlending( const SceneBlendType sbt ); |
520 | | |
521 | | /** Sets the kind of blending every pass has with the existing contents of the scene, using individual factors both color and alpha channels |
522 | | @note |
523 | | This property actually exists on the Pass class. For simplicity, this method allows |
524 | | you to set these properties for every current Pass within this Technique. If |
525 | | you need more precision, retrieve the Pass instance and set the |
526 | | property there. |
527 | | @see Pass::setSeparateSceneBlending |
528 | | */ |
529 | | void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta ); |
530 | | |
531 | | /** Allows very fine control of blending every Pass with the existing contents of the scene. |
532 | | @note |
533 | | This property actually exists on the Pass class. For simplicity, this method allows |
534 | | you to set these properties for every current Pass within this Technique. If |
535 | | you need more precision, retrieve the Pass instance and set the |
536 | | property there. |
537 | | @see Pass::setSceneBlending |
538 | | */ |
539 | | void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); |
540 | | |
541 | | /** Allows very fine control of blending every Pass with the existing contents of the scene, using individual factors both color and alpha channels |
542 | | @note |
543 | | This property actually exists on the Pass class. For simplicity, this method allows |
544 | | you to set these properties for every current Pass within this Technique. If |
545 | | you need more precision, retrieve the Pass instance and set the |
546 | | property there. |
547 | | @see Pass::setSeparateSceneBlending |
548 | | */ |
549 | | void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha); |
550 | | /// @} |
551 | | |
552 | | /** Assigns a level-of-detail (LOD) index to this Technique. |
553 | | |
554 | | As noted previously, as well as providing fallback support for various |
555 | | graphics cards, multiple Technique objects can also be used to implement |
556 | | material LOD, where the detail of the material diminishes with distance to |
557 | | save rendering power. |
558 | | @par |
559 | | By default, all Techniques have a LOD index of 0, which means they are the highest |
560 | | level of detail. Increasing LOD indexes are lower levels of detail. You can |
561 | | assign more than one Technique to the same LOD index, meaning that the best |
562 | | Technique that is supported at that LOD index is used. |
563 | | @par |
564 | | You should not leave gaps in the LOD sequence; Ogre will allow you to do this |
565 | | and will continue to function as if the LODs were sequential, but it will |
566 | | confuse matters. |
567 | | */ |
568 | | void setLodIndex(unsigned short index); |
569 | | /** Gets the level-of-detail index assigned to this Technique. */ |
570 | 0 | unsigned short getLodIndex(void) const { return mLodIndex; } |
571 | | |
572 | | /** Set the 'scheme name' for this technique. |
573 | | |
574 | | Material schemes are used to control top-level switching from one |
575 | | set of techniques to another. For example, you might use this to |
576 | | define 'high', 'medium' and 'low' complexity levels on materials |
577 | | to allow a user to pick a performance / quality ratio. Another |
578 | | possibility is that you have a fully HDR-enabled pipeline for top |
579 | | machines, rendering all objects using unclamped shaders, and a |
580 | | simpler pipeline for others; this can be implemented using |
581 | | schemes. |
582 | | @par |
583 | | Every technique belongs to a scheme - if you don't specify one, the |
584 | | Technique belongs to the scheme called 'Default', which is also the |
585 | | scheme used to render by default. The active scheme is set one of |
586 | | two ways - either by calling Viewport::setMaterialScheme, or |
587 | | by manually calling MaterialManager::setActiveScheme. |
588 | | */ |
589 | | void setSchemeName(const String& schemeName); |
590 | | /** Returns the scheme to which this technique is assigned. |
591 | | @see Technique::setSchemeName |
592 | | */ |
593 | | const String& getSchemeName(void) const; |
594 | | |
595 | | /// Internal method for getting the scheme index |
596 | | unsigned short _getSchemeIndex(void) const; |
597 | | |
598 | | /** Is depth writing going to occur on this technique? */ |
599 | | bool isDepthWriteEnabled(void) const; |
600 | | |
601 | | /** Is depth checking going to occur on this technique? */ |
602 | | bool isDepthCheckEnabled(void) const; |
603 | | |
604 | | /** Exists colour writing disabled pass on this technique? */ |
605 | | bool hasColourWriteDisabled(void) const; |
606 | | |
607 | | /** Set the name of the technique. |
608 | | |
609 | | The use of technique name is optional. Its useful in material scripts where a material could inherit |
610 | | from another material and only want to modify a particular technique. |
611 | | */ |
612 | | void setName(const String& name); |
613 | | /// Gets the name of the technique |
614 | 0 | const String& getName(void) const { return mName; } |
615 | | |
616 | | typedef ConstVectorIterator<GPUVendorRuleList> GPUVendorRuleIterator; |
617 | | typedef ConstVectorIterator<GPUDeviceNameRuleList> GPUDeviceNameRuleIterator; |
618 | | /// @name GPU Vendor Rules |
619 | | /// @{ |
620 | | |
621 | | /// Internal method for checking GPU vendor / device rules |
622 | | bool checkGPURules(StringStream& errors); |
623 | | /** Add a rule which manually influences the support for this technique based |
624 | | on a GPU vendor. |
625 | | |
626 | | You can use this facility to manually control whether a technique is |
627 | | considered supported, based on a GPU vendor. You can add inclusive |
628 | | or exclusive rules, and you can add as many of each as you like. If |
629 | | at least one inclusive rule is added, a technique is considered |
630 | | unsupported if it does not match any of those inclusive rules. If exclusive rules are |
631 | | added, the technique is considered unsupported if it matches any of |
632 | | those inclusive rules. |
633 | | @note |
634 | | Any rule for the same vendor will be removed before adding this one. |
635 | | @param vendor The GPU vendor |
636 | | @param includeOrExclude Whether this is an inclusive or exclusive rule |
637 | | */ |
638 | | void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude); |
639 | | /** Add a rule which manually influences the support for this technique based |
640 | | on a GPU vendor. |
641 | | |
642 | | You can use this facility to manually control whether a technique is |
643 | | considered supported, based on a GPU vendor. You can add inclusive |
644 | | or exclusive rules, and you can add as many of each as you like. If |
645 | | at least one inclusive rule is added, a technique is considered |
646 | | unsupported if it does not match any of those inclusive rules. If exclusive rules are |
647 | | added, the technique is considered unsupported if it matches any of |
648 | | those inclusive rules. |
649 | | @note |
650 | | Any rule for the same vendor will be removed before adding this one. |
651 | | */ |
652 | | void addGPUVendorRule(const GPUVendorRule& rule); |
653 | | /** Removes a matching vendor rule. |
654 | | @see addGPUVendorRule |
655 | | */ |
656 | | void removeGPUVendorRule(GPUVendor vendor); |
657 | | /// @deprecated use getGPUVendorRules() |
658 | | OGRE_DEPRECATED GPUVendorRuleIterator getGPUVendorRuleIterator() const; |
659 | | /// Get the currently registered vendor rules. |
660 | 0 | const GPUVendorRuleList& getGPUVendorRules() const { |
661 | 0 | return mGPUVendorRules; |
662 | 0 | } |
663 | | |
664 | | /** Add a rule which manually influences the support for this technique based |
665 | | on a pattern that matches a GPU device name (e.g. '*8800*'). |
666 | | |
667 | | You can use this facility to manually control whether a technique is |
668 | | considered supported, based on a GPU device name pattern. You can add inclusive |
669 | | or exclusive rules, and you can add as many of each as you like. If |
670 | | at least one inclusive rule is added, a technique is considered |
671 | | unsupported if it does not match any of those inclusive rules. If exclusive rules are |
672 | | added, the technique is considered unsupported if it matches any of |
673 | | those inclusive rules. The pattern you supply can include wildcard |
674 | | characters ('*') if you only want to match part of the device name. |
675 | | @note |
676 | | Any rule for the same device pattern will be removed before adding this one. |
677 | | @param devicePattern The GPU vendor |
678 | | @param includeOrExclude Whether this is an inclusive or exclusive rule |
679 | | @param caseSensitive Whether the match is case sensitive or not |
680 | | */ |
681 | | void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false); |
682 | | /// @overload |
683 | | void addGPUDeviceNameRule(const GPUDeviceNameRule& rule); |
684 | | /** Removes a matching device name rule. |
685 | | @see addGPUDeviceNameRule |
686 | | */ |
687 | | void removeGPUDeviceNameRule(const String& devicePattern); |
688 | | /// @deprecated use getGPUDeviceNameRules() |
689 | | OGRE_DEPRECATED GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const; |
690 | | /// Get the currently registered device name rules. |
691 | 0 | const GPUDeviceNameRuleList& getGPUDeviceNameRules() const { return mGPUDeviceNameRules; } |
692 | | /// @} |
693 | | |
694 | | /// @copydoc UserObjectBindings |
695 | 0 | UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; } |
696 | | |
697 | | /// @overload |
698 | 0 | const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; } |
699 | | |
700 | | }; |
701 | | |
702 | | /** @} */ |
703 | | /** @} */ |
704 | | |
705 | | } |
706 | | |
707 | | #include "OgreHeaderSuffix.h" |
708 | | |
709 | | #endif |