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

ShaderData.SubShader returns incorrect passCount for Lit shader

Discussion in 'Universal Render Pipeline' started by rainluna, Feb 21, 2022.

  1. rainluna

    rainluna

    Joined:
    Sep 3, 2021
    Posts:
    4
    upload_2022-2-21_19-29-25.png upload_2022-2-21_19-29-54.png
    Screenshots are from Unity 2020.2 URP 10.3.1. Lit shader source code has 7 passes in the first subShader and 5 passes in the second. The other result I get from the code above in Unity 2019.4 URP 7.4 is: upload_2022-2-21_20-0-30.png
    But in fact Lit shader has only 1 subShader and 5 passes :) like what the heck?
     
  2. rainluna

    rainluna

    Joined:
    Sep 3, 2021
    Posts:
    4
    fyi reply from https://twitter.com/Cyanilux in Unity's Official Discord channel:
    I'm not very familiar with the ShaderData stuff, It could very well be bugged. But it's also possible that it only counts SubShaders/Passes that are currently being used / compiled. If the scene isn't using them it might be stripped. Hence 6 and not the full 7. And in both versions the second subshader (with one pass) could be Fallback (magenta error shader).
     
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,864
    Hi!
    ShaderData reports what the runtime sees. The URP/Lit shader has two subshaders that include a different subset of graphics APIs (one excludes GL backends, another one includes only GL backends; you cannot have both at the same time) and a fallback. Fallback subshaders are also counted in there.
     
  4. rainluna

    rainluna

    Joined:
    Sep 3, 2021
    Posts:
    4
    Hey! Thanks for reply! I got it. Is there a way to check if subShader/pass is excluded for current platform?
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,864
    I don't think there is currently.