# Render Texture
The RenderTexture can be considered as a drawable texture or a collection of multiple textures. The main screen can be considered as a special rendering canvas.
# Create
RenderTexture is a resource, and it can also be created in two ways.
# Edit in IDE
Create a RenderTexture:
# Create with code
const rt = new engine.RenderTexture({
width: 256,
height: 256,
needSampleCount: true,
colors: [{}],
depthStencil: {
format: ETextureFormat.Depth_High | ETextureFormat.Depth_Low | ETextureFormat.Depth_Stencil,
needRead: false
}
});
# Configuration
Use IDE to create. Currently, only width
, height
and setAsSharedRenderTexture
can be configured. The first two are width and height and do not need to be repeated. The last one is related to the open data field. For details, see [Open Data Field](../.. /opendata/index.md).
If you use code to create, there are many parameters that can be configured, of which the more important ones are colors
and depthStencil
:
- colors: color buffer, a RenderTexture can theoretically have multiple color buffers, but currently the mini game framework only supports one, developers can configure the required texture parameters here, you can refer to 贴图 .
- depthStencil: depth stencil buffer, configure the depth stencil buffer used by RenderTexture, the default format is
Depth_Stencil
.
# use
Using RenderTexture is also very simple, you can use it as the renderTarget
of camera, or use it as a texture to render.