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

Bug Missing RayTracing API features, RayTracingAccelerationStructure bugs?

Discussion in 'HDRP Ray Tracing' started by orikama, Aug 19, 2021.

  1. orikama

    orikama

    Joined:
    Sep 4, 2019
    Posts:
    2
    Hello!
    So recently I was playing with RayTracingAccelerationStructure and custom closesthit/intersection shaders in Unity 2021.2.0b6 and came across some missing features in the API:

    1. Why there is a way to set
    Renderer.rayTracingMode
    in C# script, but no way to set this "Ray Trace Procedurally" checkbox?
    upload_2021-8-19_17-30-39.png

    2. Why there is no way to set
    D3D12_RAYTRACING_GEOMETRY_FLAGS
    in
    RayTracingAccelerationStructure.AddInstance(GraphicsBuffer aabbBuffer, ...)
    methods, while you can set it with
    AddInstance(Renderer targetRenderer, RayTracingSubMeshFlags[] subMeshFlags, ...)
    I assume that RayTracingSubMeshFlags is D3D12_RAYTRACING_GEOMETRY_FLAGS internally.

    Now, due to this inconveniences I described above, I decided to switch from using AABB and intersection shader to cube GameObject's which will act like an AABB and quickly stumbled upon a more complicated problem. (bug?)
    When I was setting InstanceID through AddInstance(GraphicsBuffer aabbBuffer, ..., id: instanceID) and then getting it with InstanceID() intrinsic in my closesthit shader it worked fine.
    Then I switched to AddInstance(Renderer targetRenderer, ..., id: instanceID) method and everything stopped working.
    Later with the help of NVIDIA Nsight I found out that setting id argument in AddInstance(Renderer targetRenderer, ...) method does nothing, it just sets id's in some unreliable order (not in the order in which AddInstance's were called, idk what it is, some internal driver stuff?)

    Also I wanted to ask, is setting multiple RayTracingAccelerationStructure's in one RayTracingShader supported by Unity?
    For example, I add a cube with materialGreen to RAS1 and a cube with materialRed to RAS2.
    Now when I set RAS1 and then RAS2 in my RT shader, I get both cubes colored in red. If I set RAS2 first and then RAS1, I get 2 green cubes.
     
    funkyCoty and SergeyKoptev like this.