CubemapArray
Class for handling Cubemap arrays.
Read time 7 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Inherits from: Texture
public sealed class CubemapArray : Texture
Remarks
Modern graphics APIs, such as D3D10.1 and later, OpenGL 4.0 and later, and Metal on macOS support cubemap arrays, which are arrays of cubemaps with same size and format. From the shader side, they are treated as a single resource, and sampling them needs an extra coordinate that indicates which array element to sample from.
Typically cubemap arrays are useful for implementing efficient reflection probe, lighting and shadowing systems (all reflection/cookie/shadow cubemaps in a single array).
Cubemap arrays do not have an import pipeline for them, and must be created from code, either at runtime or in editor scripts. Using Graphics.CopyTexture is useful for fast copying of pixel data from regular Cubemap textures into elements of a cubemap array. From editor scripts, a common way of creating serialized cubemap array is to create it, fill with data (either via Graphics.CopyTexture from regular cubemaps, or via CubemapArray.SetPixels or CubemapArray.SetPixels32) and save it as an asset via AssetDatabase.CreateAsset.
Note that not all platforms and GPUs support cubemap arrays. Use SystemInfo.supportsCubemapArrayTextures to check. Also, this class does not support CubemapArray creation with a Crunch compression TextureFormat.
Constructors
Constructor | Description |
|---|---|
| CubemapArray(System.Int32,System.Int32,UnityEngine.Experimental.Rendering.GraphicsFormat,UnityEngine.Experimental.Rendering.TextureCreationFlags) | Create a new cubemap array. |
| CubemapArray(System.Int32,System.Int32,UnityEngine.TextureFormat,System.Boolean) | Create a new cubemap array. |
| CubemapArray(System.Int32,System.Int32,UnityEngine.TextureFormat,System.Boolean,System.Boolean,System.Boolean) | Create a new cubemap array. |
| CubemapArray(System.Int32,System.Int32,UnityEngine.TextureFormat,System.Int32,System.Boolean) | Create a new cubemap array. |
| CubemapArray(System.Int32,System.Int32,UnityEngine.TextureFormat,System.Int32,System.Boolean,System.Boolean) | Create a new cubemap array. |
Properties
Property | Description |
|---|---|
| cubemapCount | Number of cubemaps in the array (Read Only). |
| format | Texture format (Read Only). |
Methods
Method | Description |
|---|---|
| Apply | Copies changes you've made in a CPU texture to the GPU. |
| CopyPixels | Copies pixel data from another texture on the CPU. |
| GetPixelData | Gets the raw data from a texture. |
| GetPixels | Gets the pixel color data for a mipmap level of a face of a slice as Color structs. |
| GetPixels32 | Gets the pixel color data for a mipmap level of a face of a slice as Color32 structs. |
| SetPixelData | Sets the raw data of an entire mipmap level of a face directly in CPU memory. |
| SetPixels | Sets the pixel colors of an entire mipmap level of a face of a slice. |
| SetPixels32 | Sets the pixel colors of an entire mipmap level of a face of a slice. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |