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

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:

Material mat = new(<...>); // use any shader created with Shader Graph
mat.EnableKeyword("_EXAMPLE_KEYWORD"); // arbitrary keyword exposed by the graph, set to false by default
HDMaterial.ValidateMaterial(mat);
Debug.Log(mat.IsKeywordEnabled("_EXAMPLE_KEYWORD"));
// Expected value: true
// 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.

Thanks for the report, the issue is being fixed

1 Like

Fixed according to issuetracker :)