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

Ray tracing with dynamically added/deleted objects

Discussion in 'Graphics Experimental Previews' started by guodongrong, Apr 2, 2020.

  1. guodongrong

    guodongrong

    Joined:
    Dec 4, 2019
    Posts:
    13
    Most of objects in my scene are added at the beginning of the application. I used RayTracingAccelerationStructure.AddInstance to add all corresponding renderers in my acceleration structure and called RayTracingAccelerationStructure.Build to build the structure.

    In the Update function, I called RayTracingAccelerationStructure.UpdateInstanceTransform for all moving objects and then called RayTracingAccelerationStructure.Update to update the structure.

    Some objects are dynamically added to the scene and some are deleted. How should I deal with such objects?
    * When an object is added to the scene, I can call RayTracingAccelerationStructure.AddInstance to add its renderers. Do I have to call RayTracingAccelerationStructure.Build again? Or is RayTracingAccelerationStructure.Update enough?
    * When an object is removed from the scene, how can I delete it from the RayTracingAccelerationStructure? (There is no method like RayTracingAccelerationStructure.RemoveInstance).