Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Is there any way to do a single Camera.Render() with URP?

Discussion in 'Universal Render Pipeline' started by kbm, Jan 27, 2020.

  1. kbm

    kbm

    Joined:
    Aug 7, 2014
    Posts:
    83
    Right now, a feature in our game relies on being able to disable some effects, then manually render one camera into a render texture, then re-enable the effects. all in one frame.

    Is there any way to do this with the URP or not at all? Camera.Render() hook is listed as "not supported" and without this feature we can't really upgrade to URP at all.

    Also, bonus question: Would our game theoretically be able to run on a Nintendo Switch with the built-in render pipeline?
     
  2. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    580
    You can use UniversalRenderPipeline.RenderSingleCamera. That is the similar to Camera.Render

    Both URP and Builtin' pipelines support Nintendo Switch.
     
    CyrilGhys and avandenberg like this.
  3. osso_geo

    osso_geo

    Joined:
    Mar 4, 2019
    Posts:
    2
    Thanks for asking this question, kbm.

    What Context do you pass RenderSingleCamera? I'm using it to render one frame of a secondary camera. I can't find any examples of its use.

    Thanks in advance for any assistance!

    Geo
     
    deus0 and Mese96 like this.
  4. avandenberg

    avandenberg

    Joined:
    Nov 22, 2018
    Posts:
    23
    I case you haven't figured this out, I ran into the same problem, just paying forward the help I was offered!


    using UnityEngine.Rendering;
    using UnityEngine.Rendering.Universal;
    using RenderPipeline = UnityEngine.Rendering.RenderPipelineManager;
    ...

    private void OnEnable()
    {
    RenderPipeline.beginCameraRendering += UpdateCamera;
    }
    ...
    void UpdateCamera(ScriptableRenderContext SRC, Camera camera)
    {
    ...
    UniversalRenderPipeline.RenderSingleCamera(SRC, portalCamera);
    ...
    }
     
    deus0, Adunato, CyrilGhys and 4 others like this.
  5. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    612
    Is there a way to do this from an editor script?

    (Just trying to render a texture from a temporary camera and save it to a file, something that used to work with camera.Render() with the classic render pipeline)

    edit: Got it working after discovering the editor coroutines package, and using a coroutine to just wait a frame for the camera to render itself
     
    Last edited: Jan 14, 2021
    Arlorean likes this.
  6. ekakiya

    ekakiya

    Joined:
    Jul 25, 2011
    Posts:
    59
    Last edited: Jan 16, 2021
    bluescrn likes this.
  7. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    612
    Interesting. Might have just been a Graphics.CopyTexture (from RenderTexture to saveable Texture2D) not working as expected when I tried that then, as I ended up switching to Texture2D.ReadPixels to get the coroutine version working.
     
  8. xujinm

    xujinm

    Joined:
    Dec 11, 2018
    Posts:
    13
    when I used UniversalRenderPipeline.RenderSingleCamera() with this camera.enabled is false,this camera just can't render ui canvas .Does anyone konw this???
     
  9. AljoshaD

    AljoshaD

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    125
    The RenderRequest api should be what you need. It landed in 2022.2 https://github.com/Unity-Technologies/Graphics/commit/76150c8114170b7e2359ccd786c02b22bafdb125