Render textures

With 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.

For API details, see .

Camera slots link the graphics compositor to the cameras in your scene. You need to add a camera slot for a new camera to use. For more information about camera slots, see Camera slots.

  • In the Asset View (in the bottom pane by default), double-click the Graphics Compositor asset.

The graphics compositor editor opens.

Graphics Compositor editor

  • On the left, under Camera slots, click (Add).

Camera slots

Game Studio adds a new camera slot.

Tip

To rename a camera slot, double-click it in the list and type a new name.

2. Create a camera and bind it to the slot

Add camera component

  • Position the entity so the camera captures the area of the scene you want to render to a texture.

  • In the entity Property Grid, enable the Camera component using the checkbox.

  • in the Camera component properties, under Slot, select the slot you created in the previous step.

Select camera slot

In the Asset View, click Add asset and select Texture > Render target.

Game Studio adds a render target texture to your project assets.

Render texture

4. Place the render target texture in the scene

There are various ways you can use the render target texture.

  • In the material properties, under Shading, next to Diffuse map, click (Replace) and select Texture.
  • Click Hand icon (Select an asset).

  • Select the Render texture asset and click OK.

  • Create an entity and position it where you want to display the texture.

  • With the entity selected, in the Property Grid, click Add component and add a sprite component.

Add sprite component

  • In the sprite component properties, next to Source, click (Replace) and select Texture.

Select sprite source

  • Click (Select an asset).

    The Select an asset window opens.

  • Select the Render texture asset and click OK.

Select render frame

  • If you don't want the texture to be semi-transparent, under the Source properties, clear the Is transparent checkbox.

To display a render texture in your scene, you need at least two renderers:

  • one to render your main camera
  • one to render the second camera to the render textureThis page describes the simplest way to do this from scratch, using two cameras and two renderers. Depending on your pipeline, you might need to create a different setup.
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.

  • In the graphics compositor editor, select the Entry points node.

Entry points node

  • In the Property Grid on the right, next to Game renderer, click (Replace) and select None to delete your existing renderers.

Cleared game renderers

This lets you set multiple renderers for the game entry point.

  • Under Game renderer, next to Children, click Green plus button (Add) and select Camera renderer.

  • Next to Camera, click Blue arrow button (Replace) and select your main game camera.
  • Next to Child, select the renderer for your main game camera (eg the forward renderer).

  • Under Game renderer, next to Add to Children, click Green plus button (Add) and select Camera renderer.

Game Studio adds a camera renderer to the list of children.

Second camera renderer

  • Expand the second camera renderer.

  • Next to Camera, click Blue arrow button (Replace) and select the camera you want to render to a texture.

  • Next to Child, click Blue arrow button (Replace) and select RenderTextureSceneRenderer.

  • Under the RenderTextureSceneRenderer, next to Child, click Blue arrow button (Replace) and select the renderer for your main game camera (eg the forward renderer).

  • Next to Render texture, click Hand icon (Select an asset).

    The Select an asset window opens.

  • Select the render texture and click OK.

Game Studio adds the render texture to the renderer.

Render texture added

Your game is now ready to render the camera to the texture in the scene.

Set a render mask

You can use the render mask to filter which groups are rendered in the render texture.

Next to Render mask, click Change values and select the render groups you want the camera to render.

For more information, see .

See also