Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Ray tracing with dynamically added/deleted objects

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

  1. guodongrong


    Dec 4, 2019
    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).