Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How can you force HDRP to initialize a preview scene?

Discussion in 'Graphics Dev Blitz Day 2023 - Q&A' started by MechaWolf99, May 24, 2023.

  1. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    295
    Hello, I have some code for generating custom previews in the editor using a PreviewScene.
    My only issue is that I have to call camera.Render() at least once before actually starting to render the previews, in order to force HDRP to initialize the scene. And I have to wait until the next frame before actually rendering. Otherwise the lighting would be inconsistent between previews.

    Is there a nicer to initialize scene with HDRP? I'm not afraid of a bit of reflection if that is what it takes.

    Thanks!
     
    Lars-Steenhoff likes this.
  2. AMoulin

    AMoulin

    Unity Technologies

    Joined:
    Mar 29, 2022
    Posts:
    8
    Hey MechaWolf99!

    I'm not sure this is exactly what you are looking for, but just wanted to mention that we recently added a new API RenderPipeline.SubmitRenderRequest() usable with both URP and HDRP for 2023.1+ that you could use instead of Camera.Render(). It is safer that Camera.Render() and more powerful as you can use it with an active camera. There is still some cleaning to do on the documentation side, things are still a work in progress on that front, but you can find some explanations here and an example there. Right now, HDRP support is relatively basic and you might want to call it once or twice to stabilize temporal effects (exposure and else...) as we use a separate camera history from the render loop to protect it, but we plan to extend it. Hope this helps a bit.