Search Unity

How to know when a commandBuffer starts rendering and when does it finish?

Discussion in 'Image Effects' started by CGDever, Apr 21, 2018.

  1. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    Hi guys.
    I'm making a camera that renders all objects in the scene except objects with the tag "enemy".
    The object can be excluded ( obj.SetActive(false) ) from rendering in the OnPreRender().
    Then the object can be activated ( obj.SetActive(true) ) in the OnPostRender().
    As a result, the camera does not render the object.

    Now I'm using CommandBuffer and the "enemy" is rendered:
    https://yadi.sk/i/CXOY7qvi3UdsFS
    Here is the order of calling methods (https://docs.unity3d.com/Manual/ExecutionOrder.html ... just in case).
    This is an example of how I add a buffer:
    camera.AddCommandBuffer(CameraEvent.BeforeImageEffects, cmdBuff);

    The problem is that I do not know how to set the command buffer so that it works after OnPreRender, but before OnPostRender. Is this possible?
    How to know when a commandBuffer starts rendering and when does it finish?
     
    Last edited: Apr 21, 2018
    dylan-hart likes this.
  2. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    Is the question quite simple or is it impossible to do it?