#import <CC3Texture.h>
CC3TextureUnitTexture is a specialized CC3Texture subclass that actually wraps another texture instance and combines it with an instance of a texture unit to define additional environmental configuration information about the use of the texture in multi-texturing under fixed-pipeline rendering used by OpenGL ES 1.1 on iOS, or OpenGL on OSX without shaders.
This class is generally not used for multi-texturing under programmable-pipeline rendering used by OpenGL ES 2.0 on, or OpenGL on OSX with shaders, as you will generally handle multitexturing in the shader code. However, it is possible to use an instance of this class with a programmable-pipeline shader if your shader is designed to make use of the texture unit configuration content. This can be used as a mechanism for supporting the same multi-texturing configuration between both fixed and programmable pipelines.
You instantiate an instance of CC3TextureUnitTexture directly, using any of the instance creation or initializaton methods defined by the CC3Texture superclass. Or, if you already have an instance of a CC3Texture, you can wrap it in an instance of CC3TextureUnitTexture by using the textureWithTexture: or initWithTexture: creation and initialization methods of this class.
You can then create an instance of CC3TextureUnit, configure it appropriately, and set it into the textureUnit property of your CC3TextureUnitTexture instance. By adding multiple CC3TextureUnitTexture instances to your CC3Material, you can combine textures creatively.
For example, to configure a material for bump-mapping, add a texture that contains a normal vector at each pixel instead of a color, and set the textureUnit property of the texture to a CC3BumpMapTextureUnit. Then add another texture, containing the image that will be visible, to the material. The material will combine these two textures, as specified by the CC3TextureUnit held by the second texture.
- (id) initWithTexture: | (CC3Texture *) | texture |
Initializes this instance on the specified underlying texture.
The name property of this instance will set to that of the specified texture.
+ (id) textureWithTexture: | (CC3Texture *) | texture |
Allocates and initializes an autoreleased instance on the specified underlying texture.
The name property of this instance will set to that of the specified texture.
|
readnonatomicretain |
The CC3Texture texture being managed by this instance.
This property is populated automatically during instance creation and loading.
|
readwritenonatomicretain |
The texture environment settings that are applied to the texture unit that draws this texture, when this texture participates in multi-texturing under fixed-pipeline rendering.
The texture unit is optional, and this propety may be left as nil to provide standard single texture rendering. The default value of this property is nil.
The texture unit can be used to configure how the texture will be combined with other textures when using multi-texturing. When the material supports multiple textures, each texture should contain a texture unit that describes how the GL engine should combine that texture with the textures that have already been applied.
Different subclasses of CC3TextureUnit provide different customizations for combining textures. The CC3BumpMapTextureUnit provides easy settings for DOT3 bump-mapping, and CC3ConfigurableTextureUnit provides complete flexibility in setting texture environment settings.