From ca741d8cd710db5db9905bb0dcf77d13fe05eda8 Mon Sep 17 00:00:00 2001 From: emilybrown1 Date: Thu, 27 Jan 2022 11:41:34 +0000 Subject: [PATCH] Fixed missing capital and UI bolding --- .../Documentation~/Material-API.md | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Material-API.md b/com.unity.render-pipelines.high-definition/Documentation~/Material-API.md index 275fe90f993..54629cdbfbc 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Material-API.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Material-API.md @@ -1,26 +1,27 @@ # Material Scripting API -Most HDRP shaders allow enabling and disabling functionalities through the use of Shader keywords. +Most HDRP shaders allow you to enable and disable functionalities through the use of Shader keywords. -For example, on the HDRP Lit Shader, normal mapping code is stripped from materials that do not use a normal map. Since these materials don’t include the code for normal mapping, they are faster to run, and to compile. -Enabling the keyword for normal mapping is done automatically when activated through the material Inspector, but needs to be done explicitely from a script. +For example, on the HDRP Lit Shader, normal mapping code is stripped from Materials that don't use a normal map. These Materials don’t include the code for normal mapping, so they're faster to run and compile. The keyword for normal mapping is activated automatically when you use the Material Inspector, but you need to do it explicitly when you use a script. You can find more information about Material parameters in Unity in the [Material section](https://docs.unity3d.com/Manual/MaterialsAccessingViaScript.html) of the Unity Manual. Information about shader variants, shader keywords and access in standalone builds can be found [here](https://docs.unity3d.com/Manual/shader-variants-and-keywords.html). -## Modifying HDRP materials in scripts +## Modifying HDRP Materials in scripts -When you change a Material’s properties in the Inspector, HDRP sets up properties, keywords and passes on the Material to make sure HDRP can render it correctly.This is called a validation step. -When you use a script to change a Material’s properties, HDRP does not perform this step automatically. This means you must validate that Material manually. +When you change a Material’s properties in the Inspector, HDRP sets up properties, keywords, and passes on the Material to make sure HDRP can render it correctly. This is called a validation step. +When you use a script to change a Material’s properties, HDRP doesn't perform this step automatically. This means you must validate that Material manually. ### Validating a Material in HDRP To validate a Material In HDRP, use the function `ValidateMaterial` to force HDRP to perform a validation step on any Material made from an HDRP Shader or a ShaderGraph that has a HDRP Target. + The following example script: + * Creates a Material with the [HDRP/Lit](Lit-Shader.md) shader, * Enables Alpha Clipping and sets its cutoff value to `0.2`, * Uses the `ValidateMaterial` function to enable the Alpha Clipping keywords on the Material. -```csharp +```C# using UnityEngine.Rendering.HighDefinition; public class CreateCutoutMaterial : MonoBehaviour @@ -38,20 +39,22 @@ public class CreateCutoutMaterial : MonoBehaviour ### HDRP Material API -However, some properties of HDRP shaders are not independent, and they require changes to other properties or keywords in order to have any effect. +Some properties of HDRP shaders aren't independent, and they require changes to other properties or keywords to have any effect. To help modify these properties, HDRP provides a set of functions that will take care of setting all the required states. You can find a list of available methods in the [Scripting API](.../api/UnityEngine.Rendering.HighDefinition.HDMaterial.html). Please refer to the documentation to know with which shaders the methods are compatible. -The below example script: +The example script below: + * Creates a Material with the HDRP/Lit shader, * Enables Alpha Clipping and sets its cutoff value to `0.2`. Keywords are automatically set appropriately. To do this, it uses the following helper functions: + * material.SetAlphaClipping * material.SetAlphaCutoff -```csharp +```C# using UnityEngine.Rendering.HighDefinition; public class CreateCutoutMaterial : MonoBehaviour @@ -67,12 +70,13 @@ public class CreateCutoutMaterial : MonoBehaviour ## Making shader variants available at runtime -Unity uses the set of keywords enabled on a Material to determine which Shader Variant to use. When you build a project, only the Shader Variants currently in use by the materials of the project will be included in the build. -Because Shader Variants have to be compiled at project build time, changing keywords on a material at runtime can require using a Variant that has not been built. +Unity uses the set of keywords enabled on a Material to determine which Shader Variant to use. When you build a project, Unity only includes the Shader Variants in the build that the Materials of the project are currently using. +Because Unity has to compile Shader Variants at build time, changing keywords on a Material at runtime can require using a Variant that Unity hasn't built. To make all Shader Variants you need available at runtime, you need to ensure Unity knows that you need them. There are several ways to do that: -1. You can record the shader variants used during a play session and store them in a **Shader Variant Collection** asset. To do that, navigate to the Project Settings window, open the Graphics tab and select Save to asset… This will build a collection containing all Shader Variants currently in use and save them out as an asset. You must then add this asset to the list of Preloaded Shaders for the variants to be included in a build. + +1. You can record the shader variants used during a play session and store them in a **Shader Variant Collection** asset. To do that, navigate to the Project Settings window, open the Graphics tab and select **Save to asset…** This will build a collection containing all Shader Variants currently in use and save them out as an asset. You must then add this asset to the list of Preloaded Shaders for the variants to be included in a build. ![](Images/shader-variants.png) -2. You can include at least one Material using each variant in your Assets folder. This Material must be used in a scene or be placed in your Resources Folder, otherwise Unity ignores this Material when it builds the project. +2. You can include at least one Material using each variant in your Assets folder. You must use this Material in a scene or place it in your Resources Folder, otherwise Unity ignores this Material when it builds the project.