CC3EnvironmentMapTexture Class Reference
Inherits from | CC3TextureCube : CC3Texture : CC3Identifiable : NSObject |
Declared in | CC3RenderSurfaces.h |
Overview
A texture that supports an environment map created by rendering the scene from the node’s perspective in all six axis directions.
You can use this texture in any model object, wherever you use any cube-map texture. The generateSnapshotOfScene:fromGlobalLocation: method is used to capture the scene images to this texture. You can trigger this as often as you need, to keep the image current with the scene contents.
Tasks
-
numberOfFacesPerSnapshot
property -
– generateSnapshotOfScene:fromGlobalLocation:
-
renderSurface
property -
– initCubeWithSideLength:
-
+ textureCubeWithSideLength:
-
– initCubeWithSideLength:withDepthFormat:
-
+ textureCubeWithSideLength:withDepthFormat:
-
– initCubeWithSideLength:withDepthAttachment:
-
+ textureCubeWithSideLength:withDepthAttachment:
-
– initCubeWithSideLength:withColorPixelFormat:withColorPixelType:withDepthAttachment:
-
+ textureCubeWithSideLength:withColorPixelFormat:withColorPixelType:withDepthAttachment:
-
– initCubeWithDepthAttachment:
-
+ textureCubeWithDepthAttachment:
-
– initCubeWithColorPixelFormat:andColorPixelType:andDepthAttachment:
-
+ textureCubeWithColorPixelFormat:andColorPixelType:andDepthAttachment:
Properties
numberOfFacesPerSnapshot
Indicates the number of faces of the cube-map that will be generated on each invocation of the generateSnapshotOfScene:fromGlobalLocation:withVisitor: method.
@property (nonatomic, assign) GLfloat numberOfFacesPerSnapshot
Discussion
Generating each face in the cube-map requires rendering the scene from the perspective of a camera facing towards that face, and generating a full cube-map requires six separate scene renderings. Depending on the complexity of the scene, this can be quite costly.
However, in most situations, an environment map does not require high-fideility, and the workload can be spread over time by not generating all of the cube-map faces on every snapshot.
You can use this property to control the number of cube-map faces that will be generated each time a snapshot is taken using the generateSnapshotOfScene:fromGlobalLocation:withVisitor: method.
The maximum value of this property is 6, indicating that all six faces should be generated each time the generateSnapshotOfScene:fromGlobalLocation:withVisitor: method is invoked. Setting this property to a smaller value will cause fewer faces to be generated on each snapshot, thereby spreading the workload out over time. On each invocation, a different set of faces will be generated, in a cycle, ensuring that each face will be generated at some point.
As an example, setting this value to 2 will cause only 2 of the 6 faces of the cube-map to be generated each time the generateSnapshotOfScene:fromGlobalLocation:withVisitor: is invoked. Therefore, it would take 3 snapshot invocations to generate all 6 sides of the cube-map.
You can even set this property to a fractional value less than one to spread the updating of the faces out even further. For example, if the value of this property is set to 0.25, the generateSnapshotOfScene:fromGlobalLocation:withVisitor: method will only generate one face of this cube-map texture every fourth time it is invoked. On the other three invocations, the generateSnapshotOfScene:fromGlobalLocation:withVisitor: method will do nothing. Therefore, with the value of this property set to 0.25, it would take 24 snapshot invocations to generate all 6 sides of this cube-map.
The initial value of this property is 1, indicating that one face of the cube-map will be generated on each invocation of the generateSnapshotOfScene:fromGlobalLocation:withVisitor: method. With this value, it will take six invocations to generate all six sides of the cube-map.
Declared In
CC3RenderSurfaces.h
Class Methods
textureCubeWithColorPixelFormat:andColorPixelType:andDepthAttachment:
@deprecated Use textureCubeWithSideLength:withColorPixelFormat:withColorPixelType:withDepthAttachment: instead.
+ (instancetype)textureCubeWithColorPixelFormat:(GLenum)colorFormat andColorPixelType:(GLenum)colorType andDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Declared In
CC3RenderSurfaces.h
textureCubeWithDepthAttachment:
@deprecated Use textureCubeWithSideLength:withDepthAttachment: instead.
+ (instancetype)textureCubeWithDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Declared In
CC3RenderSurfaces.h
textureCubeWithSideLength:
Allocates and initializes an autoreleased instance with the specified side length, with the standard GL_RGBA/GL_UNSIGNED_BYTE pixelFormat/pixelType, and backed by a new depth buffer with the standard GL_DEPTH_COMPONENT16 depth format.
+ (instancetype)textureCubeWithSideLength:(GLuint)sideLength
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The internal depth buffer is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth buffer for all such environment textures. In this case, consider using the textureCubeWithSideLength:WithDepthAttachment: method instead.
Declared In
CC3RenderSurfaces.h
textureCubeWithSideLength:withColorPixelFormat:withColorPixelType:withDepthAttachment:
Allocates and initializes an autoreleased instance with the specified side length, with the specified pixel format and type, and backed by the specified depth attachment.
+ (instancetype)textureCubeWithSideLength:(GLuint)sideLength withColorPixelFormat:(GLenum)colorFormat withColorPixelType:(GLenum)colorType withDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The depthAttachment argument must not be nil.
Be aware that the possible combinations of color and depth pixel formats is quite limited with cube-mapped framebuffer attachments. If you have trouble finding a suitable combination, you can use the initWithDepthAttachment: method, which invokes this method with GL_RGBA as the colorFormat and GL_UNSIGNED_BYTE as the colorType.
The depth attachment is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth attachment for all such environment textures.
Declared In
CC3RenderSurfaces.h
textureCubeWithSideLength:withDepthAttachment:
Allocates and initializes an autoreleased instance with the specified side length, with the standard GL_RGBA/GL_UNSIGNED_BYTE pixelFormat/pixelType, and backed by the specified depth attachment.
+ (instancetype)textureCubeWithSideLength:(GLuint)sideLength withDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The depthAttachment argument must not be nil.
The depth attachment is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth attachment for all such environment textures.
Declared In
CC3RenderSurfaces.h
textureCubeWithSideLength:withDepthFormat:
Allocates and initializes an autoreleased instance with the specified side length, with the standard GL_RGBA/GL_UNSIGNED_BYTE pixelFormat/pixelType, and backed by a new depth buffer of the specified depth format.
+ (instancetype)textureCubeWithSideLength:(GLuint)sideLength withDepthFormat:(GLenum)depthFormat
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The depthFormat argument may be one of the following values: – GL_DEPTH_COMPONENT16 – GL_DEPTH_COMPONENT24 – GL_DEPTH24_STENCIL8
The internal depth buffer is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth buffer for all such environment textures. In this case, consider using the textureCubeWithSideLength:WithDepthAttachment: method instead.
Declared In
CC3RenderSurfaces.h
Instance Methods
generateSnapshotOfScene:fromGlobalLocation:
Generates up to six faces of this cube-map, by creating a view of the specified scene, from the specified global location, once for each face of this cube-mapped texture.
- (void)generateSnapshotOfScene:(CC3Scene *)scene fromGlobalLocation:(CC3Vector)location
Discussion
The scene’s drawSceneContentForEnvironmentMapWithVisitor: method is invoked to render the scene as an environment map, using the visitor in the scene’s envMapDrawingVisitor property.
Typcally, you invoke this method on each frame rendering loop, and use the numberOfFacesPerSnapshot property to control how often the texture is updated.
Declared In
CC3RenderSurfaces.h
initCubeWithColorPixelFormat:andColorPixelType:andDepthAttachment:
@deprecated Use initCubeWithSideLength:withColorPixelFormat:withColorPixelType:withDepthAttachment: instead.
- (instancetype)initCubeWithColorPixelFormat:(GLenum)colorFormat andColorPixelType:(GLenum)colorType andDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Declared In
CC3RenderSurfaces.h
initCubeWithDepthAttachment:
@deprecated Use initCubeWithSideLength:withDepthAttachment: instead.
- (instancetype)initCubeWithDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Declared In
CC3RenderSurfaces.h
initCubeWithSideLength:
Initializes this instance with the specified side length, with the standard GL_RGBA/GL_UNSIGNED_BYTE pixelFormat/pixelType, and backed by a new depth buffer with the standard GL_DEPTH_COMPONENT16 depth format.
- (instancetype)initCubeWithSideLength:(GLuint)sideLength
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The internal depth buffer is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth buffer for all such environment textures. In this case, consider using the initCubeWithSideLength:WithDepthAttachment: method instead.
Declared In
CC3RenderSurfaces.h
initCubeWithSideLength:withColorPixelFormat:withColorPixelType:withDepthAttachment:
Initializes this instance with the specified side length, with the specified pixel format and type, and backed by the specified depth attachment.
- (instancetype)initCubeWithSideLength:(GLuint)sideLength withColorPixelFormat:(GLenum)colorFormat withColorPixelType:(GLenum)colorType withDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The depthAttachment argument must not be nil.
Be aware that the possible combinations of color and depth pixel formats is quite limited with cube-mapped framebuffer attachments. If you have trouble finding a suitable combination, you can use the initWithDepthAttachment: method, which invokes this method with GL_RGBA as the colorFormat and GL_UNSIGNED_BYTE as the colorType.
The depth attachment is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth attachment for all such environment textures.
Declared In
CC3RenderSurfaces.h
initCubeWithSideLength:withDepthAttachment:
Initializes this instance with the specified side length, with the standard GL_RGBA/GL_UNSIGNED_BYTE pixelFormat/pixelType, and backed by the specified depth attachment.
- (instancetype)initCubeWithSideLength:(GLuint)sideLength withDepthAttachment:(id<CC3FramebufferAttachment>)depthAttachment
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The depthAttachment argument must not be nil.
The depth attachment is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth attachment for all such environment textures.
Declared In
CC3RenderSurfaces.h
initCubeWithSideLength:withDepthFormat:
Initializes this instance with the specified side length, with the standard GL_RGBA/GL_UNSIGNED_BYTE pixelFormat/pixelType, and backed by a new depth buffer of the specified depth format.
- (instancetype)initCubeWithSideLength:(GLuint)sideLength withDepthFormat:(GLenum)depthFormat
Discussion
The sideLength argument indicates the length, in pixels, of each side of the texture.
The depthFormat argument may be one of the following values: – GL_DEPTH_COMPONENT16 – GL_DEPTH_COMPONENT24 – GL_DEPTH24_STENCIL8
The internal depth buffer is used only during the rendering of the environment to this texture. If you are creating many environmental textures of the same size, for different objects, you can save memory by using the same depth buffer for all such environment textures. In this case, consider using the initCubeWithSideLength:WithDepthAttachment: method instead.
Declared In
CC3RenderSurfaces.h