Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved HDMaterial.ValidateMaterial still broken for Shader Graphs [HDRP 14.0.6]

Discussion in 'High Definition Render Pipeline' started by TriceHelix, Feb 3, 2023.

  1. TriceHelix

    TriceHelix

    Joined:
    Mar 6, 2019
    Posts:
    34
    In the brand new 2022.2.5f1 release, the patch notes indicate that
    HDMaterial.ValidateMaterial(Material)
    should now correctly handle Shader Graph properties. I have observed an improvement when it comes to the surface type (which in the prior version would not be updated/validated when changed via the Material API). However, now local shader keywords are broken.
    Consider this (pseudo-) code:
    Code (CSharp):
    1. Material mat = new(<...>); // use any shader created with Shader Graph
    2. mat.EnableKeyword("_EXAMPLE_KEYWORD"); // arbitrary keyword exposed by the graph, set to false by default
    3. HDMaterial.ValidateMaterial(mat);
    4. Debug.Log(mat.IsKeywordEnabled("_EXAMPLE_KEYWORD"));
    5. // Expected value: true
    6. // Actual value: false
    This is not an issue with
    Material.IsKeywordEnabled()
    , as any beaviour in the corresponding Shader Graph which depends on the keyword does not change. Using
    Material.SetKeyword()
    or
    Material.DisableKeyword()
    do not work either. It seems like the bug only appeared with version 14.0.6, as I could not reproduce it in version 14.0.5.

    Note: I have not tested this with non-ShaderGraph shaders or other Unity versions besides 2022.2.5f1.
     
  2. adrien-de-tocqueville

    adrien-de-tocqueville

    Unity Technologies

    Joined:
    Mar 16, 2020
    Posts:
    275
    Thanks for the report, the issue is being fixed
     
    TriceHelix likes this.
  3. TriceHelix

    TriceHelix

    Joined:
    Mar 6, 2019
    Posts:
    34