Search Unity

Command buffer for Post Camera Effects?

Discussion in 'Image Effects' started by resetme, Apr 20, 2018.

  1. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    204
    Hi there,

    Im used to do camera effects using OnRenderImage but i saw some code with commandBuffer,
    i cant get the idea of it, im trying to do a simple downsample of my current camera render and it wont work at all... looking at the Frame Debugger i cant see the image effect being applied but in game and editor nothing change.

    my code goes like:

    OnPostRender
    - new Command Buffer
    - GetTemproraryRT of full screen
    - Create a GetTemporary half Size of screen
    - blit the Full Screen temporary to the Half Size screen temporary
    - Remove Full Screen temporary
    - Take the half Screen downsample RT and put it on another Full Screen Temporary
    - blit the downsample full screen into BuiltinRenderTextureType.CurrentActive
    ------->_buffer.Blit(FinalTextureID, BuiltinRenderTextureType.CurrentActive, _bloomMaterial);
    - AddCommandBuffer

    That works only inside the frame debugger.
    i tried removing the last blit and use SetGlobalTexture with no lucky.

    What im missing here?
    Help!
     
  2. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    I'm not a professional, but maybe you create a new commandBuffer each time before the previous one works.
    Look closer at the params in AddCommandBuffer.
     
  3. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    204
    im still trying and looks like if i want to use CommandBuffer as a Post Camera Effect i also need to use OnRenderImage or setup the camera differently. At the end is more expensive to use Command buffer for full screen camera effect.

    I remove all of it and went to the only image effect technique with best optimization results.

    im doing something wrong?