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

Kinematica: Using Kinematica with Scriptable Render Pipeline (URP or HDRP)

Discussion in 'Animation Previews' started by randomPoison, Apr 13, 2021.

  1. randomPoison

    randomPoison

    Joined:
    Apr 3, 2021
    Posts:
    5
    While experimenting with Kinematica in a project that uses the URP, I noticed that the snapshot debugger wouldn't correctly render its debug visualizations when active:

    upload_2021-4-12_23-49-29.png

    Note how in the above image I have the snapshot debugger enabled and am examining a specific frame, but the captured debug info isn't displaying.

    After some debugging I was able to determine that this was because snapshot debugger is relying on the
    Camera.onPostRender
    event in order to render the debug overlay, and that event isn't broadcast when using the scriptable render pipeline.

    Fortunately for us
    onPostRender
    is just a public delegate, and we can invoke it explicitly for ourselves! As an example, here's the setup I'm using the forward the
    RenderManager.endCameraRendering
    to
    onPostRender
    which gets the debug overlay working again:

    Code (CSharp):
    1. [RuntimeInitializeOnLoadMethod]
    2. public static void RegisterCameraCallback()
    3. {
    4.     // Register a callback that forwards the `endCameraRendering` event to the legacy
    5.     // `onPostRender` event used by the Kinematica frame debugger.
    6.     RenderPipelineManager.endCameraRendering += (context, camera) =>
    7.     {
    8.         Camera.onPostRender.Invoke(camera);
    9.     };
    10. }
    upload_2021-4-13_0-4-57.png

    Hopefully once Kinematica development resumes direct compatibility for SRP will be added, but until then I hope this helps someone out!
     
    xiangshushu and FrancoisFournel like this.