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