Texture Assets
Texture assets are assets used for procedural sampling, such as textures on models and the UI on Sprites. When the UI or model are rendered, the corresponding texture is sampled, then filled on the model grid, plus a series of processing such as lighting to render the entire scene.
Texture assets can be generated from ImageAsset. Some common image formats, including .png
, .jpeg
, etc. can be used in ImageAsset.
Texture2D
Texture2D is a type of texture asset that is usually used for rendering of 3D models, such as reflection map, ambient occlusion map, etc… in model materials.
Texture2D in Cocos Creator:
Note: the texture type is a Texture2D asset.
Adjusting the Properties of a Texture2D
When importing an ImageAsset, it will be set to Texture2D by default. At this same time, one or more sub-assets will be generated on the original asset. Click the arrow in front of the original asset to see all the sub-assets. Example:
After selecting the generated Texture2D sub-asset, you can see the following panel:
Sub-Asset Texture2D Properties Panel
The following describes the properties of the panel:
Property | Explanation |
---|---|
Anisotropy | Anisotropy value |
Min Filter | Narrowing Filter Algorithm |
Mag Filter | Magnification Filter Algorithm |
Mip Filter | Multi-level texture filtering algorithm |
Wrap Mode S | S (U) direction texture addressing mode |
Wrap Mode T | T (V) direction texture addressing mode |
Note: since the default Wrap Mode may result in black edges when rendering transparent edges of an image, Creator will change the Wrap Mode S and Wrap Mode T properties of the texture resource to clamp-to-edge automatically when setting the image resource type to sprite-frame, which can be modified by the developer if there is a special need.
Using Texture2D
Texture2D is a very widely used asset. Any property marked as Texture2D in the Inspector panel can be dragged into a Texture2D asset type.
The usage scenario is mainly in the Editor environment and for dynamic acquisition:
- In the Editor, just drag the assets in;
- For dynamic acquisition, you need to obtain the ImageAsset asset first, and then instantiate the Texture2D asset based on the obtained ImageAsset.
TextureCube
TextureCube is a cube texture, which can be used to set the scene’s Skybox. It can be obtained by setting the panorama ImageAsset to the TextureCube type. It can also be obtained by making CubeMap assets.
TextureCube obtained from a panorama in Cocos Creator:
TextureCube obtained by making a CubeMap in Cocos Creator:
To learn more about the use of TextureCube and CubeMaps, please refer to the Texure Cube|Skybox documentation.