Render Texture
Click the + button in the top left of the Assets panel and select RenderTexture to create a Render Texture:
The properties associated with the render texture asset can then be set in the Inspector panel.
In the camera component, assigning RenderTexture to the camera’s TargetTexture property will draw the result of the camera’s illumination onto the RenderTexture.
RenderTexture can be used like a normal texture. Take Sprite Component as an example, drag and drop from Assets panel onto the SpriteFrame property on Sprite’s Inspector panel.
To use RenderTexture in material includes the following two steps:
Select the corresponding material in the Assets panel, then check
SAMPLE FROM RT
in the Inspector panel:
There are two ways to use RenderTexture programmatically:
Method 1: Draw the contents illuminated by the 3D camera to the sprite frame of the UI.
Method 3:Read the content drawn by the 3D camera into the ArrayBuffer through the readPixels method
Make sure that the shader has a property and is enabled in the material if you want to display the drawing results correctly. For example, if using the
builtin-standard
shader, make sure the USE ALBEDO MAP option is checked:
For more information about the usage, please refer to the example RenderTexture ().