In the Universal Render Pipeline (URP), a Camera can render to the screen or to a Render Texture. Rendering to a screen is the default and is the most common use case, but rendering to a Render Texture allows you to create effects such as CCTV camera monitors.
If you have a Camera that is rendering to a Render Texture, you must have a second Camera that then renders that Render Texture to the screen. In URP, all Cameras that render to Render Textures perform their render loops before all Cameras that render to the screen. This ensures that the Render Textures are ready to render to the screen. For more information on Camera rendering order in URP, refer to Rendering order and overdraw.
The first Camera now renders its view to the Render Texture. The second Camera renders the scene including the Render Texture to the screen.
You can set the output target for a camera in a script by setting the targetTexture
property of the camera:
myCamera.targetTexture = myRenderTexture;