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

Ray Tracing Issue: Changing material property causes 18 second delay in operation of path tracer

Discussion in 'High Definition Render Pipeline' started by GregBahm, Jun 15, 2021.

  1. GregBahm

    GregBahm

    Joined:
    Jul 1, 2014
    Posts:
    11
    In Unity 2021.1.11f1, if I set any material property using mat.SetColor(propertyId, color), the path tracer stops accumulating rays for several seconds.

    Here's a video demonstrating the issue. This is a realtime-recording of my Unity editor. I overlayed some text for clarity.


    This issue did not manifest in Unity 2019.4.11f1. I upgraded to Unity 2021 so that I could get ray tracing on skinned meshes. I have set up a script to record interactions with my data visualization app and then march through and render each frame with path tracing on. It only takes a second to get a pretty frame path traced, but it takes ~18 seconds for path tracing to work again after changing a material property.

    I tried turning off instancing on the material, and using material.SetColor(string, color) instead of material.SetColor(propertyId, color), but this had no effect. I'm so close to this whole project working. Anyone have ideas for how I can fix this problem
     
  2. GregBahm

    GregBahm

    Joined:
    Jul 1, 2014
    Posts:
    11
    Update: I was able to solve this by changing the materials through a MaterialPropertyBlock instead of Material.SetColor(). I don't understand why this worked, but it made the problem completely go away.