/src/ogre/OgreMain/include/OgreMaterial.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 _Material_H__ |
29 | | #define _Material_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | |
33 | | #include "OgreResource.h" |
34 | | #include "OgreCommon.h" |
35 | | #include "OgreColourValue.h" |
36 | | #include "OgreBlendMode.h" |
37 | | #include "OgreHeaderPrefix.h" |
38 | | #include "OgreSharedPtr.h" |
39 | | |
40 | | namespace Ogre { |
41 | | |
42 | | // Forward declaration |
43 | | class LodStrategy; |
44 | | template <typename T> class ConstVectorIterator; |
45 | | template <typename T> class VectorIterator; |
46 | | |
47 | | /** \addtogroup Core |
48 | | * @{ |
49 | | */ |
50 | | /** \addtogroup Materials |
51 | | * @{ |
52 | | */ |
53 | | /** Class encapsulates rendering properties of an object. |
54 | | |
55 | | %Ogre's material class encapsulates *all* aspects of the visual appearance, |
56 | | of an object. It also includes other flags which |
57 | | might not be traditionally thought of as material properties such as |
58 | | culling modes and depth buffer settings, but these affect the |
59 | | appearance of the rendered object and are convenient to attach to the |
60 | | material since it keeps all the settings in one place. This is |
61 | | different to Direct3D which treats a material as just the colour |
62 | | components (diffuse, specular) and not texture maps etc. An Ogre |
63 | | Material can be thought of as equivalent to a 'Shader'. |
64 | | |
65 | | A Material can be rendered in multiple different ways depending on the |
66 | | hardware available. You may configure a Material to use high-complexity |
67 | | fragment shaders, but these won't work on every card; therefore a Technique |
68 | | is an approach to creating the visual effect you are looking for. You are advised |
69 | | to create fallback techniques with lower hardware requirements if you decide to |
70 | | use advanced features. In addition, you also might want lower-detail techniques |
71 | | for distant geometry. |
72 | | |
73 | | Each Technique can be made up of multiple passes. A fixed-function Pass |
74 | | may combine multiple texture layers using multitexturing, but Ogre can |
75 | | break that into multiple passes automatically if the active card cannot |
76 | | handle that many simultaneous textures. Programmable passes, however, cannot |
77 | | be split down automatically, so if the active graphics card cannot handle the |
78 | | technique which contains these passes, OGRE will try to find another technique |
79 | | which the card can do. If, at the end of the day, the card cannot handle any of the |
80 | | techniques which are listed for the material, the engine will render the |
81 | | geometry plain white, which should alert you to the problem. |
82 | | |
83 | | %Ogre comes configured with a number of default settings for a newly |
84 | | created material. These can be changed if you wish by retrieving the |
85 | | default material settings through |
86 | | MaterialManager::getDefaultSettings. Any changes you make to the |
87 | | Material returned from this method will apply to any materials created |
88 | | from this point onward. |
89 | | */ |
90 | | class _OgreExport Material final : public Resource |
91 | | { |
92 | | friend class SceneManager; |
93 | | friend class MaterialManager; |
94 | | |
95 | | public: |
96 | | /// distance list used to specify LOD |
97 | | typedef std::vector<Real> LodValueList; |
98 | | typedef ConstVectorIterator<LodValueList> LodValueIterator; |
99 | | typedef std::vector<Technique*> Techniques; |
100 | | private: |
101 | | |
102 | | |
103 | | /** Internal method which sets the material up from the default settings. |
104 | | */ |
105 | | void applyDefaults(void); |
106 | | |
107 | | /// All techniques, supported and unsupported |
108 | | Techniques mTechniques; |
109 | | /// Supported techniques of any sort |
110 | | Techniques mSupportedTechniques; |
111 | | typedef std::map<unsigned short, Technique*> LodTechniques; |
112 | | typedef std::map<unsigned short, LodTechniques> BestTechniquesBySchemeList; |
113 | | /** Map of scheme -> list of LOD techniques. |
114 | | Current scheme is set on MaterialManager, |
115 | | and can be set per Viewport for auto activation. |
116 | | */ |
117 | | BestTechniquesBySchemeList mBestTechniquesBySchemeList; |
118 | | |
119 | | LodValueList mUserLodValues; |
120 | | LodValueList mLodValues; |
121 | | const LodStrategy *mLodStrategy; |
122 | | /// Text description of why any techniques are not supported |
123 | | String mUnsupportedReasons; |
124 | | bool mReceiveShadows; |
125 | | bool mTransparencyCastsShadows; |
126 | | /// Does this material require compilation? |
127 | | bool mCompilationRequired; |
128 | | |
129 | | /** Insert a supported technique into the local collections. */ |
130 | | void insertSupportedTechnique(Technique* t); |
131 | | |
132 | | /** Clear the best technique list. |
133 | | */ |
134 | | void clearBestTechniqueList(void); |
135 | | |
136 | | void prepareImpl(void) override; |
137 | | void unprepareImpl(void) override; |
138 | | void loadImpl(void) override; |
139 | | |
140 | | /** Unloads the material, frees resources etc. |
141 | | @see |
142 | | Resource |
143 | | */ |
144 | | void unloadImpl(void) override; |
145 | | /// @copydoc Resource::calculateSize |
146 | | size_t calculateSize(void) const override; |
147 | | public: |
148 | | |
149 | | /** Constructor - use resource manager's create method rather than this. |
150 | | */ |
151 | | Material(ResourceManager* creator, const String& name, ResourceHandle handle, |
152 | | const String& group, bool isManual = false, ManualResourceLoader* loader = 0); |
153 | | |
154 | | ~Material(); |
155 | | /** Assignment operator to allow easy copying between materials. |
156 | | */ |
157 | | Material& operator=( const Material& rhs ); |
158 | | |
159 | | /** Determines if the material has any transparency with the rest of the scene (derived from |
160 | | whether any Techniques say they involve transparency). |
161 | | */ |
162 | | bool isTransparent(void) const; |
163 | | |
164 | | /** Sets whether objects using this material will receive shadows. |
165 | | |
166 | | This method allows a material to opt out of receiving shadows, if |
167 | | it would otherwise do so. Shadows will not be cast on any objects |
168 | | unless the scene is set up to support shadows |
169 | | (@see SceneManager::setShadowTechnique), and not all techniques cast |
170 | | shadows on all objects. In any case, if you have a need to prevent |
171 | | shadows being received by material, this is the method you call to |
172 | | do it. |
173 | | @note |
174 | | Transparent materials never receive shadows despite this setting. |
175 | | The default is to receive shadows. |
176 | | */ |
177 | 0 | void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; } |
178 | | /** Returns whether or not objects using this material will receive shadows. */ |
179 | 0 | bool getReceiveShadows(void) const { return mReceiveShadows; } |
180 | | |
181 | | /** Sets whether objects using this material be classified as opaque to the shadow caster system. |
182 | | |
183 | | This method allows a material to cast a shadow, even if it is transparent. |
184 | | By default, transparent materials neither cast nor receive shadows. Shadows |
185 | | will not be cast on any objects unless the scene is set up to support shadows |
186 | | (@see SceneManager::setShadowTechnique), and not all techniques cast |
187 | | shadows on all objects. |
188 | | */ |
189 | 0 | void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; } |
190 | | /** Returns whether or not objects using this material be classified as opaque to the shadow caster system. */ |
191 | 0 | bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; } |
192 | | |
193 | | typedef VectorIterator<Techniques> TechniqueIterator; |
194 | | /// @name Techniques |
195 | | /// @{ |
196 | | /** Creates a new Technique for this Material. |
197 | | |
198 | | A Technique is a single way of rendering geometry in order to achieve the effect |
199 | | you are intending in a material. There are many reason why you would want more than |
200 | | one - the main one being to handle variable graphics card abilities; you might have |
201 | | one technique which is impressive but only runs on 4th-generation graphics cards, |
202 | | for example. In this case you will want to create at least one fallback Technique. |
203 | | OGRE will work out which Techniques a card can support and pick the best one. |
204 | | @par |
205 | | If multiple Techniques are available, the order in which they are created is |
206 | | important - the engine will consider lower-indexed Techniques to be preferable |
207 | | to higher-indexed Techniques, ie when asked for the 'best' technique it will |
208 | | return the first one in the technique list which is supported by the hardware. |
209 | | */ |
210 | | Technique* createTechnique(void); |
211 | | /** Gets the indexed technique. */ |
212 | 0 | Technique* getTechnique(size_t index) const { return mTechniques.at(index); } |
213 | | /** searches for the named technique. |
214 | | Return 0 if technique with name is not found |
215 | | */ |
216 | | Technique* getTechnique(const String& name) const; |
217 | | /** Retrieves the number of techniques. */ |
218 | 0 | size_t getNumTechniques(void) const { return mTechniques.size(); } |
219 | | /** Removes the technique at the given index. */ |
220 | | void removeTechnique(unsigned short index); |
221 | | /** Removes all the techniques in this Material. */ |
222 | | void removeAllTechniques(void); |
223 | | /** Get an iterator over the Techniques in this Material. |
224 | | * @deprecated use getTechniques() */ |
225 | | OGRE_DEPRECATED TechniqueIterator getTechniqueIterator(void); |
226 | | |
227 | | /** Get the Techniques in this Material. */ |
228 | 0 | const Techniques& getTechniques(void) const { |
229 | 0 | return mTechniques; |
230 | 0 | } |
231 | | |
232 | | /** Gets all the Techniques which are supported by the current card. |
233 | | |
234 | | The supported technique list is only available after this material has been compiled, |
235 | | which typically happens on loading the material. Therefore, if this method returns |
236 | | an empty list, try calling Material::load. |
237 | | */ |
238 | 0 | const Techniques& getSupportedTechniques(void) const { |
239 | 0 | return mSupportedTechniques; |
240 | 0 | } |
241 | | |
242 | | /// @deprecated use getSupportedTechniques() |
243 | | OGRE_DEPRECATED TechniqueIterator getSupportedTechniqueIterator(void); |
244 | | |
245 | | /** Gets the indexed supported technique. */ |
246 | 0 | Technique* getSupportedTechnique(size_t index) const { return mSupportedTechniques.at(index); } |
247 | | /** Retrieves the number of supported techniques. */ |
248 | 0 | size_t getNumSupportedTechniques(void) const { return mSupportedTechniques.size(); } |
249 | | /** Gets a string explaining why any techniques are not supported. */ |
250 | 0 | const String& getUnsupportedTechniquesExplanation() const { return mUnsupportedReasons; } |
251 | | |
252 | | /** Gets the best supported technique. |
253 | | |
254 | | This method returns the lowest-index supported Technique in this material |
255 | | (since lower-indexed Techniques are considered to be better than higher-indexed |
256 | | ones). |
257 | | @par |
258 | | The best supported technique is only available after this material has been compiled, |
259 | | which typically happens on loading the material. Therefore, if this method returns |
260 | | NULL, try calling Material::load. |
261 | | @par |
262 | | The technique is chosen for the active material scheme (see |
263 | | MaterialManager::setActiveScheme). A Viewport only sets its scheme while it is |
264 | | being rendered and restores the previous one afterwards, so a query made outside |
265 | | rendering normally resolves against the Default scheme. |
266 | | @par |
267 | | A scheme technique may be created on demand by a MaterialManager::Listener, as the |
268 | | RTShaderSystem does. Such a technique is not created by Material::load. If this |
269 | | method returns NULL for a scheme served by a listener, make sure the scheme is active |
270 | | and the listener is registered, or create the technique explicitly with |
271 | | Ogre::RTShader::ShaderGenerator::createShaderBasedTechnique. |
272 | | @param lodIndex The material LOD index to use |
273 | | @param rend Optional parameter specifying the Renderable that is requesting |
274 | | this technique. Only used if no valid technique for the active material |
275 | | scheme is found, at which point it is passed to |
276 | | MaterialManager::Listener::handleSchemeNotFound as information. |
277 | | */ |
278 | | Technique* getBestTechnique(unsigned short lodIndex = 0, const Renderable* rend = 0); |
279 | | /// @} |
280 | | |
281 | | /** Creates a new copy of this material with the same settings but a new name. |
282 | | @param newName The name for the cloned material |
283 | | @param newGroup |
284 | | Optional name of the new group to assign the clone to; |
285 | | if you leave this blank, the clone will be assigned to the same |
286 | | group as this Material. |
287 | | */ |
288 | | MaterialPtr clone(const String& newName, const String& newGroup = BLANKSTRING) const; |
289 | | |
290 | | // needed because of deprecated variant below |
291 | 0 | MaterialPtr clone(const String& newName, const char* newGroup) const { return clone(newName, String(newGroup)); } |
292 | | |
293 | | /// @deprecated use clone(const String&, const String&) |
294 | | OGRE_DEPRECATED MaterialPtr clone(const String& newName, bool changeGroup, |
295 | | const String& newGroup = BLANKSTRING) const |
296 | 0 | { |
297 | 0 | return clone(newName, newGroup); |
298 | 0 | } |
299 | | |
300 | | /** Copies the details of this material into another, preserving the target's handle and name |
301 | | (unlike operator=) but copying everything else. |
302 | | @param mat Weak reference to material which will receive this material's settings. |
303 | | */ |
304 | | void copyDetailsTo(MaterialPtr& mat) const; |
305 | | |
306 | | /** 'Compiles' this Material. |
307 | | |
308 | | Compiling a material involves determining which Techniques are supported on the |
309 | | card on which OGRE is currently running, and for fixed-function Passes within those |
310 | | Techniques, splitting the passes down where they contain more TextureUnitState |
311 | | instances than the current card has texture units. |
312 | | @par |
313 | | This process is automatically done when the Material is loaded, but may be |
314 | | repeated if you make some procedural changes. |
315 | | @param |
316 | | autoManageTextureUnits If true, when a fixed function pass has too many TextureUnitState |
317 | | entries than the card has texture units, the Pass in question will be split into |
318 | | more than one Pass in order to emulate the Pass. If you set this to false and |
319 | | this situation arises, an Exception will be thrown. |
320 | | */ |
321 | | void compile(bool autoManageTextureUnits = true); |
322 | | |
323 | | /** @name Forwarded Pass Properties |
324 | | |
325 | | The following methods are to make migration from previous versions simpler |
326 | | and to make code easier to write when dealing with simple materials |
327 | | They set the properties which have been moved to Pass for all Techniques and all Passes |
328 | | */ |
329 | | |
330 | | /// @{ |
331 | | /** Sets the point size properties for every Pass in every Technique. |
332 | | @note |
333 | | This property has been moved to the Pass class, which is accessible via the |
334 | | Technique. For simplicity, this method allows you to set these properties for |
335 | | every current Technique, and for every current Pass within those Techniques. If |
336 | | you need more precision, retrieve the Technique and Pass instances and set the |
337 | | property there. |
338 | | @see Pass::setPointSize |
339 | | */ |
340 | | void setPointSize(Real ps); |
341 | | |
342 | | /** Sets the ambient colour reflectance properties for every Pass in every Technique. |
343 | | @note |
344 | | This property has been moved to the Pass class, which is accessible via the |
345 | | Technique. For simplicity, this method allows you to set these properties for |
346 | | every current Technique, and for every current Pass within those Techniques. If |
347 | | you need more precision, retrieve the Technique and Pass instances and set the |
348 | | property there. |
349 | | @see Pass::setAmbient |
350 | | */ |
351 | | void setAmbient(float red, float green, float blue); |
352 | | |
353 | | /// @overload |
354 | | void setAmbient(const ColourValue& ambient); |
355 | | |
356 | | /** Sets the diffuse colour reflectance properties of every Pass in every Technique. |
357 | | @note |
358 | | This property has been moved to the Pass class, which is accessible via the |
359 | | Technique. For simplicity, this method allows you to set these properties for |
360 | | every current Technique, and for every current Pass within those Techniques. If |
361 | | you need more precision, retrieve the Technique and Pass instances and set the |
362 | | property there. |
363 | | @see Pass::setDiffuse |
364 | | */ |
365 | | void setDiffuse(float red, float green, float blue, float alpha); |
366 | | |
367 | | /// @overload |
368 | | void setDiffuse(const ColourValue& diffuse); |
369 | | |
370 | | /** Sets the specular colour reflectance properties of every Pass in every Technique. |
371 | | @note |
372 | | This property has been moved to the Pass class, which is accessible via the |
373 | | Technique. For simplicity, this method allows you to set these properties for |
374 | | every current Technique, and for every current Pass within those Techniques. If |
375 | | you need more precision, retrieve the Technique and Pass instances and set the |
376 | | property there. |
377 | | @see Pass::setSpecular |
378 | | */ |
379 | | void setSpecular(float red, float green, float blue, float alpha); |
380 | | |
381 | | /// @overload |
382 | | void setSpecular(const ColourValue& specular); |
383 | | |
384 | | /** Sets the shininess properties of every Pass in every Technique. |
385 | | @note |
386 | | This property has been moved to the Pass class, which is accessible via the |
387 | | Technique. For simplicity, this method allows you to set these properties for |
388 | | every current Technique, and for every current Pass within those Techniques. If |
389 | | you need more precision, retrieve the Technique and Pass instances and set the |
390 | | property there. |
391 | | @see Pass::setShininess |
392 | | */ |
393 | | void setShininess(Real val); |
394 | | |
395 | | /** Sets the amount of self-illumination of every Pass in every Technique. |
396 | | @note |
397 | | This property has been moved to the Pass class, which is accessible via the |
398 | | Technique. For simplicity, this method allows you to set these properties for |
399 | | every current Technique, and for every current Pass within those Techniques. If |
400 | | you need more precision, retrieve the Technique and Pass instances and set the |
401 | | property there. |
402 | | @see Pass::setSelfIllumination |
403 | | */ |
404 | | void setSelfIllumination(float red, float green, float blue); |
405 | | |
406 | | /// @overload |
407 | | void setSelfIllumination(const ColourValue& selfIllum); |
408 | | |
409 | | /** Sets whether or not each Pass renders with depth-buffer checking on or not. |
410 | | @note |
411 | | This property has been moved to the Pass class, which is accessible via the |
412 | | Technique. For simplicity, this method allows you to set these properties for |
413 | | every current Technique, and for every current Pass within those Techniques. If |
414 | | you need more precision, retrieve the Technique and Pass instances and set the |
415 | | property there. |
416 | | @see Pass::setDepthCheckEnabled |
417 | | */ |
418 | | void setDepthCheckEnabled(bool enabled); |
419 | | |
420 | | /** Sets whether or not each Pass renders with depth-buffer writing on or not. |
421 | | @note |
422 | | This property has been moved to the Pass class, which is accessible via the |
423 | | Technique. For simplicity, this method allows you to set these properties for |
424 | | every current Technique, and for every current Pass within those Techniques. If |
425 | | you need more precision, retrieve the Technique and Pass instances and set the |
426 | | property there. |
427 | | @see Pass::setDepthWriteEnabled |
428 | | */ |
429 | | void setDepthWriteEnabled(bool enabled); |
430 | | |
431 | | /** Sets the function used to compare depth values when depth checking is on. |
432 | | @note |
433 | | This property has been moved to the Pass class, which is accessible via the |
434 | | Technique. For simplicity, this method allows you to set these properties for |
435 | | every current Technique, and for every current Pass within those Techniques. If |
436 | | you need more precision, retrieve the Technique and Pass instances and set the |
437 | | property there. |
438 | | @see Pass::setDepthFunction |
439 | | */ |
440 | | void setDepthFunction( CompareFunction func ); |
441 | | |
442 | | /** Sets whether or not colour buffer writing is enabled for each Pass. |
443 | | @note |
444 | | This property has been moved to the Pass class, which is accessible via the |
445 | | Technique. For simplicity, this method allows you to set these properties for |
446 | | every current Technique, and for every current Pass within those Techniques. If |
447 | | you need more precision, retrieve the Technique and Pass instances and set the |
448 | | property there. |
449 | | @see Pass::setColourWriteEnabled |
450 | | */ |
451 | | void setColourWriteEnabled(bool enabled); |
452 | | |
453 | | /** Sets which colour buffer channels are enabled for writing for each Pass. |
454 | | @see Pass::setColourWriteEnabled |
455 | | */ |
456 | | void setColourWriteEnabled(bool red, bool green, bool blue, bool alpha); |
457 | | |
458 | | /** Sets the culling mode for each pass based on the 'vertex winding'. |
459 | | @note |
460 | | This property has been moved to the Pass class, which is accessible via the |
461 | | Technique. For simplicity, this method allows you to set these properties for |
462 | | every current Technique, and for every current Pass within those Techniques. If |
463 | | you need more precision, retrieve the Technique and Pass instances and set the |
464 | | property there. |
465 | | @see Pass::setCullingMode |
466 | | */ |
467 | | void setCullingMode( CullingMode mode ); |
468 | | |
469 | | /** Sets the manual culling mode, performed by CPU rather than hardware. |
470 | | @note |
471 | | This property has been moved to the Pass class, which is accessible via the |
472 | | Technique. For simplicity, this method allows you to set these properties for |
473 | | every current Technique, and for every current Pass within those Techniques. If |
474 | | you need more precision, retrieve the Technique and Pass instances and set the |
475 | | property there. |
476 | | @see Pass::setManualCullingMode |
477 | | */ |
478 | | void setManualCullingMode( ManualCullingMode mode ); |
479 | | |
480 | | /** Sets whether or not dynamic lighting is enabled for every Pass. |
481 | | @note |
482 | | This property has been moved to the Pass class, which is accessible via the |
483 | | Technique. For simplicity, this method allows you to set these properties for |
484 | | every current Technique, and for every current Pass within those Techniques. If |
485 | | you need more precision, retrieve the Technique and Pass instances and set the |
486 | | property there. |
487 | | @see Pass::setLightingEnabled |
488 | | */ |
489 | | void setLightingEnabled(bool enabled); |
490 | | |
491 | | /** Sets the type of light shading required |
492 | | @note |
493 | | This property has been moved to the Pass class, which is accessible via the |
494 | | Technique. For simplicity, this method allows you to set these properties for |
495 | | every current Technique, and for every current Pass within those Techniques. If |
496 | | you need more precision, retrieve the Technique and Pass instances and set the |
497 | | property there. |
498 | | @see Pass::setShadingMode |
499 | | */ |
500 | | void setShadingMode( ShadeOptions mode ); |
501 | | |
502 | | /** Sets the fogging mode applied to each pass. |
503 | | @note |
504 | | This property has been moved to the Pass class, which is accessible via the |
505 | | Technique. For simplicity, this method allows you to set these properties for |
506 | | every current Technique, and for every current Pass within those Techniques. If |
507 | | you need more precision, retrieve the Technique and Pass instances and set the |
508 | | property there. |
509 | | @see Pass::setFog |
510 | | */ |
511 | | void setFog( |
512 | | bool overrideScene, |
513 | | FogMode mode = FOG_NONE, |
514 | | const ColourValue& colour = ColourValue::White, |
515 | | Real expDensity = 0.001f, Real linearStart = 0.0f, Real linearEnd = 1.0f ); |
516 | | |
517 | | /** Sets the depth bias to be used for each Pass. |
518 | | @note |
519 | | This property has been moved to the Pass class, which is accessible via the |
520 | | Technique. For simplicity, this method allows you to set these properties for |
521 | | every current Technique, and for every current Pass within those Techniques. If |
522 | | you need more precision, retrieve the Technique and Pass instances and set the |
523 | | property there. |
524 | | @see Pass::setDepthBias |
525 | | */ |
526 | | void setDepthBias(float constantBias, float slopeScaleBias); |
527 | | |
528 | | /** Set texture filtering for every texture unit in every Technique and Pass |
529 | | @note |
530 | | This property has been moved to the TextureUnitState class, which is accessible via the |
531 | | Technique and Pass. For simplicity, this method allows you to set these properties for |
532 | | every current TeextureUnitState, If you need more precision, retrieve the Technique, |
533 | | Pass and TextureUnitState instances and set the property there. |
534 | | @see TextureUnitState::setTextureFiltering |
535 | | */ |
536 | | void setTextureFiltering(TextureFilterOptions filterType); |
537 | | /** Sets the anisotropy level to be used for all textures. |
538 | | @note |
539 | | This property has been moved to the TextureUnitState class, which is accessible via the |
540 | | Technique and Pass. For simplicity, this method allows you to set these properties for |
541 | | every current TeextureUnitState, If you need more precision, retrieve the Technique, |
542 | | Pass and TextureUnitState instances and set the property there. |
543 | | @see TextureUnitState::setTextureAnisotropy |
544 | | */ |
545 | | void setTextureAnisotropy(int maxAniso); |
546 | | |
547 | | /** Sets the kind of blending every pass has with the existing contents of the scene. |
548 | | @note |
549 | | This property has been moved to the Pass class, which is accessible via the |
550 | | Technique. For simplicity, this method allows you to set these properties for |
551 | | every current Technique, and for every current Pass within those Techniques. If |
552 | | you need more precision, retrieve the Technique and Pass instances and set the |
553 | | property there. |
554 | | @see Pass::setSceneBlending |
555 | | */ |
556 | | void setSceneBlending( const SceneBlendType sbt ); |
557 | | |
558 | | /** Sets the kind of blending every pass has with the existing contents of the scene, using individual factors for color and alpha channels |
559 | | @note |
560 | | This property has been moved to the Pass class, which is accessible via the |
561 | | Technique. For simplicity, this method allows you to set these properties for |
562 | | every current Technique, and for every current Pass within those Techniques. If |
563 | | you need more precision, retrieve the Technique and Pass instances and set the |
564 | | property there. |
565 | | @see Pass::setSeparateSceneBlending |
566 | | */ |
567 | | void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta ); |
568 | | |
569 | | /** Allows very fine control of blending every Pass with the existing contents of the scene. |
570 | | @note |
571 | | This property has been moved to the Pass class, which is accessible via the |
572 | | Technique. For simplicity, this method allows you to set these properties for |
573 | | every current Technique, and for every current Pass within those Techniques. If |
574 | | you need more precision, retrieve the Technique and Pass instances and set the |
575 | | property there. |
576 | | @see Pass::setSceneBlending |
577 | | */ |
578 | | void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); |
579 | | |
580 | | /** Allows very fine control of blending every Pass with the existing contents of the scene, using individual factors for color and alpha channels |
581 | | @note |
582 | | This property has been moved to the Pass class, which is accessible via the |
583 | | Technique. For simplicity, this method allows you to set these properties for |
584 | | every current Technique, and for every current Pass within those Techniques. If |
585 | | you need more precision, retrieve the Technique and Pass instances and set the |
586 | | property there. |
587 | | @see Pass::setSeparateSceneBlending |
588 | | */ |
589 | | void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha); |
590 | | /// @} |
591 | | |
592 | | /** Tells the material that it needs recompilation. */ |
593 | | void _notifyNeedsRecompile(void); |
594 | | |
595 | | /// @name Level of Detail |
596 | | /// @{ |
597 | | /** Gets the number of levels-of-detail this material has in the |
598 | | given scheme, based on Technique::setLodIndex. |
599 | | |
600 | | Note that this will not be up to date until the material has been compiled. |
601 | | */ |
602 | | unsigned short getNumLodLevels(unsigned short schemeIndex) const; |
603 | | /** Gets the number of levels-of-detail this material has in the |
604 | | given scheme, based on Technique::setLodIndex. |
605 | | |
606 | | Note that this will not be up to date until the material has been compiled. |
607 | | */ |
608 | | unsigned short getNumLodLevels(const String& schemeName) const; |
609 | | /** Sets the distance at which level-of-detail (LOD) levels come into effect. |
610 | | |
611 | | You should only use this if you have assigned LOD indexes to the Technique |
612 | | instances attached to this Material. If you have done so, you should call this |
613 | | method to determine the distance at which the lowe levels of detail kick in. |
614 | | The decision about what distance is actually used is a combination of this |
615 | | and the LOD bias applied to both the current Camera and the current Entity. |
616 | | @param lodValues A vector of Reals which indicate the LOD value at which to |
617 | | switch to lower details. They are listed in LOD index order, starting at index |
618 | | 1 (ie the first level down from the highest level 0, which automatically applies |
619 | | from a value of 0). These are 'user values', before being potentially |
620 | | transformed by the strategy, so for the distance strategy this is an |
621 | | unsquared distance for example. |
622 | | */ |
623 | | void setLodLevels(const LodValueList& lodValues); |
624 | | |
625 | | /** Gets the list of values transformed by the LodStrategy at which each LOD comes into effect. |
626 | | |
627 | | Note that the iterator returned from this method is not totally analogous to |
628 | | the one passed in by calling setLodLevels - the list includes a zero |
629 | | entry at the start (since the highest LOD starts at value 0). Also, the |
630 | | values returned are after being transformed by LodStrategy::transformUserValue. |
631 | | */ |
632 | 0 | const LodValueList& getLodValues(void) const { |
633 | 0 | return mLodValues; |
634 | 0 | } |
635 | | |
636 | | /// @deprecated use getLodValues() |
637 | | OGRE_DEPRECATED LodValueIterator getLodValueIterator(void) const; |
638 | | |
639 | | /** Gets the user-defined list of values which are internally transformed by the LodStrategy. |
640 | | |
641 | | Note that the iterator returned from this method is not totally analogous to |
642 | | the one passed in by calling setLodLevels - the list includes a zero |
643 | | entry at the start (since the highest LOD starts at value 0). Also, the |
644 | | values returned are after being transformed by LodStrategy::transformUserValue. |
645 | | */ |
646 | 0 | const LodValueList& getUserLodValues(void) const { |
647 | 0 | return mUserLodValues; |
648 | 0 | } |
649 | | |
650 | | /// @deprecated use getUserLodValues() |
651 | | OGRE_DEPRECATED LodValueIterator getUserLodValueIterator(void) const; |
652 | | |
653 | | /** Gets the LOD index to use at the given value. |
654 | | @note The value passed in is the 'transformed' value. If you are dealing with |
655 | | an original source value (e.g. distance), use LodStrategy::transformUserValue |
656 | | to turn this into a lookup value. |
657 | | */ |
658 | | ushort getLodIndex(Real value) const; |
659 | | |
660 | | /** Get LOD strategy used by this material. */ |
661 | | const LodStrategy *getLodStrategy() const; |
662 | | /** Set the LOD strategy used by this material. */ |
663 | | void setLodStrategy(LodStrategy *lodStrategy); |
664 | | /// @} |
665 | | |
666 | | void touch(void) override |
667 | 0 | { |
668 | 0 | if (mCompilationRequired) |
669 | 0 | compile(); |
670 | 0 | // call superclass |
671 | 0 | Resource::touch(); |
672 | 0 | } |
673 | | |
674 | | /** Gets the compilation status of the material. |
675 | | @return True if the material needs recompilation. |
676 | | */ |
677 | | bool getCompilationRequired() const |
678 | 0 | { |
679 | 0 | return mCompilationRequired; |
680 | 0 | } |
681 | | |
682 | | |
683 | | }; |
684 | | /** @} */ |
685 | | /** @} */ |
686 | | |
687 | | } //namespace |
688 | | |
689 | | #include "OgreHeaderSuffix.h" |
690 | | |
691 | | #endif |