From 857b8ee80b06f21a1161110e0f6e6b14acf90bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 20 Oct 2020 16:47:06 +0200 Subject: [PATCH 1/5] Expose shader pass names API --- .../RenderPipeline/HDStringConstants.cs | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index 3f27d1a8e68..6dcd5b94cf1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -1,60 +1,101 @@ namespace UnityEngine.Rendering.HighDefinition { - static class HDShaderPassNames + /// Pass names and shader ids used in HDRP. these names can be used as filters when rendering objects in a custom pass or a DrawRenderers() call. + public static class HDShaderPassNames { // ShaderPass string - use to have consistent name through the code + /// Empty pass name. public static readonly string s_EmptyStr = ""; + /// Forward pass name. public static readonly string s_ForwardStr = "Forward"; + /// Depth Only pass name. public static readonly string s_DepthOnlyStr = "DepthOnly"; + /// Depth Forward Only pass name. public static readonly string s_DepthForwardOnlyStr = "DepthForwardOnly"; + /// Forward Only pass name. public static readonly string s_ForwardOnlyStr = "ForwardOnly"; + /// GBuffer pass name. public static readonly string s_GBufferStr = "GBuffer"; + /// GBuffer With Prepass pass name. public static readonly string s_GBufferWithPrepassStr = "GBufferWithPrepass"; + /// Legacy Unlit cross pipeline pass name. public static readonly string s_SRPDefaultUnlitStr = "SRPDefaultUnlit"; + /// Motion Vectors pass name. public static readonly string s_MotionVectorsStr = "MotionVectors"; + /// Distortion Vectors pass name. public static readonly string s_DistortionVectorsStr = "DistortionVectors"; + /// Transparent Depth Prepass pass name. public static readonly string s_TransparentDepthPrepassStr = "TransparentDepthPrepass"; + /// Transparent Backface pass name. public static readonly string s_TransparentBackfaceStr = "TransparentBackface"; + /// Transparent Depth Postpass pass name. public static readonly string s_TransparentDepthPostpassStr = "TransparentDepthPostpass"; + /// RayTracing Prepass pass name. public static readonly string s_RayTracingPrepassStr = "RayTracingPrepass"; + /// Visibility DXR pass name. public static readonly string s_RayTracingVisibilityStr = "VisibilityDXR"; + /// PathTracing DXR pass name. public static readonly string s_PathTracingDXRStr = "PathTracingDXR"; + /// META pass name. public static readonly string s_MetaStr = "META"; + /// Shadow Caster pass name. public static readonly string s_ShadowCasterStr = "ShadowCaster"; + /// FullScreen Debug pass name. public static readonly string s_FullScreenDebugStr = "FullScreenDebug"; + /// DBuffer Projector pass name. public static readonly string s_DBufferProjectorStr = DecalSystem.s_MaterialDecalPassNames[(int)DecalSystem.MaterialDecalPass.DBufferProjector]; + /// Decal Projector Forward Emissive pass name. public static readonly string s_DecalProjectorForwardEmissiveStr = DecalSystem.s_MaterialDecalPassNames[(int)DecalSystem.MaterialDecalPass.DecalProjectorForwardEmissive]; + /// DBuffer Mesh pass name. public static readonly string s_DBufferMeshStr = DecalSystem.s_MaterialDecalPassNames[(int)DecalSystem.MaterialDecalPass.DBufferMesh]; + /// Decal Mesh Forward Emissive pass name. public static readonly string s_DecalMeshForwardEmissiveStr = DecalSystem.s_MaterialDecalPassNames[(int)DecalSystem.MaterialDecalPass.DecalMeshForwardEmissive]; // ShaderPass name + /// Empty shader tag id. public static readonly ShaderTagId s_EmptyName = new ShaderTagId(s_EmptyStr); + /// Forward shader tag id. public static readonly ShaderTagId s_ForwardName = new ShaderTagId(s_ForwardStr); + /// Depth Only shader tag id. public static readonly ShaderTagId s_DepthOnlyName = new ShaderTagId(s_DepthOnlyStr); + /// Depth Forward Only shader tag id. public static readonly ShaderTagId s_DepthForwardOnlyName = new ShaderTagId(s_DepthForwardOnlyStr); + /// Forward Only shader tag id. public static readonly ShaderTagId s_ForwardOnlyName = new ShaderTagId(s_ForwardOnlyStr); + /// GBuffer shader tag id. public static readonly ShaderTagId s_GBufferName = new ShaderTagId(s_GBufferStr); + /// GBufferWithPrepass shader tag id. public static readonly ShaderTagId s_GBufferWithPrepassName = new ShaderTagId(s_GBufferWithPrepassStr); + /// Legacy Unlit cross pipeline shader tag id. public static readonly ShaderTagId s_SRPDefaultUnlitName = new ShaderTagId(s_SRPDefaultUnlitStr); + /// Motion Vectors shader tag id. public static readonly ShaderTagId s_MotionVectorsName = new ShaderTagId(s_MotionVectorsStr); + /// Distortion Vectors shader tag id. public static readonly ShaderTagId s_DistortionVectorsName = new ShaderTagId(s_DistortionVectorsStr); + /// Transparent Depth Prepass shader tag id. public static readonly ShaderTagId s_TransparentDepthPrepassName = new ShaderTagId(s_TransparentDepthPrepassStr); + /// Transparent Backface shader tag id. public static readonly ShaderTagId s_TransparentBackfaceName = new ShaderTagId(s_TransparentBackfaceStr); + /// Transparent Depth Postpass shader tag id. public static readonly ShaderTagId s_TransparentDepthPostpassName = new ShaderTagId(s_TransparentDepthPostpassStr); + /// RayTracing Prepass shader tag id. public static readonly ShaderTagId s_RayTracingPrepassName = new ShaderTagId(s_RayTracingPrepassStr); + /// FullScreen Debug shader tag id. public static readonly ShaderTagId s_FullScreenDebugName = new ShaderTagId(s_FullScreenDebugStr); + /// DBuffer Mesh shader tag id. public static readonly ShaderTagId s_DBufferMeshName = new ShaderTagId(s_DBufferMeshStr); + /// Decal Mesh Forward Emissive shader tag id. public static readonly ShaderTagId s_DecalMeshForwardEmissiveName = new ShaderTagId(s_DecalMeshForwardEmissiveStr); // Legacy name - public static readonly ShaderTagId s_AlwaysName = new ShaderTagId("Always"); - public static readonly ShaderTagId s_ForwardBaseName = new ShaderTagId("ForwardBase"); - public static readonly ShaderTagId s_DeferredName = new ShaderTagId("Deferred"); - public static readonly ShaderTagId s_PrepassBaseName = new ShaderTagId("PrepassBase"); - public static readonly ShaderTagId s_VertexName = new ShaderTagId("Vertex"); - public static readonly ShaderTagId s_VertexLMRGBMName = new ShaderTagId("VertexLMRGBM"); - public static readonly ShaderTagId s_VertexLMName = new ShaderTagId("VertexLM"); + internal static readonly ShaderTagId s_AlwaysName = new ShaderTagId("Always"); + internal static readonly ShaderTagId s_ForwardBaseName = new ShaderTagId("ForwardBase"); + internal static readonly ShaderTagId s_DeferredName = new ShaderTagId("Deferred"); + internal static readonly ShaderTagId s_PrepassBaseName = new ShaderTagId("PrepassBase"); + internal static readonly ShaderTagId s_VertexName = new ShaderTagId("Vertex"); + internal static readonly ShaderTagId s_VertexLMRGBMName = new ShaderTagId("VertexLMRGBM"); + internal static readonly ShaderTagId s_VertexLMName = new ShaderTagId("VertexLM"); } // Pre-hashed shader ids - naming conventions are a bit off in this file as we use the same From 342ae2a9392d3581f0ffd907f7f958904bf2acd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 20 Oct 2020 16:48:43 +0200 Subject: [PATCH 2/5] Updated changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 8e5c062dff2..8488dd9b45b 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +### Unreleased + +### Added +- Exposed the API to access HDRP shader pass names. + ## [10.2.0] - 2020-10-19 ### Added From 950aea79024c220b2175c69546947f03b59b307a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 20 Oct 2020 17:45:48 +0200 Subject: [PATCH 3/5] exposed per object data in HDUtils --- .../Runtime/RenderPipeline/Utility/HDUtils.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index 499584b578e..cc2e725a3d9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -15,8 +15,10 @@ namespace UnityEngine.Rendering.HighDefinition /// public class HDUtils { - internal const PerObjectData k_RendererConfigurationBakedLighting = PerObjectData.LightProbe | PerObjectData.Lightmaps | PerObjectData.LightProbeProxyVolume; - internal const PerObjectData k_RendererConfigurationBakedLightingWithShadowMask = k_RendererConfigurationBakedLighting | PerObjectData.OcclusionProbe | PerObjectData.OcclusionProbeProxyVolume | PerObjectData.ShadowMask; + /// Render configuration for baked static lighting, this value can be used in a RendererListDesc call to render Lit objects. + public const PerObjectData k_RendererConfigurationBakedLighting = PerObjectData.LightProbe | PerObjectData.Lightmaps | PerObjectData.LightProbeProxyVolume; + /// Render configuration for baked static lighting with shadow masks, this value can be used in a RendererListDesc call to render Lit objects when shadow masks are enabled. + public const PerObjectData k_RendererConfigurationBakedLightingWithShadowMask = k_RendererConfigurationBakedLighting | PerObjectData.OcclusionProbe | PerObjectData.OcclusionProbeProxyVolume | PerObjectData.ShadowMask; /// Default HDAdditionalReflectionData static internal HDAdditionalReflectionData s_DefaultHDAdditionalReflectionData { get { return ComponentSingleton.instance; } } From 0c0c1ad83172a9c56929208683848c5f5e1c1d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Fri, 23 Oct 2020 12:11:31 +0200 Subject: [PATCH 4/5] changed constants to accessors --- .../RenderPass/DrawRenderersCustomPass.cs | 2 +- .../Runtime/RenderPipeline/Utility/HDUtils.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/DrawRenderersCustomPass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/DrawRenderersCustomPass.cs index 34ce91f8008..8aff33e8dd5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/DrawRenderersCustomPass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/DrawRenderersCustomPass.cs @@ -154,7 +154,7 @@ protected override void Execute(CustomPassContext ctx) stencilState = new StencilState(false), }; - PerObjectData renderConfig = ctx.hdCamera.frameSettings.IsEnabled(FrameSettingsField.Shadowmask) ? HDUtils.k_RendererConfigurationBakedLightingWithShadowMask : HDUtils.k_RendererConfigurationBakedLighting; + PerObjectData renderConfig = ctx.hdCamera.frameSettings.IsEnabled(FrameSettingsField.Shadowmask) ? HDUtils.GetBakedLightingWithShadowMaskRenderConfig() : HDUtils.GetBakedLightingRenderConfig(); var result = new RendererListDesc(shaderPasses, ctx.cullingResults, ctx.hdCamera.camera) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index cc2e725a3d9..ddd282fc070 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -15,10 +15,13 @@ namespace UnityEngine.Rendering.HighDefinition /// public class HDUtils { - /// Render configuration for baked static lighting, this value can be used in a RendererListDesc call to render Lit objects. - public const PerObjectData k_RendererConfigurationBakedLighting = PerObjectData.LightProbe | PerObjectData.Lightmaps | PerObjectData.LightProbeProxyVolume; - /// Render configuration for baked static lighting with shadow masks, this value can be used in a RendererListDesc call to render Lit objects when shadow masks are enabled. - public const PerObjectData k_RendererConfigurationBakedLightingWithShadowMask = k_RendererConfigurationBakedLighting | PerObjectData.OcclusionProbe | PerObjectData.OcclusionProbeProxyVolume | PerObjectData.ShadowMask; + internal const PerObjectData k_RendererConfigurationBakedLighting = PerObjectData.LightProbe | PerObjectData.Lightmaps | PerObjectData.LightProbeProxyVolume; + internal const PerObjectData k_RendererConfigurationBakedLightingWithShadowMask = k_RendererConfigurationBakedLighting | PerObjectData.OcclusionProbe | PerObjectData.OcclusionProbeProxyVolume | PerObjectData.ShadowMask; + + /// Returns the render configuration for baked static lighting, this value can be used in a RendererListDesc call to render Lit objects. + public PerObjectData GetBakedLightingRenderConfig() => k_RendererConfigurationBakedLighting; + /// Returns the render configuration for baked static lighting with shadow masks, this value can be used in a RendererListDesc call to render Lit objects when shadow masks are enabled. + public PerObjectData GetBakedLightingWithShadowMaskRenderConfig() => k_RendererConfigurationBakedLightingWithShadowMask; /// Default HDAdditionalReflectionData static internal HDAdditionalReflectionData s_DefaultHDAdditionalReflectionData { get { return ComponentSingleton.instance; } } From ea7b8bafde502931e2b7d91c96807cfdc42c673b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Fri, 23 Oct 2020 12:14:35 +0200 Subject: [PATCH 5/5] Moved getters to static --- .../Runtime/RenderPipeline/Utility/HDUtils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index ddd282fc070..f2e13fdbb4e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -19,9 +19,9 @@ public class HDUtils internal const PerObjectData k_RendererConfigurationBakedLightingWithShadowMask = k_RendererConfigurationBakedLighting | PerObjectData.OcclusionProbe | PerObjectData.OcclusionProbeProxyVolume | PerObjectData.ShadowMask; /// Returns the render configuration for baked static lighting, this value can be used in a RendererListDesc call to render Lit objects. - public PerObjectData GetBakedLightingRenderConfig() => k_RendererConfigurationBakedLighting; + public static PerObjectData GetBakedLightingRenderConfig() => k_RendererConfigurationBakedLighting; /// Returns the render configuration for baked static lighting with shadow masks, this value can be used in a RendererListDesc call to render Lit objects when shadow masks are enabled. - public PerObjectData GetBakedLightingWithShadowMaskRenderConfig() => k_RendererConfigurationBakedLightingWithShadowMask; + public static PerObjectData GetBakedLightingWithShadowMaskRenderConfig() => k_RendererConfigurationBakedLightingWithShadowMask; /// Default HDAdditionalReflectionData static internal HDAdditionalReflectionData s_DefaultHDAdditionalReflectionData { get { return ComponentSingleton.instance; } }