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

Should I use RayTracingShader or CommandBuffer for RTX feature?

Discussion in 'Scripting' started by guodongrong, Apr 27, 2020.

  1. guodongrong

    guodongrong

    Joined:
    Dec 4, 2019
    Posts:
    13
    I am learning writing my own ray tracing shaders in Unity. I found two classes can do almost the exact same things for RTX:
    1. RayTracingShader (https://docs.unity3d.com/ScriptReference/Experimental.Rendering.RayTracingShader.html); and
    2. CommandBuffer (https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.html).

    Every method in RayTracingShader class has a corresponding method in CommandBuffer class. For example:
    * RayTracingShader.Dispacth => CommandBuffer.DispatchRays
    * RayTracingShader.SetAccelerationStructure => CommandBuffer.SetRayTracingAccelerationStructure
    * RayTracingShader.SetTexture => CommandBuffer.SetRayTracingTextureParam
    ...

    So, what is the difference between using RayTracingShader and using CommandBuffer? Which one should I use? Why does Unity have two ways to do the same thing? Or are they for different purposes?
     
    Last edited: Apr 27, 2020
  2. guodongrong

    guodongrong

    Joined:
    Dec 4, 2019
    Posts:
    13
    Anybody with RTX experience can help on this? Thanks!