Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to get the progress of path tracing

Discussion in 'HDRP Ray Tracing' started by wenzy, Jul 11, 2021.

  1. wenzy

    wenzy

    Joined:
    Nov 17, 2015
    Posts:
    44
    Hi, community

    Is it possible to get the path tracing progress ? I want to render a series images and composite them as a video. The problem is there is no API to know when the render has done. So I can't make a script to auto save the image.(When render an image, We can see a gray process bar below the game view)
     
    newguy123 and fuzzy3d like this.
  2. PavlosM

    PavlosM

    Unity Technologies

    Joined:
    Oct 8, 2019
    Posts:
    31
    Hey! I'm not sure if you just want to save the video from the Unity Editor or you want to do it from your own script.

    If you just want the video, then the latest Unity Recorder already includes the functionality that is necessary to save converged path traced images and save them as video.

    But you can also do the same from your scripts:
    The path tracer will converge after N frames are renderer, where N is the number of samples you have in the Maximum Samples property in the path tracer volume.

    We don’t have an explicit API to query the progress (that’s a good idea to add), but for now you can keep track of this using a variable in your script. In this post you can find a script that manually calls camera.Render() to save converged path traced images.

    This script is using the Multiframe rendering and accumulation API to handle animation and scene changes while recording the frames. If your scene is static, then the calls to BeginRecording/PrepareNewSubFrame/EndRecording are not necessary (as the other person in that thread did it).
     
    TerraUnity and jeremedia like this.
  3. wenzy

    wenzy

    Joined:
    Nov 17, 2015
    Posts:
    44
    -------------------------------------------------
    Thank u . That's helpful :)

    This is some record testing (https://twitter.com/i/status/1415706151157571586)

    Really love the path tracing feature
     
  4. stefanob

    stefanob

    Joined:
    Nov 26, 2012
    Posts:
    68
    If I select a denoiser (Nvidia Optix Denoiser in my case) for my path tracer, how do I know when it is done? Can I access it's state somehow? When I export a screenshot right after the path tracer is done I don't get the denoised image yet.
     
  5. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Right now, there's no API to know the current progress of the pathtracer.
    It should be possible though and has already been asked a few time so it's not totally out of question that we add it, I'll see what's possible.

    In the meantime, in your case, if you count the number of frames elapsed and capture the image (using a classic ScreenCapture.CaptureScreenshot()) when frame count is >= (Samples+1), the current image should be denoised.

    In the game view the denoising is a "blocking" process so it should happen at the last frame.

    Issue tracker link.
     
    Last edited: Sep 2, 2022
    jeremedia and stefanob like this.