Search Unity

Bug 2D URP Multiple renderfeatures rendertexture doesn't seem to update everyframe, or update is ignored

Discussion in 'Universal Render Pipeline' started by ThroughlineFums, May 23, 2023.

  1. ThroughlineFums

    ThroughlineFums

    Joined:
    Oct 21, 2021
    Posts:
    3
    In 2D URP, I'm trying to make my own dof system. To this end I have 3 cameras that capture different segments of the world. I then merge these captures together to create a simple alpha based depth map in grey scale.
    I then use a renderfeature to apply a kawase blur onto the MainCamera, based on this alphamap. And it works, except it seems that when it needs to do this blur, it uses the previous frames alpha map. I.e when I move the camera i get a blurry outline that would match the previous frames outline.

    All of the materials and rendertextures used in this process, is created and set up before hand in unity. None of the renderfeatures update texture references. I only update the offset and passes float values.

    In the editor, if I pause and skip frames, it is possible for me to get this blur quite a few frames behind, before I then move the mouse and it does it correctly. Does anybody know why it doesn't seem to update the render texture or use the previous frames render texture. This is also present in a build, to the point where if my character and the camera moves at the same time, it's completely distracting and unusable.
    The game view after i press next frame a few times.
    Blurry.png
    The game view after I then move the mouse around a bit
    UnBlurry.PNG

    The order in the Renderer list should be correct. The cameras also have different priorities just in case. So behind = 1, center = 2, front = 3, KawaseBlur = 10.
    RenderListOrder.PNG
    Subscribing to
    RenderPipelineManager.beginCameraRendering

    also seems to indicate that it does it in the correct order. The Running late update is c# code that matches the 3 dof cameras fov to the main camera's.
    Debug line description:
    [Time.framecount] [Type: (beginCameraRendering, endCameraRendering, beginFrameRendering, endFrameRendering)] Main [camera name or camera array lenght] [AlphaMap.updatecount]

    The debug log after I pressed the next frame once.
    RunningLateUpdate.png
    And then the debug log immediate after I then move the mouse a bit.
    Double MainCamera.PNG
    I also wonder why there would be two main cameras running. Anybody have some deeper inside into what I've could have setup wrong? Is there some kind of batching behind the scenes in urp, that means I have to set this up differently
    Unity 2022.2.17 and urp 14.0.7
     
    Last edited: May 23, 2023