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. Dismiss Notice

Question Is it possible to grab screen image at a specific draw call?

Discussion in 'Universal Render Pipeline' started by JSmithIR, Sep 4, 2023.

  1. JSmithIR

    JSmithIR

    Joined:
    Apr 13, 2023
    Posts:
    84
    Hi,

    I was brainstorming approaches for a needed effect and I need help determining if something is possible. In URP can I blit (or something similar) the rendered image to a temp texture at a certain draw call? For example, instead of blitting the final screen image after everything is drawn and post-processing, can I somehow capture the screen after the first ten objects are drawn (for example) and before the rest of the objects are drawn?

    Looking for a way to capture the image of an object that is currently blocked by another object in front. And I want to do this for many objects. Essentially, want to capture the way an object is drawn for a given frame in order to capture how it is oriented at the current viewing angle. Dont want to get other objects that are in front of it, but I DO want to include objects that are behind it and visible around the perimeter of said object.

    I mean, I can view these images in the frame debugger by scrolling through the draw calls. I would think Unity would allow me to just pass one into a temporary render texture?

    Thanks
     
  2. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    289
    I am pretty sure this will be rather difficult.

    "After a certain object" isn't that easy in a full release build. The render order will probably get changed, sorting is never reliable and a large part of good rendering performance is the ability to for the gpu to just crunch through those large amounts of objects uninterupted (and changing from write to read is a large interuption).
    (The frame debugger basically costs you a large amount of performance)

    I would rather think about using a different approach tbh.

    Maybe using renderqueue ids and at certain Ids blitting the framebuffer (or parts of it) to a fixed set of lookup textures could work, or a complety custom renderer might be able to do it.

    Maybe just re-rendering the object you are looking for to an atlas texture which contains all your needed objects is actually an approach you could try (lots of additional draw calls but at least doable, maybe you can use some parts of the background from a previous frame's texture)
     
    JSmithIR likes this.
  3. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    214
    Can you elaborate more on your intended usage? Defining the desired outcome rather than the desired path might be more likely to find a solution. For instance, are you trying to view or highlight objects occluded by other geometry? If so, stencil passes or the render objects render feature may be useful