using System; namespace UnityEngine.Rendering.Universal { /// /// A resource container for shaders used for terrains in . /// /// /// You cannot edit these resources through the editor's UI; use the API for advanced changes. /// Changing this through the API is only allowed in the Editor. In the Player, this raises an error. /// /// /// /// Here is an example of how to get the terrain detail lit shader used by URP. /// /// using UnityEngine.Rendering; /// using UnityEngine.Rendering.Universal; /// /// public static class URPUniversalRendererRuntimeShadersHelper /// { /// public static Shader terrainDetailLit /// { /// get /// { /// if (GraphicsSettings.TryGetRenderPipelineSettings<UniversalRenderPipelineRuntimeTerrainShaders>( /// out var shadersResources)) /// { /// return shadersResources.terrainDetailLitShader; /// } /// return null; /// } /// } /// } /// /// [Serializable] [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] [Categorization.CategoryInfo(Name = "R: Runtime Shaders", Order = 1000), HideInInspector] public class UniversalRenderPipelineRuntimeTerrainShaders : IRenderPipelineResources { [SerializeField][HideInInspector] private int m_Version = 0; /// The current version of the resource container. Used only for upgrading a project. public int version => m_Version; bool IRenderPipelineGraphicsSettings.isAvailableInPlayerBuild { get { // Check if the setting exists and is enabled if (GraphicsSettings.TryGetRenderPipelineSettings(out var settings)) { return settings.includeTerrainShaders; } return false; // Default to not including if settings don't exist } } [SerializeField] [ResourcePath("Shaders/Terrain/TerrainDetailLit.shader")] private Shader m_TerrainDetailLit; /// /// Returns the terrain detail lit shader that this asset uses. /// public Shader terrainDetailLitShader { get => m_TerrainDetailLit; set => this.SetValueAndNotify(ref m_TerrainDetailLit, value); } [SerializeField] [ResourcePath("Shaders/Terrain/WavingGrassBillboard.shader")] private Shader m_TerrainDetailGrassBillboard; /// /// Returns the terrain detail grass billboard shader that this asset uses. /// public Shader terrainDetailGrassBillboardShader { get => m_TerrainDetailGrassBillboard; set => this.SetValueAndNotify(ref m_TerrainDetailGrassBillboard, value); } [SerializeField] [ResourcePath("Shaders/Terrain/WavingGrass.shader")] private Shader m_TerrainDetailGrass; /// /// Returns the terrain detail grass shader that this asset uses. /// public Shader terrainDetailGrassShader { get => m_TerrainDetailGrass; set => this.SetValueAndNotify(ref m_TerrainDetailGrass, value); } } }