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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Basic Command Buffer Question

Discussion in 'Universal Render Pipeline' started by cyuxi, May 28, 2020.

  1. cyuxi

    cyuxi

    Joined:
    Apr 21, 2014
    Posts:
    49
    (It's very frustrating to find step-by-step tutorials about CommandBuffer. Yea, There are lots of example codes and projects out there, but most are only fancy, nothing like a clean "Hello World"...:confused:)

    What I was attempting is :
    1- Simply put few lines in the OnEnable and drag the script to a scene GameObject;
    2- Run the game and check if any information shows up in Frame Debugger (the Name of CommandBuffer);
    3- If the Name of CommandBuffer is found , It's Hello world!

    But in the end, after searching a lot on internet and reading documents, I just couldn't get any thing useful to make it happen.. The CommandBuffer is not listed in the Frame Debugger. And I am not sure if the CommandBuffer was working or not, and Why...Please anyone can give any help, information or advice. Thanks.
    (I'm using 2018.4.0f1 LWRP)

    Here is the part of code:
    Code (CSharp):
    1.         void OnEnable()
    2.         {
    3.             _commandBuffer = new CommandBuffer();
    4.             _commandBuffer.name = "Test CommandBuffer";
    5.             int testRT = Shader.PropertyToID("_testRT");
    6.             _commandBuffer.GetTemporaryRT(testRT, 500, 500, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 0, false);
    7.             _commandBuffer.Blit(BuiltinRenderTextureType.CameraTarget, testRT);
    8.             Camera.main.AddCommandBuffer(CameraEvent.BeforeImageEffects, _commandBuffer);
    9.         }
     
    Last edited: May 29, 2020
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    https://docs.unity3d.com/Packages/c...l/universalrp-builtin-feature-comparison.html:
    To get it to work in URP, you'll probably need to create a subclass of ScriptableRendererFeature, which adds a ScriptableRenderPass, which creates the commandbuffer and executes it in
    Code (CSharp):
    1. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    . There are examples out there on the web that I followed to do this kind of thing, sorry I don't have the link handy.
     
  3. cyuxi

    cyuxi

    Joined:
    Apr 21, 2014
    Posts:
    49
    Many Thanks !
    In the table, I can already see they have banned so many pipeline features of URP regarding to Commndbuffer and Camera rendering callbacks.... Quite a shock to know the fact... just feel like falling into the bottom of a trough on the learning curve...:eek:

    I think the link below is the way you've pointed:
    https://github.com/UnityTechnologies/LWRPScriptableRenderPass_ExampleLibrary
     
  4. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    No problem.
    I recommend you look at this repository instead, as it is up-to-date for URP (LWRP is the old name):
    https://github.com/Unity-Technologies/UniversalRenderingExamples

    There is also a video tutorial that explains this repository somewhere...