Class HDMaterial
Utility class for setting properties, keywords and passes on a material to ensure it is in a valid state for rendering with HDRP.
Inherited Members
Namespace: UnityEngine .Rendering.HighDefinition
Assembly: Unity.RenderPipelines.HighDefinition.Runtime.dll
Syntax
public static class HDMaterial
Methods
GetDiffusionProfile(Material)
Get the Diffusion profile on Lit shaders.
Declaration
public static DiffusionProfileSettings GetDiffusionProfile(Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to access. |
Returns
Type | Description |
---|---|
Diffusion |
The Diffusion Profile Asset. |
GetDiffusionProfileShaderGraph(Material, string)
Get the Diffusion profile on a Shader Graph material.
Declaration
public static DiffusionProfileSettings GetDiffusionProfileShaderGraph(Material material, string referenceName)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to access. |
string | referenceName | The reference name of the Diffusion Profile property in the Shader Graph. |
Returns
Type | Description |
---|---|
Diffusion |
The Diffusion Profile Asset. |
GetMaterialType(Material)
Gets the "Material Type" of the material. Returns MaterialId.LitStandard in case the material doesn't have a Type.
Declaration
public static MaterialId GetMaterialType(this Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material used to get the type. |
Returns
Type | Description |
---|---|
Material |
The "Material Type" of the material if the value exists, MaterialId.LitStandard otherwise. |
GetUseEmissiveIntensity(Material)
Compares a material's color and intensity values to determine if they are different. Works with Lit, Unlit and Decal shaders.
Declaration
public static bool GetUseEmissiveIntensity(Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
Returns
Type | Description |
---|---|
bool | True if the material uses different color and intensity values. |
SetAlphaClipping(Material, bool)
Set Alpha Clipping on Lit and Unlit shaders.
Declaration
public static void SetAlphaClipping(Material material, bool value)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
bool | value | True to enable alpha clipping. |
SetAlphaCutoff(Material, float)
Set Alpha Cutoff on Lit and Unlit shaders.
Declaration
public static void SetAlphaCutoff(Material material, float cutoff)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
float | cutoff | The alpha cutoff value between 0 and 1. |
SetDiffusionProfile(Material, DiffusionProfileSettings)
Set the Diffusion profile on Lit shaders.
Declaration
public static void SetDiffusionProfile(Material material, DiffusionProfileSettings profile)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
Diffusion |
profile | The Diffusion Profile Asset. |
SetDiffusionProfileShaderGraph(Material, DiffusionProfileSettings, string)
Set a Diffusion profile on a Shader Graph material.
Declaration
public static void SetDiffusionProfileShaderGraph(Material material, DiffusionProfileSettings profile, string referenceName)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
Diffusion |
profile | The Diffusion Profile Asset. |
string | referenceName | The reference name of the Diffusion Profile property in the Shader Graph. |
SetEmissiveColor(Material, Color)
Set the Emissive Color on Lit, Unlit and Decal shaders.
Declaration
public static void SetEmissiveColor(Material material, Color value)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
Color | value | The emissive color. In LDR if the material uses a separate emissive intensity value, in HDR otherwise. |
SetEmissiveIntensity(Material, float, EmissiveIntensityUnit)
Set the Emissive Intensity on Lit, Unlit and Decal shaders. If the material doesn't use emissive intensity, this won't have any effect.
Declaration
public static void SetEmissiveIntensity(Material material, float intensity, EmissiveIntensityUnit unit)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
float | intensity | The emissive intensity. |
Emissive |
unit | The unit of the intensity parameter. |
SetMaterialType(Material, MaterialId)
Tries to set the "Material Type" property of the material. The function returns true if it have successfully updated the material type. The function can fail if the material doesn't have a _MaterialID property or if you're trying to set a type that wasn't exposed on the ShaderGraph shader of this material.
Declaration
public static bool SetMaterialType(this Material material, MaterialId type)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
Material |
type | The new "Material Type" value to set on the material. |
Returns
Type | Description |
---|---|
bool | True if the function has successfully changed the material. False otherwise. |
SetRenderingPass(Material, RenderingPass)
Set the Rendering Pass on Lit, Unlit and Shadergraph shaders.
Declaration
public static void SetRenderingPass(Material material, HDMaterial.RenderingPass value)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
HDMaterial.Rendering |
value | The rendering pass to set. |
SetSurfaceType(Material, bool)
Set the Surface Type of a HDRP material.
Declaration
public static void SetSurfaceType(Material material, bool transparent)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
bool | transparent | Controls if the material has an opaque or transparent Surface Type. |
SetUseEmissiveIntensity(Material, bool)
Set to true to use a separate LDR color and intensity value for the emission color. Compatible with Lit, Unlit and Decal shaders.
Declaration
public static void SetUseEmissiveIntensity(Material material, bool value)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to change. |
bool | value | True to use separate color and intensity values. |
ValidateMaterial(Material)
Setup properties, keywords and passes on a material to ensure it is in a valid state for rendering with HDRP. This function is only for materials using HDRP Shaders or ShaderGraphs.
Declaration
public static bool ValidateMaterial(Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The target material. |
Returns
Type | Description |
---|---|
bool | False if the material doesn't have an HDRP Shader. |