Rendering to a Render Texture | Universal RP | 10.2.2
docs.unity3d.com
    Show / Hide Table of Contents

    Rendering to a Render Texture

    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, see Rendering order and overdraw.

    Rendering to a Render Texture, and then rendering that Render Texture to the screen

    Rendering to a Render Texture in URP

    Create a Render Texture Asset in your Project using Assets > Create > Render Texture. Create a Quad in your Scene. Create a Material in your Project, and select it. In the Inspector, drag the Render Texture to the Material's Base Map field. In the Scene view, drag the Material on to the Quad. Create a Camera in your Scene. Its Render Mode defaults to Base, making it a Base Camera. Select the Base Camera. In the Inspector, scroll to the Output section. Set the Camera’s Output Target to Texture, and drag the Render Texture on to the Texture field. Create another Camera in your Scene. Its Render Mode defaults to Base, making it a Base Camera. Place the Quad within the view of the new Base Camera.

    The first Camera 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 cameraOutput property of the Camera's Universal Additional Camera Data component, like this:

    myUniversalAdditionalCameraData.cameraOutput = CameraOutput.Texture;
    myCamera.targetTexture = myRenderTexture;
    
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023