/src/ogre/OgreMain/include/OgreTextureUnitState.h
Line | Count | Source (jump to first uncovered line) |
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 __TextureUnitState_H__ |
29 | | #define __TextureUnitState_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | #include "OgreCommon.h" |
33 | | #include "OgreBlendMode.h" |
34 | | #include "OgreMatrix4.h" |
35 | | #include "OgreTexture.h" |
36 | | #include "OgreHeaderPrefix.h" |
37 | | #include "OgreRenderSystem.h" |
38 | | |
39 | | namespace Ogre { |
40 | | enum TexCoordCalcMethod : uint8; |
41 | | |
42 | | /** \addtogroup Core |
43 | | * @{ |
44 | | */ |
45 | | /** \addtogroup Materials |
46 | | * @{ |
47 | | */ |
48 | | |
49 | | /** Class which determines how a TextureUnitState accesses data from a Texture |
50 | | |
51 | | There are a number of parameters affecting how texture data is fetched. |
52 | | Most notably @ref FilterOptions and @ref TextureAddressingMode. |
53 | | */ |
54 | | class _OgreExport Sampler { |
55 | | public: |
56 | | /** Texture addressing mode for each texture coordinate. */ |
57 | | struct UVWAddressingMode |
58 | | { |
59 | | TextureAddressingMode u, v, w; |
60 | | }; |
61 | | |
62 | | /// must be created through TextureManager |
63 | | Sampler(); |
64 | | virtual ~Sampler(); |
65 | | |
66 | | /** Set the texture filtering for this unit, using the simplified interface. |
67 | | |
68 | | You also have the option of specifying the minification, magnification |
69 | | and mip filter individually if you want more control over filtering |
70 | | options. See the alternative setTextureFiltering methods for details. |
71 | | @param filterType |
72 | | The high-level filter type to use. |
73 | | */ |
74 | | void setFiltering(TextureFilterOptions filterType); |
75 | | /** Set a single filtering option on this texture unit. |
76 | | @param ftype |
77 | | The filtering type to set. |
78 | | @param opts |
79 | | The filtering option to set. |
80 | | */ |
81 | | void setFiltering(FilterType ftype, FilterOptions opts); |
82 | | /** Set a the detailed filtering options on this texture unit. |
83 | | @param minFilter |
84 | | The filtering to use when reducing the size of the texture. |
85 | | Can be Ogre::FO_POINT, Ogre::FO_LINEAR or Ogre::FO_ANISOTROPIC. |
86 | | @param magFilter |
87 | | The filtering to use when increasing the size of the texture. |
88 | | Can be Ogre::FO_POINT, Ogre::FO_LINEAR or Ogre::FO_ANISOTROPIC. |
89 | | @param mipFilter |
90 | | The filtering to use between mip levels. |
91 | | Can be Ogre::FO_NONE (turns off mipmapping), Ogre::FO_POINT or Ogre::FO_LINEAR (trilinear filtering). |
92 | | */ |
93 | | void setFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter); |
94 | | /// Get the texture filtering for the given type. |
95 | | FilterOptions getFiltering(FilterType ftype) const; |
96 | | |
97 | | /** Gets the texture addressing mode for a given coordinate, |
98 | | i.e. what happens at uv values above 1.0. |
99 | | @note |
100 | | The default is TAM_WRAP i.e. the texture repeats over values of 1.0. |
101 | | */ |
102 | 0 | const UVWAddressingMode& getAddressingMode() const { return mAddressMode; } |
103 | | |
104 | | /** Sets the texture addressing mode, i.e. what happens at uv values above 1.0. |
105 | | |
106 | | The default is TAM_WRAP i.e. the texture repeats over values of 1.0. |
107 | | This is a shortcut method which sets the addressing mode for all |
108 | | coordinates at once; you can also call the more specific method |
109 | | to set the addressing mode per coordinate. |
110 | | |
111 | | This is a shortcut method which sets the addressing mode for all |
112 | | coordinates at once; you can also call the more specific method |
113 | | to set the addressing mode per coordinate. |
114 | | */ |
115 | 4 | void setAddressingMode(TextureAddressingMode tam) { setAddressingMode({tam, tam, tam}); } |
116 | | |
117 | | /** Sets the texture addressing mode, i.e. what happens at uv values above 1.0. |
118 | | |
119 | | The default is #TAM_WRAP i.e. the texture repeats over values of 1.0. |
120 | | */ |
121 | | void setAddressingMode(TextureAddressingMode u, TextureAddressingMode v, |
122 | | TextureAddressingMode w) |
123 | 0 | { |
124 | 0 | setAddressingMode({u, v, w}); |
125 | 0 | } |
126 | | /// @overload |
127 | | void setAddressingMode(const UVWAddressingMode& uvw); |
128 | | |
129 | | /** Sets the anisotropy level to be used for this texture level. |
130 | | |
131 | | The degree of anisotropy is the ratio between the height of the texture segment visible in a |
132 | | screen space region versus the width - so for example a floor plane, which stretches on into |
133 | | the distance and thus the vertical texture coordinates change much faster than the |
134 | | horizontal ones, has a higher anisotropy than a wall which is facing you head on (which has |
135 | | an anisotropy of 1 if your line of sight is perfectly perpendicular to it).The maximum value |
136 | | is determined by the hardware, but it is usually 8 or 16. |
137 | | |
138 | | In order for this to be used, you have to set the minification and/or the magnification |
139 | | option on this texture to Ogre::FO_ANISOTROPIC. |
140 | | @param maxAniso |
141 | | The maximal anisotropy level, should be between 2 and the maximum |
142 | | supported by hardware (1 is the default, ie. no anisotropy). |
143 | | */ |
144 | | void setAnisotropy(unsigned int maxAniso) |
145 | 0 | { |
146 | 0 | mMaxAniso = maxAniso; |
147 | 0 | mDirty = true; |
148 | 0 | } |
149 | | /// Get this layer texture anisotropy level. |
150 | 0 | unsigned int getAnisotropy() const { return mMaxAniso; } |
151 | | |
152 | | /** Sets the bias value applied to the mipmap calculation. |
153 | | |
154 | | You can alter the mipmap calculation by biasing the result with a |
155 | | single floating point value. After the mip level has been calculated, |
156 | | this bias value is added to the result to give the final mip level. |
157 | | Lower mip levels are larger (higher detail), so a negative bias will |
158 | | force the larger mip levels to be used, and a positive bias |
159 | | will cause smaller mip levels to be used. The bias values are in |
160 | | mip levels, so a -1 bias will force mip levels one larger than by the |
161 | | default calculation. |
162 | | |
163 | | In order for this option to be used, your hardware has to support mipmap biasing |
164 | | (exposed through Ogre::RSC_MIPMAP_LOD_BIAS), and your minification filtering has to be |
165 | | set to point or linear. |
166 | | */ |
167 | | void setMipmapBias(float bias) |
168 | 0 | { |
169 | 0 | mMipmapBias = bias; |
170 | 0 | mDirty = true; |
171 | 0 | } |
172 | | /** Gets the bias value applied to the mipmap calculation. |
173 | | @see TextureUnitState::setTextureMipmapBias |
174 | | */ |
175 | 0 | float getMipmapBias(void) const { return mMipmapBias; } |
176 | | |
177 | | /** Enables or disables the comparison test for depth textures. |
178 | | * |
179 | | * When enabled, sampling the texture returns how the sampled value compares against a |
180 | | * reference value instead of the sampled value itself. Combined with linear filtering this |
181 | | * can be used to implement hardware PCF for shadow maps. |
182 | | */ |
183 | | void setCompareEnabled(bool enabled) |
184 | 0 | { |
185 | 0 | mCompareEnabled = enabled; |
186 | 0 | mDirty = true; |
187 | 0 | } |
188 | 0 | bool getCompareEnabled() const { return mCompareEnabled; } |
189 | | |
190 | | void setCompareFunction(CompareFunction function) |
191 | 0 | { |
192 | 0 | mCompareFunc = function; |
193 | 0 | mDirty = true; |
194 | 0 | } |
195 | 0 | CompareFunction getCompareFunction() const { return mCompareFunc; } |
196 | | |
197 | | /** Sets the texture border colour. |
198 | | |
199 | | The default is ColourValue::Black, and this value only used when addressing mode |
200 | | is TAM_BORDER. |
201 | | */ |
202 | | void setBorderColour(const ColourValue& colour) |
203 | 0 | { |
204 | 0 | mBorderColour = colour; |
205 | 0 | mDirty = true; |
206 | 0 | } |
207 | 0 | const ColourValue& getBorderColour(void) const { return mBorderColour; } |
208 | | |
209 | | protected: |
210 | | ColourValue mBorderColour; |
211 | | /// Texture anisotropy. |
212 | | unsigned int mMaxAniso; |
213 | | /// Mipmap bias (always float, not Real). |
214 | | float mMipmapBias; |
215 | | UVWAddressingMode mAddressMode; |
216 | | /// Texture filtering - minification. |
217 | | FilterOptions mMinFilter; |
218 | | /// Texture filtering - magnification. |
219 | | FilterOptions mMagFilter; |
220 | | /// Texture filtering - mipmapping. |
221 | | FilterOptions mMipFilter; |
222 | | CompareFunction mCompareFunc; |
223 | | bool mCompareEnabled : 1; |
224 | | bool mDirty : 1; // flag for derived classes to sync with implementation |
225 | | }; |
226 | | typedef std::shared_ptr<Sampler> SamplerPtr; |
227 | | |
228 | | /** Class representing the state of a single texture unit during a Pass of a |
229 | | Technique, of a Material. |
230 | | |
231 | | Texture units are pipelines for retrieving texture data for rendering onto |
232 | | your objects in the world. Using them is common to both the fixed-function and |
233 | | the programmable (vertex and fragment program) pipeline, but some of the |
234 | | settings will only have an effect in the fixed-function pipeline (for example, |
235 | | setting a texture rotation will have no effect if you use the programmable |
236 | | pipeline, because this is overridden by the fragment program). The effect |
237 | | of each setting as regards the 2 pipelines is commented in each setting. |
238 | | |
239 | | When I use the term 'fixed-function pipeline' I mean traditional rendering |
240 | | where you do not use vertex or fragment programs (shaders). Programmable |
241 | | pipeline means that for this pass you are using vertex or fragment programs. |
242 | | */ |
243 | | class _OgreExport TextureUnitState : public TextureUnitStateAlloc |
244 | | { |
245 | | friend class RenderSystem; |
246 | | public: |
247 | | /** Definition of the broad types of texture effect you can apply to a texture unit. |
248 | | */ |
249 | | enum TextureEffectType |
250 | | { |
251 | | /// Generate all texture coords based on angle between camera and vertex. |
252 | | ET_ENVIRONMENT_MAP, |
253 | | /// Generate texture coords based on a frustum. |
254 | | ET_PROJECTIVE_TEXTURE, |
255 | | /// Constant u/v scrolling effect. |
256 | | ET_UVSCROLL, |
257 | | /// Constant u scrolling effect. |
258 | | ET_USCROLL, |
259 | | /// Constant u/v scrolling effect. |
260 | | ET_VSCROLL, |
261 | | /// Constant rotation. |
262 | | ET_ROTATE, |
263 | | /// More complex transform. |
264 | | ET_TRANSFORM |
265 | | |
266 | | }; |
267 | | |
268 | | /// rather use @ref TexCoordCalcMethod |
269 | | enum EnvMapType : uint8 |
270 | | { |
271 | | /// same as #TEXCALC_ENVIRONMENT_MAP_PLANAR |
272 | | ENV_PLANAR = TEXCALC_ENVIRONMENT_MAP_PLANAR, |
273 | | /// same as #TEXCALC_ENVIRONMENT_MAP |
274 | | ENV_CURVED = TEXCALC_ENVIRONMENT_MAP, |
275 | | /// same as #TEXCALC_ENVIRONMENT_MAP_REFLECTION |
276 | | ENV_REFLECTION = TEXCALC_ENVIRONMENT_MAP_REFLECTION, |
277 | | /// same as #TEXCALC_ENVIRONMENT_MAP_NORMAL |
278 | | ENV_NORMAL = TEXCALC_ENVIRONMENT_MAP_NORMAL |
279 | | }; |
280 | | |
281 | | /** Useful enumeration when dealing with procedural transforms. |
282 | | */ |
283 | | enum TextureTransformType |
284 | | { |
285 | | TT_TRANSLATE_U, |
286 | | TT_TRANSLATE_V, |
287 | | TT_SCALE_U, |
288 | | TT_SCALE_V, |
289 | | TT_ROTATE |
290 | | }; |
291 | | |
292 | | |
293 | | static const Ogre::TextureAddressingMode TAM_WRAP = Ogre::TAM_WRAP; |
294 | | static const Ogre::TextureAddressingMode TAM_MIRROR = Ogre::TAM_MIRROR; |
295 | | static const Ogre::TextureAddressingMode TAM_CLAMP = Ogre::TAM_CLAMP; |
296 | | static const Ogre::TextureAddressingMode TAM_BORDER = Ogre::TAM_BORDER; |
297 | | |
298 | | OGRE_DEPRECATED typedef Ogre::TextureAddressingMode TextureAddressingMode; |
299 | | OGRE_DEPRECATED typedef Sampler::UVWAddressingMode UVWAddressingMode; |
300 | | |
301 | | /** Enum identifying the frame indexes for faces of a cube map (not the composite 3D type. |
302 | | */ |
303 | | enum TextureCubeFace |
304 | | { |
305 | | CUBE_FRONT = 0, |
306 | | CUBE_BACK = 1, |
307 | | CUBE_LEFT = 2, |
308 | | CUBE_RIGHT = 3, |
309 | | CUBE_UP = 4, |
310 | | CUBE_DOWN = 5 |
311 | | }; |
312 | | |
313 | | /** Internal structure defining a texture effect. |
314 | | */ |
315 | | struct TextureEffect { |
316 | | TextureEffectType type; |
317 | | float arg1, arg2; |
318 | | int subtype; |
319 | | WaveformType waveType; |
320 | | float base; |
321 | | float frequency; |
322 | | float phase; |
323 | | float amplitude; |
324 | | ControllerFloat* controller; |
325 | | const Frustum* frustum; |
326 | | }; |
327 | | |
328 | | /** Texture effects in a multimap paired array. |
329 | | */ |
330 | | typedef std::multimap<TextureEffectType, TextureEffect> EffectMap; |
331 | | |
332 | | /** Default constructor. |
333 | | */ |
334 | | TextureUnitState(Pass* parent); |
335 | | |
336 | | TextureUnitState(Pass* parent, const TextureUnitState& oth ); |
337 | | |
338 | | TextureUnitState & operator = ( const TextureUnitState& oth ); |
339 | | |
340 | | /** Default destructor. |
341 | | */ |
342 | | ~TextureUnitState(); |
343 | | |
344 | | /** Name-based constructor. |
345 | | @param parent the parent Pass object. |
346 | | @param texName |
347 | | The basic name of the texture e.g. brickwall.jpg, stonefloor.png. |
348 | | @param texCoordSet |
349 | | The index of the texture coordinate set to use. |
350 | | */ |
351 | | TextureUnitState( Pass* parent, const String& texName, uint8 texCoordSet = 0); |
352 | | |
353 | | /** Get the name of current texture image for this layer. |
354 | | |
355 | | This will either always be a single name for this layer, |
356 | | or will be the name of the current frame for an animated |
357 | | or otherwise multi-frame texture. |
358 | | */ |
359 | | const String& getTextureName(void) const; |
360 | | |
361 | | /** Sets this texture layer to use a single texture, given the |
362 | | name of the texture to use on this layer. |
363 | | */ |
364 | | void setTextureName( const String& name); |
365 | | |
366 | | /// @overload |
367 | | void setTextureName( const String& name, TextureType ttype); |
368 | | |
369 | | /** Sets this texture layer to use a single texture, given the |
370 | | pointer to the texture to use on this layer. |
371 | | */ |
372 | | void setTexture( const TexturePtr& texPtr); |
373 | | |
374 | | /** |
375 | | @deprecated use setTextureName() |
376 | | */ |
377 | | OGRE_DEPRECATED void setCubicTextureName( const String& name, bool forUVW = false ) |
378 | 0 | { |
379 | 0 | setTextureName(name, TEX_TYPE_CUBE_MAP); |
380 | 0 | } |
381 | | |
382 | | /** |
383 | | @deprecated use setLayerArrayNames() |
384 | | */ |
385 | | OGRE_DEPRECATED void setCubicTextureName( const String* const names, bool forUVW = false ); |
386 | | |
387 | | /** |
388 | | @deprecated use setTexture() |
389 | | */ |
390 | | OGRE_DEPRECATED void setCubicTexture( const TexturePtr* const texPtrs, bool forUVW = false ) |
391 | 0 | { |
392 | 0 | setTexture(*texPtrs); |
393 | 0 | } |
394 | | |
395 | | /** Sets the names of the texture images for an animated texture. |
396 | | |
397 | | Animated textures are just a series of images making up the frames of the animation. All the images |
398 | | must be the same size, and their names must have a frame number appended before the extension, e.g. |
399 | | if you specify a name of "flame.jpg" with 3 frames, the image names must be "flame_0.jpg", "flame_1.jpg" |
400 | | and "flame_2.jpg". |
401 | | |
402 | | You can change the active frame on a texture layer by calling the Ogre::TextureUnitState::setCurrentFrame method. |
403 | | @note |
404 | | If you can't make your texture images conform to the naming standard laid out here, you |
405 | | can call the alternative setAnimatedTextureName method which takes an array of names instead. |
406 | | @param name |
407 | | The base name of the textures to use e.g. flame.jpg for frames flame_0.jpg, flame_1.jpg etc. |
408 | | @param numFrames |
409 | | The number of frames in the sequence. |
410 | | @param duration |
411 | | The length of time it takes to display the whole animation sequence, in seconds. |
412 | | If 0, no automatic transition occurs. |
413 | | */ |
414 | | void setAnimatedTextureName( const String& name, size_t numFrames, Real duration = 0 ); |
415 | | |
416 | | /// @overload |
417 | | /// @deprecated use setAnimatedTextureName( const std::vector<String>&, Real ) |
418 | | void setAnimatedTextureName( const String* const names, size_t numFrames, Real duration = 0 ); |
419 | | |
420 | | /// @overload |
421 | | void setAnimatedTextureName( const std::vector<String>& names, Real duration = 0 ) |
422 | 0 | { |
423 | 0 | setAnimatedTextureName(names.data(), names.size(), duration); |
424 | 0 | } |
425 | | |
426 | | /// Sets this texture layer to use an array of texture maps |
427 | | void setLayerArrayNames(TextureType type, const std::vector<String>& names); |
428 | | |
429 | | /** Returns the width and height of the texture in the given frame. |
430 | | */ |
431 | | std::pair<uint32, uint32> getTextureDimensions(unsigned int frame = 0) const; |
432 | | |
433 | | /** Changes the active frame in an animated or multi-image texture. |
434 | | |
435 | | An animated texture (or a cubic texture where the images are not combined for 3D use) is made up of |
436 | | a number of frames. This method sets the active frame. |
437 | | */ |
438 | | void setCurrentFrame( unsigned int frameNumber ); |
439 | | |
440 | | /** Gets the active frame in an animated or multi-image texture layer. |
441 | | */ |
442 | | unsigned int getCurrentFrame(void) const; |
443 | | |
444 | | /** Gets the name of the texture associated with a frame number. |
445 | | Throws an exception if frameNumber exceeds the number of stored frames. |
446 | | */ |
447 | | const String& getFrameTextureName(unsigned int frameNumber) const; |
448 | | |
449 | | /** Sets the name of the texture associated with a frame. |
450 | | @param name |
451 | | The name of the texture. |
452 | | @param frameNumber |
453 | | The frame the texture name is to be placed in. |
454 | | @note |
455 | | Throws an exception if frameNumber exceeds the number of stored frames. |
456 | | */ |
457 | | void setFrameTextureName(const String& name, unsigned int frameNumber); |
458 | | |
459 | | /** Add a Texture name to the end of the frame container. |
460 | | @param name |
461 | | The name of the texture. |
462 | | */ |
463 | | void addFrameTextureName(const String& name); |
464 | | /** Deletes a specific texture frame. The texture used is not deleted but the |
465 | | texture will no longer be used by the Texture Unit. An exception is raised |
466 | | if the frame number exceeds the number of actual frames. |
467 | | @param frameNumber |
468 | | The frame number of the texture to be deleted. |
469 | | */ |
470 | | void deleteFrameTextureName(const size_t frameNumber); |
471 | | /** Gets the number of frames for a texture. |
472 | | */ |
473 | | unsigned int getNumFrames(void) const; |
474 | | |
475 | | /** Enum identifying the type of content this texture unit contains. |
476 | | */ |
477 | | enum ContentType : uint8 |
478 | | { |
479 | | /// The default option, this derives texture content from a texture name, loaded by |
480 | | /// ordinary means from a file or having been manually created with a given name. |
481 | | CONTENT_NAMED = 0, |
482 | | /// A shadow texture, automatically bound by engine |
483 | | CONTENT_SHADOW = 1, |
484 | | /// This option allows you to reference a texture from a compositor, and is only valid |
485 | | /// when the pass is rendered within a compositor sequence. |
486 | | CONTENT_COMPOSITOR = 2 |
487 | | }; |
488 | | |
489 | | /** Set the type of content this TextureUnitState references. |
490 | | |
491 | | The default is to reference a standard named texture, but this unit |
492 | | can also reference automated content like a shadow texture. |
493 | | */ |
494 | | void setContentType(ContentType ct); |
495 | | /** Get the type of content this TextureUnitState references. */ |
496 | | ContentType getContentType(void) const; |
497 | | |
498 | | /// @deprecated use getTextureType() |
499 | 0 | OGRE_DEPRECATED bool isCubic(void) const { return getTextureType() == TEX_TYPE_CUBE_MAP; } |
500 | | |
501 | | /// @deprecated use getTextureType() |
502 | 0 | OGRE_DEPRECATED bool is3D(void) const { return getTextureType() == TEX_TYPE_CUBE_MAP; } |
503 | | |
504 | | /** Returns the type of this texture. |
505 | | */ |
506 | | TextureType getTextureType(void) const; |
507 | | |
508 | | /// @copydoc Texture::setFormat |
509 | | void setDesiredFormat(PixelFormat desiredFormat); |
510 | | |
511 | | /// @copydoc Texture::getDesiredFormat |
512 | | PixelFormat getDesiredFormat(void) const; |
513 | | |
514 | | /// @copydoc Texture::setNumMipmaps |
515 | | void setNumMipmaps(int numMipmaps); |
516 | | |
517 | | /** Gets how many mipmaps have been requested for the texture. |
518 | | */ |
519 | | int getNumMipmaps(void) const; |
520 | | |
521 | | /// @deprecated use setDesiredFormat(PF_A8) |
522 | | OGRE_DEPRECATED void setIsAlpha(bool isAlpha); |
523 | | |
524 | | /// @copydoc Texture::getGamma |
525 | | float getGamma() const; |
526 | | /// @copydoc Texture::setGamma |
527 | | void setGamma(float gamma); |
528 | | |
529 | | /// @copydoc Texture::setHardwareGammaEnabled |
530 | | void setHardwareGammaEnabled(bool enabled); |
531 | | /// @copydoc Texture::isHardwareGammaEnabled |
532 | | bool isHardwareGammaEnabled() const; |
533 | | |
534 | | /** Gets the index of the set of texture co-ords this layer uses. |
535 | | @note |
536 | | Only applies to the fixed function pipeline and has no effect if a fragment program is used. |
537 | | */ |
538 | | uint8 getTextureCoordSet(void) const; |
539 | | |
540 | | /** Sets which texture coordinate set is to be used for this texture layer. |
541 | | |
542 | | A mesh can define multiple sets of texture coordinates, this sets which one this |
543 | | material uses. |
544 | | */ |
545 | | void setTextureCoordSet(uint8 set); |
546 | | |
547 | | /// Enables Unordered Access to the provided mipLevel of the texture |
548 | 0 | void setUnorderedAccessMipLevel(int mipLevel) { mUnorderedAccessMipLevel = mipLevel; } |
549 | 0 | int getUnorderedAccessMipLevel() const { return mUnorderedAccessMipLevel; } |
550 | | |
551 | | /// @name Texture coordinate transformation |
552 | | /// @{ |
553 | | /** Sets a matrix used to transform any texture coordinates on this layer. |
554 | | |
555 | | Texture coordinates can be modified on a texture layer to create effects like scrolling |
556 | | textures. A texture transform can either be applied to a layer which takes the source coordinates |
557 | | from a fixed set in the geometry, or to one which generates them dynamically (e.g. environment mapping). |
558 | | |
559 | | It's obviously a bit impractical to create scrolling effects by calling this method manually since you |
560 | | would have to call it every frame with a slight alteration each time, which is tedious. Instead |
561 | | you can use setTransformAnimation which will manage the |
562 | | effect over time for you. |
563 | | |
564 | | In addition, if you can et the individual texture transformations rather than concatenating them |
565 | | yourself. |
566 | | |
567 | | @see Ogre::TextureUnitState::setTextureScroll |
568 | | @see Ogre::TextureUnitState::setTextureScale |
569 | | @see Ogre::TextureUnitState::setTextureRotate |
570 | | */ |
571 | | void setTextureTransform(const Matrix4& xform); |
572 | | |
573 | | /** Gets the current texture transformation matrix. |
574 | | |
575 | | Causes a reclaculation of the matrix if any parameters have been changed via |
576 | | setTextureScroll, setTextureScale and setTextureRotate. |
577 | | */ |
578 | | const Matrix4& getTextureTransform(void) const; |
579 | | |
580 | | /** Sets the translation offset of the texture, ie scrolls the texture. |
581 | | |
582 | | This method sets the translation element of the texture transformation, and is easier to |
583 | | use than setTextureTransform if you are combining translation, scaling and rotation in your |
584 | | texture transformation. |
585 | | If you want to animate these values use Ogre::TextureUnitState::setScrollAnimation |
586 | | @param u |
587 | | The amount the texture should be moved horizontally (u direction). |
588 | | @param v |
589 | | The amount the texture should be moved vertically (v direction). |
590 | | */ |
591 | | void setTextureScroll(float u, float v); |
592 | | |
593 | | /** As setTextureScroll, but sets only U value. |
594 | | */ |
595 | | void setTextureUScroll(float value); |
596 | | /// Get texture uscroll value. |
597 | | float getTextureUScroll(void) const; |
598 | | |
599 | | /** As setTextureScroll, but sets only V value. |
600 | | */ |
601 | | void setTextureVScroll(float value); |
602 | | /// Get texture vscroll value. |
603 | | float getTextureVScroll(void) const; |
604 | | |
605 | | /** As setTextureScale, but sets only U value. |
606 | | */ |
607 | | void setTextureUScale(float value); |
608 | | /// Get texture uscale value. |
609 | | float getTextureUScale(void) const; |
610 | | |
611 | | /** As setTextureScale, but sets only V value. |
612 | | */ |
613 | | void setTextureVScale(float value); |
614 | | /// Get texture vscale value. |
615 | | float getTextureVScale(void) const; |
616 | | |
617 | | /** Sets the scaling factor applied to texture coordinates. |
618 | | |
619 | | This method sets the scale element of the texture transformation, and is easier to use than |
620 | | setTextureTransform if you are combining translation, scaling and rotation in your texture transformation. |
621 | | |
622 | | If you want to animate these values use Ogre::TextureUnitState::setTransformAnimation |
623 | | @param uScale |
624 | | The value by which the texture is to be scaled horizontally. |
625 | | @param vScale |
626 | | The value by which the texture is to be scaled vertically. |
627 | | */ |
628 | | void setTextureScale(float uScale, float vScale); |
629 | | |
630 | | /** Sets the anticlockwise rotation factor applied to texture coordinates. |
631 | | |
632 | | This sets a fixed rotation angle - if you wish to animate this, use Ogre::TextureUnitState::setRotateAnimation |
633 | | @param angle |
634 | | The angle of rotation (anticlockwise). |
635 | | */ |
636 | | void setTextureRotate(const Radian& angle); |
637 | | /// Get texture rotation effects angle value. |
638 | | const Radian& getTextureRotate(void) const; |
639 | | /// @} |
640 | | |
641 | | /// get the associated sampler |
642 | 0 | const SamplerPtr& getSampler() const { return mSampler; } |
643 | | void setSampler(const SamplerPtr& sampler) |
644 | 0 | { |
645 | 0 | OgreAssert(sampler, "sampler must not be NULL"); |
646 | 0 | mSampler = sampler; |
647 | 0 | } |
648 | | |
649 | | /// @copydoc Sampler::setAddressingMode |
650 | | const Sampler::UVWAddressingMode& getTextureAddressingMode(void) const |
651 | 0 | { |
652 | 0 | return mSampler->getAddressingMode(); |
653 | 0 | } |
654 | | /// @copydoc Sampler::setAddressingMode |
655 | 0 | void setTextureAddressingMode( Ogre::TextureAddressingMode tam) { _getLocalSampler()->setAddressingMode(tam); } |
656 | | /// @copydoc Sampler::setAddressingMode |
657 | | void setTextureAddressingMode(Ogre::TextureAddressingMode u, Ogre::TextureAddressingMode v, |
658 | | Ogre::TextureAddressingMode w) |
659 | 0 | { |
660 | 0 | _getLocalSampler()->setAddressingMode(u, v, w); |
661 | 0 | } |
662 | | /// @copydoc Sampler::setAddressingMode |
663 | 0 | void setTextureAddressingMode( const Sampler::UVWAddressingMode& uvw) { _getLocalSampler()->setAddressingMode(uvw); } |
664 | | /// @copydoc Sampler::setBorderColour |
665 | 0 | void setTextureBorderColour(const ColourValue& colour) { _getLocalSampler()->setBorderColour(colour); } |
666 | | /// @copydoc Sampler::getBorderColour |
667 | 0 | const ColourValue& getTextureBorderColour() const { return mSampler->getBorderColour(); } |
668 | | /// @copydoc Sampler::setFiltering(TextureFilterOptions) |
669 | | void setTextureFiltering(TextureFilterOptions filterType) |
670 | 0 | { |
671 | 0 | _getLocalSampler()->setFiltering(filterType); |
672 | 0 | } |
673 | | /// @copydoc Sampler::setFiltering(FilterType, FilterOptions) |
674 | | void setTextureFiltering(FilterType ftype, FilterOptions opts) |
675 | 0 | { |
676 | 0 | _getLocalSampler()->setFiltering(ftype, opts); |
677 | 0 | } |
678 | | /// @copydoc Sampler::setFiltering(FilterOptions, FilterOptions, FilterOptions) |
679 | | void setTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter) |
680 | 0 | { |
681 | 0 | _getLocalSampler()->setFiltering(minFilter, magFilter, mipFilter); |
682 | 0 | } |
683 | | /// @copydoc Sampler::getFiltering |
684 | 0 | FilterOptions getTextureFiltering(FilterType ftype) const { return mSampler->getFiltering(ftype); } |
685 | | /// @copydoc Sampler::setCompareEnabled |
686 | 0 | void setTextureCompareEnabled(bool enabled) { _getLocalSampler()->setCompareEnabled(enabled); } |
687 | | /// @copydoc Sampler::getCompareEnabled |
688 | 0 | bool getTextureCompareEnabled() const { return mSampler->getCompareEnabled(); } |
689 | | /// @copydoc Sampler::setCompareFunction |
690 | 0 | void setTextureCompareFunction(CompareFunction function) { _getLocalSampler()->setCompareFunction(function); } |
691 | | /// @copydoc Sampler::getCompareFunction |
692 | 0 | CompareFunction getTextureCompareFunction() const { return mSampler->getCompareFunction(); } |
693 | | /// @copydoc Sampler::setAnisotropy |
694 | 0 | void setTextureAnisotropy(unsigned int maxAniso) { _getLocalSampler()->setAnisotropy(maxAniso); } |
695 | | /// @copydoc Sampler::getAnisotropy |
696 | 0 | unsigned int getTextureAnisotropy() const { return mSampler->getAnisotropy(); } |
697 | | /// @copydoc Sampler::setMipmapBias |
698 | 0 | void setTextureMipmapBias(float bias) { _getLocalSampler()->setMipmapBias(bias); } |
699 | | /// @copydoc Sampler::getMipmapBias |
700 | 0 | float getTextureMipmapBias(void) const { return mSampler->getMipmapBias(); } |
701 | | |
702 | | |
703 | | /** Setting advanced blending options. |
704 | | |
705 | | This is an extended version of the Ogre::TextureUnitState::setColourOperation method which allows |
706 | | extremely detailed control over the blending applied between this and earlier layers. |
707 | | See the Warning below about the issues between mulitpass and multitexturing that |
708 | | using this method can create. |
709 | | |
710 | | Texture colour operations determine how the final colour of the surface appears when |
711 | | rendered. Texture units are used to combine colour values from various sources (ie. the |
712 | | diffuse colour of the surface from lighting calculations, combined with the colour of |
713 | | the texture). This method allows you to specify the 'operation' to be used, ie. the |
714 | | calculation such as adds or multiplies, and which values to use as arguments, such as |
715 | | a fixed value or a value from a previous calculation. |
716 | | |
717 | | The defaults for each layer are: |
718 | | - op = Ogre::LBX_MODULATE |
719 | | - source1 = Ogre::LBS_TEXTURE |
720 | | - source2 = Ogre::LBS_CURRENT |
721 | | |
722 | | ie. each layer takes the colour results of the previous layer, and multiplies them |
723 | | with the new texture being applied. Bear in mind that colours are RGB values from |
724 | | 0.0 - 1.0 so multiplying them together will result in values in the same range, |
725 | | 'tinted' by the multiply. Note however that a straight multiply normally has the |
726 | | effect of darkening the textures - for this reason there are brightening operations |
727 | | like Ogre::LBX_MODULATE_X2. See the Ogre::LayerBlendOperation and Ogre::LayerBlendSource enumerated |
728 | | types for full details. |
729 | | |
730 | | The final 3 parameters are only required if you decide to pass values manually |
731 | | into the operation, i.e. you want one or more of the inputs to the colour calculation |
732 | | to come from a fixed value that you supply. Hence you only need to fill these in if |
733 | | you supply Ogre::LBS_MANUAL to the corresponding source, or use the Ogre::LBX_BLEND_MANUAL |
734 | | operation. |
735 | | @warning |
736 | | Ogre tries to use multitexturing hardware to blend texture layers |
737 | | together. However, if it runs out of texturing units (e.g. 2 of a GeForce2, 4 on a |
738 | | GeForce3) it has to fall back on multipass rendering, i.e. rendering the same object |
739 | | multiple times with different textures. This is both less efficient and there is a smaller |
740 | | range of blending operations which can be performed. For this reason, if you use this method |
741 | | you MUST also call Ogre::TextureUnitState::setColourOpMultipassFallback to specify which effect you |
742 | | want to fall back on if sufficient hardware is not available. |
743 | | @warning |
744 | | If you wish to avoid having to do this, use the simpler Ogre::TextureUnitState::setColourOperation method |
745 | | which allows less flexible blending options but sets up the multipass fallback automatically, |
746 | | since it only allows operations which have direct multipass equivalents. |
747 | | @param op |
748 | | The operation to be used, e.g. modulate (multiply), add, subtract. |
749 | | @param source1 |
750 | | The source of the first colour to the operation e.g. texture colour. |
751 | | @param source2 |
752 | | The source of the second colour to the operation e.g. current surface colour. |
753 | | @param arg1 |
754 | | Manually supplied colour value (only required if source1 = LBS_MANUAL). |
755 | | @param arg2 |
756 | | Manually supplied colour value (only required if source2 = LBS_MANUAL). |
757 | | @param manualBlend |
758 | | Manually supplied 'blend' value - only required for operations |
759 | | which require manual blend e.g. LBX_BLEND_MANUAL. |
760 | | */ |
761 | | void setColourOperationEx( |
762 | | LayerBlendOperationEx op, |
763 | | LayerBlendSource source1 = LBS_TEXTURE, |
764 | | LayerBlendSource source2 = LBS_CURRENT, |
765 | | |
766 | | const ColourValue& arg1 = ColourValue::White, |
767 | | const ColourValue& arg2 = ColourValue::White, |
768 | | |
769 | | Real manualBlend = 0.0); |
770 | | |
771 | | /** Determines how this texture layer is combined with the one below it (or the diffuse colour of |
772 | | the geometry if this is layer 0). |
773 | | |
774 | | This method is the simplest way to blend texture layers, because it requires only one parameter, |
775 | | gives you the most common blending types, and automatically sets up 2 blending methods: one for |
776 | | if single-pass multitexturing hardware is available, and another for if it is not and the blending must |
777 | | be achieved through multiple rendering passes. It is, however, quite limited and does not expose |
778 | | the more flexible multitexturing operations, simply because these can't be automatically supported in |
779 | | multipass fallback mode. If want to use the fancier options, use Ogre::TextureUnitState::setColourOperationEx, |
780 | | but you'll either have to be sure that enough multitexturing units will be available, or you should |
781 | | explicitly set a fallback using Ogre::TextureUnitState::setColourOpMultipassFallback. |
782 | | @note |
783 | | The default method is Ogre::LBO_MODULATE for all layers. |
784 | | @param op |
785 | | One of the Ogre::LayerBlendOperation enumerated blending types. |
786 | | */ |
787 | | void setColourOperation( const LayerBlendOperation op); |
788 | | |
789 | | /** Sets the multipass fallback operation for this layer, if you used TextureUnitState::setColourOperationEx |
790 | | and not enough multitexturing hardware is available. |
791 | | |
792 | | Because some effects exposed using Ogre::TextureUnitState::setColourOperationEx are only supported under |
793 | | multitexturing hardware, if the hardware is lacking the system must fallback on multipass rendering, |
794 | | which unfortunately doesn't support as many effects. This method is for you to specify the fallback |
795 | | operation which most suits you. |
796 | | |
797 | | You'll notice that the interface is the same as the Ogre::TMaterial::setSceneBlending method; this is |
798 | | because multipass rendering IS effectively scene blending, since each layer is rendered on top |
799 | | of the last using the same mechanism as making an object transparent, it's just being rendered |
800 | | in the same place repeatedly to get the multitexture effect. |
801 | | |
802 | | If you use the simpler (and hence less flexible) Ogre::TextureUnitState::setColourOperation method you |
803 | | don't need to call this as the system sets up the fallback for you. |
804 | | @note |
805 | | This option has no effect in the programmable pipeline, because there is no multipass fallback |
806 | | and multitexture blending is handled by the fragment shader. |
807 | | */ |
808 | | void setColourOpMultipassFallback( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); |
809 | | |
810 | | /** Get multitexturing colour blending mode. |
811 | | */ |
812 | | const LayerBlendModeEx& getColourBlendMode(void) const; |
813 | | |
814 | | /** Get multitexturing alpha blending mode. |
815 | | */ |
816 | | const LayerBlendModeEx& getAlphaBlendMode(void) const; |
817 | | |
818 | | /** Get the multipass fallback for colour blending operation source factor. |
819 | | */ |
820 | | SceneBlendFactor getColourBlendFallbackSrc(void) const; |
821 | | |
822 | | /** Get the multipass fallback for colour blending operation destination factor. |
823 | | */ |
824 | | SceneBlendFactor getColourBlendFallbackDest(void) const; |
825 | | |
826 | | /** Sets the alpha operation to be applied to this texture. |
827 | | |
828 | | This works in exactly the same way as setColourOperationEx, except |
829 | | that the effect is applied to the level of alpha (i.e. transparency) |
830 | | of the texture rather than its colour. When the alpha of a texel (a pixel |
831 | | on a texture) is 1.0, it is opaque, whereas it is fully transparent if the |
832 | | alpha is 0.0. Please refer to the Ogre::TextureUnitState::setColourOperationEx method for more info. |
833 | | @param op |
834 | | The operation to be used, e.g. modulate (multiply), add, subtract |
835 | | @param source1 |
836 | | The source of the first alpha value to the operation e.g. texture alpha |
837 | | @param source2 |
838 | | The source of the second alpha value to the operation e.g. current surface alpha |
839 | | @param arg1 |
840 | | Manually supplied alpha value (only required if source1 = Ogre::LBS_MANUAL) |
841 | | @param arg2 |
842 | | Manually supplied alpha value (only required if source2 = Ogre::LBS_MANUAL) |
843 | | @param manualBlend |
844 | | Manually supplied 'blend' value - only required for operations |
845 | | which require manual blend e.g. Ogre::LBX_BLEND_MANUAL |
846 | | */ |
847 | | void setAlphaOperation(LayerBlendOperationEx op, |
848 | | LayerBlendSource source1 = LBS_TEXTURE, |
849 | | LayerBlendSource source2 = LBS_CURRENT, |
850 | | Real arg1 = 1.0, |
851 | | Real arg2 = 1.0, |
852 | | Real manualBlend = 0.0); |
853 | | |
854 | | /// @name Dynamic texture coordinate generation |
855 | | /// @{ |
856 | | /** Generic method for setting up texture effects. |
857 | | |
858 | | Allows you to specify effects directly by using the #TextureEffectType enumeration. The |
859 | | arguments that go with it depend on the effect type. Only one effect of |
860 | | each type can be applied to a texture layer. |
861 | | @par |
862 | | This method is used internally by Ogre but it is better generally for applications to use the |
863 | | more intuitive specialised methods such as #setEnvironmentMap and #setTextureScroll. |
864 | | */ |
865 | | void addEffect(TextureEffect effect); |
866 | | |
867 | | /** Turns on/off texture coordinate generation for addressing an environment map. |
868 | | |
869 | | Environment maps make an object look reflective by using the object's vertex normals relative |
870 | | to the camera view to generate texture coordinates. |
871 | | |
872 | | The vectors generated can either be used to address a single 2D texture which |
873 | | is a 'fish-eye' lens view of a scene, or a 3D cubic environment map which requires 6 textures |
874 | | for each side of the inside of a cube. |
875 | | |
876 | | This effect works best if the object has lots of gradually changing normals. The texture also |
877 | | has to be designed for this effect - see the example @c spheremap.png included with the sample |
878 | | application for a 2D environment map; a cubic map can be generated by rendering 6 views of a |
879 | | scene to each of the cube faces with orthogonal views. |
880 | | |
881 | | Enabling this disables any other texture coordinate generation effects. |
882 | | However it can be combined with texture coordinate modification functions, which then operate on the |
883 | | generated coordinates rather than static model texture coordinates. |
884 | | @param enable |
885 | | True to enable, false to disable |
886 | | @param texGenType texture coordinate generation type |
887 | | */ |
888 | | void setEnvironmentMap(bool enable, int texGenType = TEXCALC_ENVIRONMENT_MAP); |
889 | | |
890 | | /** Sets up an animated scroll for the texture layer. |
891 | | |
892 | | Useful for creating constant scrolling effects on a texture layer (for varying scrolls, see Ogre::TextureUnitState::setTransformAnimation). |
893 | | @param uSpeed |
894 | | The number of horizontal loops per second (+ve=moving right, -ve = moving left). |
895 | | @param vSpeed |
896 | | The number of vertical loops per second (+ve=moving up, -ve= moving down). |
897 | | */ |
898 | | void setScrollAnimation(float uSpeed, float vSpeed); |
899 | | |
900 | | /** Sets up an animated texture rotation for this layer. |
901 | | |
902 | | Useful for constant rotations (for varying rotations, see Ogre::TextureUnitState::setTransformAnimation). |
903 | | @param speed |
904 | | The number of complete anticlockwise revolutions per second (use -ve for clockwise) |
905 | | */ |
906 | | void setRotateAnimation(float speed); |
907 | | |
908 | | /** Sets up a general time-relative texture modification effect. |
909 | | |
910 | | This can be called multiple times for different values of ttype, but only the latest effect |
911 | | applies if called multiple time for the same ttype. |
912 | | @param ttype |
913 | | The type of transform, either translate (scroll), scale (stretch) or rotate (spin). |
914 | | @param waveType |
915 | | The shape of the wave, see Ogre::WaveformType enum for details. |
916 | | @param base |
917 | | The base value for the function (range of output = {base, base + amplitude}). |
918 | | @param frequency |
919 | | The speed of the wave in cycles per second. |
920 | | @param phase |
921 | | The offset of the start of the wave, e.g. 0.5 to start half-way through the wave. |
922 | | @param amplitude |
923 | | Scales the output so that instead of lying within 0..1 it lies within 0..1*amplitude for exaggerated effects. |
924 | | */ |
925 | | void setTransformAnimation( const TextureTransformType ttype, |
926 | | const WaveformType waveType, float base = 0, float frequency = 1, float phase = 0, float amplitude = 1 ); |
927 | | |
928 | | |
929 | | /** Enables or disables projective texturing on this texture unit. |
930 | | |
931 | | Projective texturing allows you to generate texture coordinates |
932 | | based on a Frustum, which gives the impression that a texture is |
933 | | being projected onto the surface. Note that once you have called |
934 | | this method, the texture unit continues to monitor the Frustum you |
935 | | passed in and the projection will change if you can alter it. It also |
936 | | means that you must ensure that the Frustum object you pass a pointer |
937 | | to remains in existence for as long as this TextureUnitState does. |
938 | | @par |
939 | | This effect cannot be combined with other texture generation effects, |
940 | | such as environment mapping. It also has no effect on passes which |
941 | | have a vertex program enabled - projective texturing has to be done |
942 | | in the vertex program instead. |
943 | | @param enabled |
944 | | Whether to enable / disable. |
945 | | @param projectionSettings |
946 | | The Frustum which will be used to derive the |
947 | | projection parameters. |
948 | | */ |
949 | | void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0); |
950 | | |
951 | | /** Gets the Frustum which is being used to derive projective texturing parameters. |
952 | | */ |
953 | | const Frustum* getProjectiveTexturingFrustum(void) const; |
954 | | |
955 | | /** Removes all effects applied to this texture layer. |
956 | | */ |
957 | | void removeAllEffects(void); |
958 | | |
959 | | /** Removes a single effect applied to this texture layer. |
960 | | @note |
961 | | Because you can only have 1 effect of each type (e.g. 1 texture coordinate generation) applied |
962 | | to a layer, only the effect type is required. |
963 | | */ |
964 | | void removeEffect( const TextureEffectType type ); |
965 | | |
966 | | /// Get texture effects in a multimap paired array. |
967 | | const EffectMap& getEffects(void) const; |
968 | | /// @} |
969 | | |
970 | | /** Determines if this texture layer is currently blank. |
971 | | @note |
972 | | This can happen if a texture fails to load or some other non-fatal error. Worth checking after |
973 | | setting texture name. |
974 | | */ |
975 | | bool isBlank(void) const; |
976 | | |
977 | | /** Sets this texture layer to be blank. |
978 | | */ |
979 | | void setBlank(void); |
980 | | |
981 | | /** Tests if the texture associated with this unit has failed to load. |
982 | | */ |
983 | 0 | bool isTextureLoadFailing() const { return mTextureLoadFailed; } |
984 | | |
985 | | /** Tells the unit to retry loading the texture if it had failed to load. |
986 | | */ |
987 | 0 | void retryTextureLoad() { mTextureLoadFailed = false; } |
988 | | |
989 | | /// Get the animated-texture animation duration. |
990 | | Real getAnimationDuration(void) const; |
991 | | |
992 | | /// Returns true if this texture unit is using the default Sampler |
993 | | bool isDefaultFiltering() const; |
994 | | |
995 | | /** Set the compositor reference for this texture unit state. |
996 | | |
997 | | Only valid when content type is compositor. |
998 | | @param compositorName |
999 | | The name of the compositor to reference. |
1000 | | @param textureName |
1001 | | The name of the texture to reference. |
1002 | | @param mrtIndex |
1003 | | The index of the wanted texture, if referencing an MRT. |
1004 | | */ |
1005 | | void setCompositorReference(const String& compositorName, const String& textureName, uint32 mrtIndex = 0); |
1006 | | |
1007 | | /** Gets the name of the compositor that this texture references. */ |
1008 | 0 | const String& getReferencedCompositorName() const { return mCompositorRefName; } |
1009 | | /** Gets the name of the texture in the compositor that this texture references. */ |
1010 | 0 | const String& getReferencedTextureName() const { return mCompositorRefTexName; } |
1011 | | /** Gets the MRT index of the texture in the compositor that this texture references. */ |
1012 | 0 | uint32 getReferencedMRTIndex() const { return mCompositorRefMrtIndex; } |
1013 | | |
1014 | | /// Gets the parent Pass object. |
1015 | 0 | Pass* getParent(void) const { return mParent; } |
1016 | | |
1017 | | /** Internal method for preparing this object for load, as part of Material::prepare. */ |
1018 | | void _prepare(void); |
1019 | | /** Internal method for undoing the preparation this object as part of Material::unprepare. */ |
1020 | | void _unprepare(void); |
1021 | | /** Internal method for loading this object as part of Material::load. */ |
1022 | | void _load(void); |
1023 | | /** Internal method for unloading this object as part of Material::unload. */ |
1024 | | void _unload(void); |
1025 | | |
1026 | | /// Is this loaded? |
1027 | | bool isLoaded(void) const; |
1028 | | /** Tells the class that it needs recompilation. */ |
1029 | | void _notifyNeedsRecompile(void); |
1030 | | |
1031 | | /** Set the name of the Texture Unit State. |
1032 | | |
1033 | | The name of the Texture Unit State is optional. Its useful in material scripts where a material could inherit |
1034 | | from another material and only want to modify a particular Texture Unit State. |
1035 | | */ |
1036 | | void setName(const String& name); |
1037 | | /// Get the name of the Texture Unit State. |
1038 | 0 | const String& getName(void) const { return mName; } |
1039 | | |
1040 | | /// @deprecated use setName() |
1041 | 0 | OGRE_DEPRECATED void setTextureNameAlias(const String& name) { setName(name); } |
1042 | | /// @deprecated use getName() |
1043 | 0 | OGRE_DEPRECATED const String& getTextureNameAlias(void) const { return getName();} |
1044 | | |
1045 | | /** Notify this object that its parent has changed. */ |
1046 | | void _notifyParent(Pass* parent); |
1047 | | |
1048 | | /** Get the texture pointer for the current frame. */ |
1049 | | const TexturePtr& _getTexturePtr(void) const; |
1050 | | /** Get the texture pointer for a given frame. */ |
1051 | | const TexturePtr& _getTexturePtr(size_t frame) const; |
1052 | | |
1053 | | /** Set the texture pointer for the current frame (internal use only!). */ |
1054 | | void _setTexturePtr(const TexturePtr& texptr); |
1055 | | /** Set the texture pointer for a given frame (internal use only!). */ |
1056 | | void _setTexturePtr(const TexturePtr& texptr, size_t frame); |
1057 | | |
1058 | | size_t calculateSize(void) const; |
1059 | | |
1060 | | /** Gets the animation controller (as created because of setAnimatedTexture) |
1061 | | if it exists. |
1062 | | */ |
1063 | 0 | ControllerFloat* _getAnimController() const { return mAnimController; } |
1064 | | |
1065 | | /// return a sampler local to this TUS instead of the shared global one |
1066 | | const SamplerPtr& _getLocalSampler(); |
1067 | | |
1068 | | TexCoordCalcMethod _deriveTexCoordCalcMethod() const; |
1069 | | private: |
1070 | | // State |
1071 | | /// The current animation frame. |
1072 | | unsigned int mCurrentFrame; |
1073 | | |
1074 | | /// Duration of animation in seconds. |
1075 | | Real mAnimDuration; |
1076 | | |
1077 | | int mUnorderedAccessMipLevel; |
1078 | | |
1079 | | LayerBlendModeEx mColourBlendMode; |
1080 | | SceneBlendFactor mColourBlendFallbackSrc; |
1081 | | SceneBlendFactor mColourBlendFallbackDest; |
1082 | | |
1083 | | LayerBlendModeEx mAlphaBlendMode; |
1084 | | Real mGamma; |
1085 | | float mUMod, mVMod; |
1086 | | float mUScale, mVScale; |
1087 | | Radian mRotate; |
1088 | | mutable Matrix4 mTexModMatrix; |
1089 | | |
1090 | | /// Content type of texture (normal loaded texture, auto-texture). |
1091 | | ContentType mContentType; |
1092 | | |
1093 | | mutable bool mTextureLoadFailed; |
1094 | | mutable bool mRecalcTexMatrix; |
1095 | | |
1096 | | uint8 mTextureCoordSetIndex; |
1097 | | |
1098 | | /// The index of the referenced texture if referencing an MRT in a compositor. |
1099 | | uint32 mCompositorRefMrtIndex; |
1100 | | |
1101 | | //----------------------------------------------------------------------------- |
1102 | | // Complex members (those that can't be copied using memcpy) are at the end to |
1103 | | // allow for fast copying of the basic members. |
1104 | | // |
1105 | | mutable std::vector<TexturePtr> mFramePtrs; // must at least contain a single nullptr |
1106 | | SamplerPtr mSampler; |
1107 | | String mName; ///< Optional name for the TUS. |
1108 | | EffectMap mEffects; |
1109 | | /// The data that references the compositor. |
1110 | | String mCompositorRefName; |
1111 | | String mCompositorRefTexName; |
1112 | | //----------------------------------------------------------------------------- |
1113 | | |
1114 | | //----------------------------------------------------------------------------- |
1115 | | // Pointer members (those that can't be copied using memcpy), and MUST |
1116 | | // preserving even if assign from others |
1117 | | // |
1118 | | Pass* mParent; |
1119 | | ControllerFloat* mAnimController; |
1120 | | //----------------------------------------------------------------------------- |
1121 | | |
1122 | | |
1123 | | /** Internal method for calculating texture matrix. |
1124 | | */ |
1125 | | void recalcTextureMatrix(void) const; |
1126 | | |
1127 | | /** Internal method for creating animation controller. |
1128 | | */ |
1129 | | void createAnimController(void); |
1130 | | |
1131 | | /** Internal method for creating texture effect controller. |
1132 | | */ |
1133 | | void createEffectController(TextureEffect& effect); |
1134 | | |
1135 | | /** Internal method for ensuring the texture for a given frame is prepared. */ |
1136 | | void ensurePrepared(size_t frame) const; |
1137 | | /** Internal method for ensuring the texture for a given frame is loaded. */ |
1138 | | void ensureLoaded(size_t frame) const; |
1139 | | |
1140 | | TexturePtr retrieveTexture(const String& name); |
1141 | | |
1142 | | bool checkTexCalcSettings(const TexturePtr& tex) const; |
1143 | | }; |
1144 | | |
1145 | | /** @} */ |
1146 | | /** @} */ |
1147 | | |
1148 | | } // namespace Ogre |
1149 | | |
1150 | | #include "OgreHeaderSuffix.h" |
1151 | | |
1152 | | #endif // __TextureUnitState_H__ |