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

LWRP and camera command buffers

Discussion in 'Graphics Experimental Previews' started by jeijei, Jun 25, 2018.

  1. jeijei

    jeijei

    Joined:
    Aug 31, 2014
    Posts:
    30
    I've been using http://xroft666.blogspot.com/2015/07/glow-highlighting-in-unity.html until now to handle outlines on items in my game
    However when i switched to the LWRP the highlights don't show up, and as far as i can tell when i check the main camera there aren't any command buffers
    Does the LWRP handle command buffers? If not, what do i have to do to modify it to handle them
     
  2. Joshhua5

    Joshhua5

    Joined:
    Oct 25, 2016
    Posts:
    3
    Did you ever find the solution to this?
     
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,684
  4. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,684
    phil_lira likes this.
  6. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    :D That's true. I opened the link quickly and only payed attention at the github link in the screenshot!
     
  7. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    This is out of date, how do they work now? The IBeforeCameraRender interface is gone, and felt a little clunky. How do we inject scriptable render passes now? It would be nice to just add them to the render pipeline without creating monobehaviours or a custom pipeline...
     
    Last edited: Apr 26, 2019
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    I haven't found a way to execute a command buffer at specific events, without needing to make an actual ScriptableRenderPass.

    But this will work for rendering something before the camera renders. It should be a MonoBehaviour in this case.

    Code (CSharp):
    1.  
    2.         private void OnEnable()
    3.         {
    4.             RenderPipelineManager.beginCameraRendering += Render;
    5.         }
    6.  
    7.         private void OnDisable()
    8.         {
    9.             RenderPipelineManager.beginCameraRendering -= Render;
    10.         }
    11.  
    12.         private void Render(ScriptableRenderContext context, Camera cam)
    13.         {
    14.             cmd = CommandBufferPool.Get("CustomCMD");
    15.  
    16.             //Specifics here
    17.  
    18.             context.ExecuteCommandBuffer(cmd);
    19.             CommandBufferPool.Release(cmd);
    20.         }
    21.  
    Most likely not very SRP-like to do things this way, but I'm clinging into it since it works for me :D
     
  9. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    That won't work for me, I have to run it at specific points in the pipeline, and I definitely don't want to write a pipeline from scratch. Oh well, I will wait for 6-12 months for it to mature and get proper examples and documentation :)
     
    AlejUb likes this.
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    From what I gathered, the only way to currently do that is through ScriptableRenderPass which has to be executed in the render loop. That would mean modifying the LWRP or creating a custom pipeline.

    Otherwise creating a render feature as outlined here may be an option?
     
    Flurgle likes this.
  11. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    The render feature seems to work somewhat. You have to implement the class to inherit UnityEngine.Rendering.LWRP.ScriptableRendererFeature, then add it to your LWRP asset by using a custom forward renderer.

    It seems a bit buggy though, my command buffers execute 3 times in a row... :)
     
    Flurgle and StaggartCreations like this.
  12. AlejUb

    AlejUb

    Joined:
    Mar 11, 2019
    Posts:
    25
    This is maybe exactly what I need, thanks a lot.

    Had a couple of questions:
    What's the main difference between begin/end camera render and begin/end Frame?
    Is 'Frame' after all cameras, all post processes, etc have finished?
    I'm trying to attach a camera render target to a global texture variable after that camera's post process has finished.