Render textures
IntermediateDesignerProgrammer render textures, you can send a camera’s view to a texture and use the texture on objects in your scene. For example, you can use this to display part of your scene on a TV screen in the same scene, such as security camera footage. Textures and render textures.
1. Create an extra camera slot
Camera slots.
- Asset View (in the bottom pane by default), double-click the Graphics Compositor asset. The graphics compositor editor opens.
- Camera slots, click (Add).
Game Studio adds a new camera slot.
Tip
2. Create a camera and bind it to the slot
- camera component to the entity you want to be your camera.
- Position the entity so the camera captures the area of the scene you want to render to a texture.
- Property Grid, enable the Camera component using the checkbox.
- Camera component properties, under Slot, select the slot you created in the previous step.
3. Create a render target texture
Asset View, click Add asset and select Texture > Render target. render target texture to your project assets.4. Place the render target texture in the scene
There are various ways you can use the render target texture.Example 1: Use the render target texture in a material
- Shading, next to Diffuse map, click (Replace) and select Texture.
- (Select an asset).
- Render texture asset and click OK.
Example 2: Use the render target texture in a sprite component
- Create an entity and position it where you want to display the texture.
- Property Grid, click Add component and add a sprite component.
- Source, click (Replace) and select Texture.
- (Select an asset). Select an asset window opens.
- Render texture asset and click OK.
- Source properties, clear the Is transparent checkbox.
5. Set up the graphics compositor
To display a render texture in your scene, you need at least two renderers: - -
Warning
These instructions involve deleting your existing renderers for the game entry point. You might want to make a backup of your project in case you want to restore your pipeline afterwards. - Entry points node.
- Property Grid on the right, next to Game renderer, click (Replace) and select None to delete your existing renderers.
- (Replace) and select Scene renderer collection.
This lets you set multiple renderers for the game entry point.
1. Render the main camera
- Game renderer, next to Children, click (Add) and select Camera renderer.
- Camera, click (Replace) and select your main game camera.
- Child, select the renderer for your main game camera (eg the forward renderer).
2. Render the texture
- Game renderer, next to Add to Children, click (Add) and select Camera renderer. Game Studio adds a camera renderer to the list of children.
- camera renderer.
- Camera, click (Replace) and select the camera you want to render to a texture.
- Child, click (Replace) and select RenderTextureSceneRenderer.
- RenderTextureSceneRenderer, next to Child, click (Replace) and select the renderer for your main game camera (eg the forward renderer).
- Render texture, click (Select an asset). Select an asset window opens.
- render texture and click OK.
Game Studio adds the render texture to the renderer.
Your game is now ready to render the camera to the texture in the scene.
Set a render mask
render mask to filter which groups are rendered in the render texture. Render mask, click Change values and select the render groups you want the camera to render. Render groups and masks.Sample
Animation sample included with Xenko.See also
- Cameras
- Camera slots
- Low-level API – Textures and render textures
- Render groups and masks
- Graphics compositor
- Scene renderers
