Skip to content

Commit 0e84174

Browse files
YohannVaastUnityEvergreen
authored andcommitted
SpeedTree 9 - Fix DoubleSided not enabled for non-billboard materials
- The HDRP property "Double-Sided" is not enabled for non-billboards materials. - I've changed the `if` condition, since we cannot rely on the extra-map to determine if the material is a billboard or not. - I also had to change the Double-Sided value, since it looks like `0.0f` = disable and `1.0f` = enabled. That's what I noticed when importing my ST9 assets in the editor...
1 parent adcf661 commit 0e84174

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Packages/com.unity.render-pipelines.high-definition/Editor/Material/Nature/HDSpeedTree9MaterialUpgrader.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ private static class HDProperties
1919
internal static readonly int CullModeForwardID = Shader.PropertyToID("_CullModeForward");
2020
internal static readonly int DiffusionProfileAssetID = Shader.PropertyToID("_Diffusion_Profile_Asset");
2121
internal static readonly int DiffusionProfileID = Shader.PropertyToID("_Diffusion_Profile");
22+
internal static readonly int BillboardToggleID = Shader.PropertyToID("_BillboardKwToggle");
2223

2324
internal static readonly string WindShared = "_WIND_SHARED";
2425
internal static readonly string WindBranch2 = "_WIND_BRANCH2";
@@ -53,10 +54,12 @@ private static void HDSpeedTree9MaterialFinalizer(Material mat)
5354

5455
private static void SetupHDPropertiesOnImport(Material mat)
5556
{
56-
// Since _DoubleSidedEnable controls _CullMode in HD,
57-
// disable it for billboard LOD.
58-
float doubleSided = mat.GetInt(HDProperties.ExtraMapKwToggleID) > 0 ? 0.0f : 1.0f;
59-
mat.SetFloat(HDProperties.DoubleSidedEnableID, doubleSided);
57+
// Since _DoubleSidedEnable controls _CullMode in HD, disable it for billboard LOD.
58+
if (mat.HasFloat(HDProperties.BillboardToggleID))
59+
{
60+
var isBillboard = mat.GetFloat(HDProperties.BillboardToggleID) == 1.0f;
61+
mat.SetFloat(HDProperties.DoubleSidedEnableID, (isBillboard) ? 0.0f : 1.0f);
62+
}
6063

6164
if (mat.HasFloat(HDProperties.TwoSidedID))
6265
{

0 commit comments

Comments
 (0)