From 7ba28669cf28681148d60bfd7a20575a74c5356c Mon Sep 17 00:00:00 2001 From: Thomasch-unity3d <30902625+Thomasch-unity3d@users.noreply.github.com> Date: Thu, 4 Jun 2020 06:45:06 -0400 Subject: [PATCH 1/8] Handling 3dsMax's Simplified Physical Material import. (#569) --- .../CHANGELOG.md | 1 + .../PhysicalMaterial3DsMaxPreprocessor.cs | 130 ++++++++++++++++++ .../CHANGELOG.md | 1 + .../PhysicalMaterial3DsMaxPreprocessor.cs | 130 ++++++++++++++++++ 4 files changed, 262 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 71678c9c8b6..6feeab0ea0d 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -130,6 +130,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added Histogram guided automatic exposure. - Added few exposure debug modes. - Added support for multiple path-traced views at once (e.g., scene and game views). +- Added support for 3DsMax's 2021 Simplified Physical Material from FBX files in the Model Importer. ### Fixed - Fix when rescale probe all direction below zero (1219246) diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/PhysicalMaterial3DsMaxPreprocessor.cs b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/PhysicalMaterial3DsMaxPreprocessor.cs index 6a9aba49cfb..ab3c8643b60 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/PhysicalMaterial3DsMaxPreprocessor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/PhysicalMaterial3DsMaxPreprocessor.cs @@ -1,6 +1,7 @@ using UnityEditor.AssetImporters; using UnityEngine; using UnityEditor.Experimental.AssetImporters; +using UnityEngine.Rendering; namespace UnityEditor.Rendering.HighDefinition { @@ -29,12 +30,141 @@ static bool Is3DsMaxPhysicalMaterial(MaterialDescription description) return classIdA == 1030429932 && classIdB == -559038463; } + static bool Is3DsMaxSimplifiedPhysicalMaterial(MaterialDescription description) + { + float classIdA; + float classIdB; + float useGlossiness; + description.TryGetProperty("ClassIDa", out classIdA); + description.TryGetProperty("ClassIDb", out classIdB); + description.TryGetProperty("useGlossiness", out useGlossiness); + + return classIdA == -804315648 && classIdB == -1099438848 && useGlossiness == 2.0f; + } + public void OnPreprocessMaterialDescription(MaterialDescription description, Material material, AnimationClip[] clips) { if (Is3DsMaxPhysicalMaterial(description)) { CreateFrom3DsPhysicalMaterial(description, material, clips); } + else if (Is3DsMaxSimplifiedPhysicalMaterial(description)) + { + CreateFrom3DsSimplifiedPhysicalMaterial(description, material, clips); + } + } + + void CreateFrom3DsSimplifiedPhysicalMaterial(MaterialDescription description, Material material, AnimationClip[] clips) + { + float floatProperty; + Vector4 vectorProperty; + TexturePropertyDescription textureProperty; + + description.TryGetProperty("basecolor", out vectorProperty); + bool hasTransparencyScalar = vectorProperty.w != 1.0f; + var hasTransparencyMap = description.TryGetProperty("opacity_map", out textureProperty); + bool isTransparent = hasTransparencyMap | hasTransparencyScalar; + + + Shader shader; + if (isTransparent) + shader = GraphicsSettings.currentRenderPipeline.autodeskInteractiveTransparentShader; + else + shader = GraphicsSettings.currentRenderPipeline.autodeskInteractiveShader; + + if (shader == null) + return; + + material.shader = shader; + foreach (var clip in clips) + { + clip.ClearCurves(); + } + + if (hasTransparencyMap) + { + material.SetFloat("_UseOpacityMap", 1.0f); + material.SetTexture("_OpacityMap", textureProperty.texture); + } + else if (hasTransparencyScalar) + { + material.SetFloat("_Opacity", vectorProperty.w); + } + + if (description.TryGetProperty("basecolor", out vectorProperty)) + material.SetColor("_Color", vectorProperty); + + if (description.TryGetProperty("emit_color", out vectorProperty)) + material.SetColor("_EmissionColor", vectorProperty); + + if (description.TryGetProperty("roughness", out floatProperty)) + material.SetFloat("_Glossiness", floatProperty); + + if (description.TryGetProperty("metalness", out floatProperty)) + material.SetFloat("_Metallic", floatProperty); + + if (description.TryGetProperty("base_color_map", out textureProperty)) + { + material.SetTexture("_MainTex", textureProperty.texture); + material.SetFloat("_UseColorMap", 1.0f); + material.SetColor("_UvTiling", new Vector4(textureProperty.scale.x, textureProperty.scale.y, 0.0f, 0.0f)); + material.SetColor("_UvOffset", new Vector4(textureProperty.offset.x, textureProperty.offset.y, 0.0f, 0.0f)); + } + else + { + material.SetFloat("_UseColorMap", 0.0f); + } + + if (description.TryGetProperty("norm_map", out textureProperty)) + { + material.SetTexture("_BumpMap", textureProperty.texture); + material.SetFloat("_UseNormalMap", 1.0f); + } + else + { + material.SetFloat("_UseNormalMap", 0.0f); + } + + if (description.TryGetProperty("roughness_map", out textureProperty)) + { + material.SetTexture("_SpecGlossMap", textureProperty.texture); + material.SetFloat("_UseRoughnessMap", 1.0f); + } + else + { + material.SetFloat("_UseRoughnessMap", 0.0f); + } + + if (description.TryGetProperty("metalness_map", out textureProperty)) + { + material.SetTexture("_MetallicGlossMap", textureProperty.texture); + material.SetFloat("_UseMetallicMap", 1.0f); + } + else + { + material.SetFloat("_UseMetallicMap", 0.0f); + } + + if (description.TryGetProperty("emit_color_map", out textureProperty)) + { + material.SetTexture("_EmissionMap", textureProperty.texture); + material.SetFloat("_UseEmissiveMap", 1.0f); + } + else + { + material.SetFloat("_UseEmissiveMap", 0.0f); + } + + if (description.TryGetProperty("ao_map", out textureProperty)) + { + var tex = AssetDatabase.LoadAssetAtPath(textureProperty.relativePath); + material.SetTexture("AoMap", tex); + material.SetFloat("UseAoMap", 1.0f); + } + else + { + material.SetFloat("UseAoMap", 0.0f); + } } void CreateFrom3DsPhysicalMaterial(MaterialDescription description, Material material, AnimationClip[] clips) diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 31714ed34e5..a94f45351ad 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added Default Material Type options to the 2D Renderer Data Asset property settings. - Added additional steps to the 2D Renderer setup page for quality and platform settings. - Added option to disable XR autotests on test settings. +- Added support for 3DsMax's 2021 Simplified Physical Material from FBX files in the Model Importer. ### Changed diff --git a/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/PhysicalMaterial3DsMaxPreprocessor.cs b/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/PhysicalMaterial3DsMaxPreprocessor.cs index c6b5dfd1668..2f2b9028419 100644 --- a/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/PhysicalMaterial3DsMaxPreprocessor.cs +++ b/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/PhysicalMaterial3DsMaxPreprocessor.cs @@ -1,6 +1,7 @@ using UnityEditor.AssetImporters; using UnityEditor.Experimental; using UnityEngine; +using UnityEngine.Rendering; using UnityEditor.Experimental.AssetImporters; namespace UnityEditor.Rendering.Universal @@ -31,12 +32,141 @@ static bool Is3DsMaxPhysicalMaterial(MaterialDescription description) return classIdA == 1030429932 && classIdB == -559038463; } + static bool Is3DsMaxSimplifiedPhysicalMaterial(MaterialDescription description) + { + float classIdA; + float classIdB; + float useGlossiness; + description.TryGetProperty("ClassIDa", out classIdA); + description.TryGetProperty("ClassIDb", out classIdB); + description.TryGetProperty("useGlossiness", out useGlossiness); + + return classIdA == -804315648 && classIdB == -1099438848 && useGlossiness == 2.0f; + } + public void OnPreprocessMaterialDescription(MaterialDescription description, Material material, AnimationClip[] clips) { if (Is3DsMaxPhysicalMaterial(description)) { CreateFrom3DsPhysicalMaterial(description, material, clips); } + else if (Is3DsMaxSimplifiedPhysicalMaterial(description)) + { + CreateFrom3DsSimplifiedPhysicalMaterial(description, material, clips); + } + } + + void CreateFrom3DsSimplifiedPhysicalMaterial(MaterialDescription description, Material material, AnimationClip[] clips) + { + float floatProperty; + Vector4 vectorProperty; + TexturePropertyDescription textureProperty; + + description.TryGetProperty("basecolor", out vectorProperty); + bool hasTransparencyScalar = vectorProperty.w !=1.0f; + var hasTransparencyMap = description.TryGetProperty("opacity_map", out textureProperty); + bool isTransparent = hasTransparencyMap | hasTransparencyScalar; + + + Shader shader; + if (isTransparent) + shader = GraphicsSettings.currentRenderPipeline.autodeskInteractiveTransparentShader; + else + shader = GraphicsSettings.currentRenderPipeline.autodeskInteractiveShader; + + if (shader == null) + return; + + material.shader = shader; + foreach (var clip in clips) + { + clip.ClearCurves(); + } + + if (hasTransparencyMap) + { + material.SetFloat("_UseOpacityMap", 1.0f); + material.SetTexture("_OpacityMap", textureProperty.texture); + } + else if (hasTransparencyScalar) + { + material.SetFloat("_Opacity", vectorProperty.w); + } + + if (description.TryGetProperty("basecolor", out vectorProperty)) + material.SetColor("_Color", vectorProperty); + + if (description.TryGetProperty("emit_color", out vectorProperty)) + material.SetColor("_EmissionColor", vectorProperty); + + if (description.TryGetProperty("roughness", out floatProperty)) + material.SetFloat("_Glossiness", floatProperty); + + if (description.TryGetProperty("metalness", out floatProperty)) + material.SetFloat("_Metallic", floatProperty); + + if (description.TryGetProperty("base_color_map", out textureProperty)) + { + material.SetTexture("_MainTex", textureProperty.texture); + material.SetFloat("_UseColorMap", 1.0f); + material.SetColor("_UvTiling", new Vector4(textureProperty.scale.x, textureProperty.scale.y, 0.0f, 0.0f)); + material.SetColor("_UvOffset", new Vector4(textureProperty.offset.x, textureProperty.offset.y, 0.0f, 0.0f)); + } + else + { + material.SetFloat("_UseColorMap", 0.0f); + } + + if (description.TryGetProperty("norm_map", out textureProperty)) + { + material.SetTexture("_BumpMap", textureProperty.texture); + material.SetFloat("_UseNormalMap", 1.0f); + } + else + { + material.SetFloat("_UseNormalMap", 0.0f); + } + + if (description.TryGetProperty("roughness_map", out textureProperty)) + { + material.SetTexture("_SpecGlossMap", textureProperty.texture); + material.SetFloat("_UseRoughnessMap", 1.0f); + } + else + { + material.SetFloat("_UseRoughnessMap", 0.0f); + } + + if (description.TryGetProperty("metalness_map", out textureProperty)) + { + material.SetTexture("_MetallicGlossMap", textureProperty.texture); + material.SetFloat("_UseMetallicMap", 1.0f); + } + else + { + material.SetFloat("_UseMetallicMap", 0.0f); + } + + if (description.TryGetProperty("emit_color_map", out textureProperty)) + { + material.SetTexture("_EmissionMap", textureProperty.texture); + material.SetFloat("_UseEmissiveMap", 1.0f); + } + else + { + material.SetFloat("_UseEmissiveMap", 0.0f); + } + + if (description.TryGetProperty("ao_map", out textureProperty)) + { + var tex = AssetDatabase.LoadAssetAtPath(textureProperty.relativePath); + material.SetTexture("AoMap", tex); + material.SetFloat("UseAoMap", 1.0f); + } + else + { + material.SetFloat("UseAoMap", 0.0f); + } } void CreateFrom3DsPhysicalMaterial(MaterialDescription description, Material material, AnimationClip[] clips) From 9794586ee3f9bffdef4b4649eb432830056fa3b7 Mon Sep 17 00:00:00 2001 From: NicoLeyman <49522355+NicoLeyman@users.noreply.github.com> Date: Thu, 4 Jun 2020 22:20:34 +0200 Subject: [PATCH 2/8] [Skip CI] Virtual Texturing cache settings (#536) --- .../CHANGELOG.md | 1 + .../Documentation~/HDRP-Asset.md | 7 + .../RenderPipeline/HDRenderPipelineUI.Skin.cs | 2 +- .../RenderPipeline/HDRenderPipelineUI.cs | 10 +- .../SerializedHDRenderPipelineAsset.cs | 3 + .../SerializedVirtualTexturingSettings.cs | 20 ++ ...SerializedVirtualTexturingSettings.cs.meta | 11 + .../VirtualTexturingSettingsUI.cs | 282 ++++++++++++++++++ .../VirtualTexturingSettingsUI.cs.meta | 11 + .../RenderPipeline/HDRenderPipeline.cs | 22 ++ .../RenderPipeline/HDRenderPipelineAsset.cs | 3 + .../VirtualTexturingSettingsSRP.cs | 30 ++ .../VirtualTexturingSettingsSRP.cs.meta | 11 + 13 files changed, 411 insertions(+), 2 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs create mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs create mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs create mode 100644 com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6feeab0ea0d..4a4de6e3ed4 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -131,6 +131,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added few exposure debug modes. - Added support for multiple path-traced views at once (e.g., scene and game views). - Added support for 3DsMax's 2021 Simplified Physical Material from FBX files in the Model Importer. +- Added Virtual Texturing cache settings to control the size of the Streaming Virtual Texturing caches. ### Fixed - Fix when rescale probe all direction below zero (1219246) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md index 73ff57b6263..2933603e2c7 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md @@ -218,3 +218,10 @@ Use these settings to enable or disable settings relating to lighting in HDRP. | **Grading LUT Size** | The size of the internal and external color grading lookup textures (LUTs). This size is fixed for the Project. You can not mix and match LUT sizes, so decide on a size before you start the color grading process. The default value, **32**, provides a good balance of speed and quality. | | **Grading LUT Format** | Use the drop-down to select the format to encode the color grading LUTs with. Lower precision formats are faster and use less memory at the expense of color precision. These formats directly map to their equivalent in the built-in [GraphicsFormat](https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html) enum value. | | **Buffer Format** | Use the drop-down to select the format of the color buffers that are used in the post-processing passes. Lower precision formats are faster and use less memory at the expense of color precision. These formats directly map to their equivalent in the built-in [GraphicsFormat](https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html) enum value. + +## Virtual Texturing + +| **Property** | **Description** | +| ----------------------- | --------------------------------------------------------------- | +| **CPU Cache Size** | Amount of CPU memory (in MB) that can be allocated by the Streaming Virtual Texturing system to cache texture data. | +| **GPU Cache Size per Format** | Amount of GPU memory (in MB) that can be allocated per format by the Streaming Virtual Texturing system to cache texture data. The value assigned to None is used for all unspecified formats. | diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index bf7f0ccc463..a78024c06b3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -23,7 +23,7 @@ public class GeneralSection public static readonly GUIContent materialSectionTitle = EditorGUIUtility.TrTextContent("Material"); public static readonly GUIContent postProcessSectionTitle = EditorGUIUtility.TrTextContent("Post-processing"); public static readonly GUIContent xrTitle = EditorGUIUtility.TrTextContent("XR"); - public static readonly GUIContent virtualTexturingTitle = EditorGUIUtility.TrTextContent("Virtual Texturing"); + public static readonly GUIContent virtualTexturingTitle = EditorGUIUtility.TrTextContent("Virtual Texturing", "Virtual Texturing Settings. These are only available when Virtual Texturing is enabled in the Player Settings."); public static readonly GUIContent lightLoopSubTitle = EditorGUIUtility.TrTextContent("Lights"); public static readonly GUIContent postProcessQualitySubTitle = EditorGUIUtility.TrTextContent("Post-processing Quality Settings"); public static readonly GUIContent lightingQualitySettings = EditorGUIUtility.TrTextContent("Lighting Quality Settings"); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index e7862542a9d..ad24fb02a96 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -68,6 +68,8 @@ internal enum SelectedFrameSettings internal static SelectedFrameSettings selectedFrameSettings; + internal static VirtualTexturingSettingsUI virtualTexturingSettingsUI = new VirtualTexturingSettingsUI(); + static HDRenderPipelineUI() { Inspector = CED.Group( @@ -99,7 +101,8 @@ static HDRenderPipelineUI() CED.FoldoutGroup(Styles.bloomQualitySettings, Expandable.BloomQuality, k_ExpandedState, FoldoutOption.Indent | FoldoutOption.SubFoldout | FoldoutOption.NoSpaceAtEnd, Drawer_SectionBloomQualitySettings), CED.FoldoutGroup(Styles.chromaticAberrationQualitySettings, Expandable.ChromaticAberrationQuality, k_ExpandedState, FoldoutOption.Indent | FoldoutOption.SubFoldout | FoldoutOption.NoSpaceAtEnd, Drawer_SectionChromaticAberrationQualitySettings) ), - CED.FoldoutGroup(Styles.xrTitle, Expandable.XR, k_ExpandedState, Drawer_SectionXRSettings) + CED.FoldoutGroup(Styles.xrTitle, Expandable.XR, k_ExpandedState, Drawer_SectionXRSettings), + CED.FoldoutGroup(Styles.virtualTexturingTitle, Expandable.VirtualTexturing, k_ExpandedState, Drawer_SectionVTSettings) ); // fix init of selection along what is serialized @@ -569,6 +572,11 @@ static void Drawer_SectionXRSettings(SerializedHDRenderPipelineAsset serialized, EditorGUILayout.PropertyField(serialized.renderPipelineSettings.xrSettings.cameraJitter, Styles.XRCameraJitter); } + static void Drawer_SectionVTSettings(SerializedHDRenderPipelineAsset serialized, Editor owner) + { + virtualTexturingSettingsUI.OnGUI(serialized, owner); + } + static private bool m_ShowDoFLowQualitySection = false; static private bool m_ShowDoFMediumQualitySection = false; static private bool m_ShowDoFHighQualitySection = false; diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs index 1f1572a90e6..e8b64eed36f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs @@ -20,6 +20,7 @@ class SerializedHDRenderPipelineAsset public SerializedFrameSettings defaultFrameSettings; public SerializedFrameSettings defaultBakedOrCustomReflectionFrameSettings; public SerializedFrameSettings defaultRealtimeReflectionFrameSettings; + public SerializedVirtualTexturingSettings virtualTexturingSettings; //RenderPipelineResources not always exist and thus cannot be serialized normally. public bool editorResourceHasMultipleDifferentValues @@ -63,6 +64,8 @@ public SerializedHDRenderPipelineAsset(SerializedObject serializedObject) defaultFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultCameraFrameSettings"), null); //no overrides in HDRPAsset defaultBakedOrCustomReflectionFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings"), null); //no overrides in HDRPAsset defaultRealtimeReflectionFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultRealtimeReflectionFrameSettings"), null); //no overrides in HDRPAsset + + virtualTexturingSettings = new SerializedVirtualTexturingSettings(serializedObject.FindProperty("virtualTexturingSettings")); } public void Update() diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs new file mode 100644 index 00000000000..b0233c3751b --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs @@ -0,0 +1,20 @@ +using UnityEditor.Rendering; +using UnityEngine.Rendering.HighDefinition; + +namespace UnityEditor.Rendering.HighDefinition +{ + public sealed class SerializedVirtualTexturingSettings + { + public SerializedProperty root; + + public SerializedProperty streamingCpuCacheSizeInMegaBytes; + public SerializedProperty streamingGpuCacheSettings; + public SerializedVirtualTexturingSettings(SerializedProperty root) + { + this.root = root; + + streamingCpuCacheSizeInMegaBytes = root.Find((VirtualTexturingSettingsSRP s) => s.streamingCpuCacheSizeInMegaBytes); + streamingGpuCacheSettings = root.Find((VirtualTexturingSettingsSRP s) => s.streamingGpuCacheSettings); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta new file mode 100644 index 00000000000..d2b9c82d69a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2b6b35c2a70589145b2353009c41ecf8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs new file mode 100644 index 00000000000..1fb12cef2aa --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering.VirtualTexturing; + +namespace UnityEditor.Rendering.HighDefinition +{ + class VirtualTexturingSettingsUI + { + private ReorderableList m_GPUCacheSizeOverrideListStreaming; + private SerializedProperty m_GPUCacheSizeOverridesPropertyStreaming; + + public SerializedObject serializedObject; + private SerializedHDRenderPipelineAsset serializedRPAsset; + + private const int CPUCacheSizeMinValue = 64; + private const int GPUCacheSizeMinValue = 32; + + public void OnGUI(SerializedHDRenderPipelineAsset serialized, Editor owner) + { + CheckStyles(); + + serializedObject = serialized.serializedObject; + serializedRPAsset = serialized; + + EditorGUILayout.Space(); + +#if !ENABLE_VIRTUALTEXTURES + EditorGUI.BeginDisabledGroup(true); +#endif + + using (var scope = new EditorGUI.ChangeCheckScope()) + { + serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue = Mathf.Max(CPUCacheSizeMinValue, EditorGUILayout.DelayedIntField(s_Styles.cpuCacheSize, serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue)); + + // GPU Cache size settings + if (m_GPUCacheSizeOverrideListStreaming == null || + m_GPUCacheSizeOverridesPropertyStreaming != serialized.virtualTexturingSettings.streamingGpuCacheSettings) + { + m_GPUCacheSizeOverridesPropertyStreaming = serialized.virtualTexturingSettings.streamingGpuCacheSettings; + m_GPUCacheSizeOverrideListStreaming = CreateGPUCacheSizeOverrideList(m_GPUCacheSizeOverridesPropertyStreaming, DrawStreamingOverrideElement); + } + + m_GPUCacheSizeOverrideListStreaming.DoLayoutList(); + } + +#if !ENABLE_VIRTUALTEXTURES + EditorGUI.EndDisabledGroup(); +#endif + + serialized.serializedObject.ApplyModifiedProperties(); + } + + GPUCacheSetting[] GetGPUCacheSizeOverrideArrayFromProperty(SerializedProperty property) + { + List settings = new List(); + for (int i = 0; i < property.arraySize; ++i) + { + SerializedProperty settingProperty = property.GetArrayElementAtIndex(i); + settings.Add(new GPUCacheSetting() + { format = (GraphicsFormat)settingProperty.FindPropertyRelative("format").intValue, sizeInMegaBytes = (uint)settingProperty.FindPropertyRelative("sizeInMegaBytes").intValue }); + } + + return settings.ToArray(); + } + + ReorderableList CreateGPUCacheSizeOverrideList(SerializedProperty property, ReorderableList.ElementCallbackDelegate drawCallback) + { + ReorderableList list = new ReorderableList(property.serializedObject, property); + + list.drawHeaderCallback = + (Rect rect) => + { + GUI.Label(rect, s_Styles.gpuCacheSize); + }; + + list.drawElementCallback = drawCallback; + + list.onAddCallback = (l) => + { + List availableFormats = new List(EditorHelpers.QuerySupportedFormats()); + + // We can't just pass in existing settings as a parameter to CreateGPUCacheSizeOverrideList() because lambdas can't capture ref params. + GPUCacheSetting[] existingSettings = GetGPUCacheSizeOverrideArrayFromProperty(serializedRPAsset.virtualTexturingSettings.streamingGpuCacheSettings); + RemoveOverriddenFormats(availableFormats, existingSettings); + + int index = property.arraySize; + property.InsertArrayElementAtIndex(index); + var newItemProperty = property.GetArrayElementAtIndex(index); + newItemProperty.FindPropertyRelative("format").intValue = availableFormats.Count > 0 ? (int)availableFormats[0] : 0; + newItemProperty.FindPropertyRelative("sizeInMegaBytes").intValue = 64; + }; + + return list; + } + + void GraphicsFormatToFormatAndChannelTransformString(GraphicsFormat graphicsFormat, out string format, out string channelTransform) + { + string formatString = graphicsFormat.ToString(); + int lastUnderscore = formatString.LastIndexOf('_'); + if (lastUnderscore < 0) + { + format = "None"; + channelTransform = "None"; + return; + } + format = formatString.Substring(0, lastUnderscore); + channelTransform = formatString.Substring(lastUnderscore + 1); + } + GraphicsFormat FormatAndChannelTransformStringToGraphicsFormat(string format, string channelTransform) + { + if (format == "None") return GraphicsFormat.None; + + return (GraphicsFormat)Enum.Parse(typeof(GraphicsFormat), $"{format}_{channelTransform}"); + } + + void RemoveOverriddenFormats(List formats, GPUCacheSetting[] settings) + { + foreach (var existingCacheSizeOverride in settings) + { + formats.Remove(existingCacheSizeOverride.format); + } + } + + void GPUCacheSizeOverridesGUI(Rect rect, int settingIdx, SerializedProperty settingListProperty, GPUCacheSetting[] settingList) + { + var cacheSizeOverrideProperty = settingListProperty.GetArrayElementAtIndex(settingIdx); + var cacheSizeOverride = settingList[settingIdx]; + +#if ENABLE_VIRTUALTEXTURES + List availableFormats = new List(EditorHelpers.QuerySupportedFormats()); + // None is used for a default cache size. + availableFormats.Add(GraphicsFormat.None); + + RemoveOverriddenFormats(availableFormats, settingList); + + // Group formats + Dictionary> formatGroups = new Dictionary>(); + foreach (GraphicsFormat graphicsFormat in availableFormats) + { + GraphicsFormatToFormatAndChannelTransformString(graphicsFormat, out var format, out var channelTransform); + if (!formatGroups.ContainsKey(format)) + { + formatGroups.Add(format, new List()); + } + formatGroups[format].Add(channelTransform); + } +#endif + + GraphicsFormat serializedFormat = (GraphicsFormat) cacheSizeOverrideProperty.FindPropertyRelative("format").intValue; + GraphicsFormatToFormatAndChannelTransformString(serializedFormat, out string formatString, out string channelTransformString); + + + // GUI Drawing + + float settingWidth = rect.width; + + float spacing = Math.Min(5, settingWidth * 0.02f); + + settingWidth -= 2 * spacing; + + float formatLabelWidth = Math.Min(60, settingWidth * 0.25f); + float formatWidth = settingWidth * 0.3f; + float channelTransformWidth = settingWidth * 0.25f; + float sizeLabelWidth = Math.Min(45, settingWidth * 0.2f); + float sizeWidth = settingWidth * 0.15f; + + // Format + rect.width = formatLabelWidth; + rect.position += new Vector2(-15, 0); + EditorGUI.LabelField(rect, s_Styles.gpuCacheSizeOverrideFormat); + + rect.position += new Vector2(formatLabelWidth, 0); + rect.width = formatWidth; + if (EditorGUI.DropdownButton(rect, new GUIContent(formatString), FocusType.Keyboard)) + { +#if ENABLE_VIRTUALTEXTURES + GenericMenu menu = new GenericMenu(); + foreach (string possibleFormat in formatGroups.Keys) + { + string localFormat = possibleFormat; + menu.AddItem(new GUIContent(localFormat), formatString == localFormat, () => + { + // Make sure the channelTransform is valid for the format. + List formatGroup = formatGroups[localFormat]; + if (formatGroup.FindIndex((string possibleChannelTransform) => { return possibleChannelTransform == channelTransformString; }) == -1) + { + channelTransformString = formatGroup[0]; + } + + cacheSizeOverrideProperty.FindPropertyRelative("format").intValue = (int)FormatAndChannelTransformStringToGraphicsFormat(localFormat, channelTransformString); + + serializedObject.ApplyModifiedProperties(); + }); + } + + menu.ShowAsContext(); +#endif + } + + // Channel transform + rect.position += new Vector2(formatWidth, 0); + rect.width = channelTransformWidth; + + List possibleChannelTransforms = new List(); + +#if ENABLE_VIRTUALTEXTURES + if (formatGroups.ContainsKey(formatString)) + { + possibleChannelTransforms = formatGroups[formatString]; + } +#endif + + EditorGUI.BeginDisabledGroup(possibleChannelTransforms.Count == 0); + { + if (serializedFormat != GraphicsFormat.None && EditorGUI.DropdownButton(rect, new GUIContent(channelTransformString), FocusType.Keyboard)) + { +#if ENABLE_VIRTUALTEXTURES + GenericMenu menu = new GenericMenu(); + possibleChannelTransforms.Add(channelTransformString); + possibleChannelTransforms.Sort(); + + foreach (string possibleChannelTransform in possibleChannelTransforms) + { + string localChannelTransform = possibleChannelTransform; + menu.AddItem(new GUIContent(localChannelTransform), localChannelTransform == channelTransformString, () => + { + GraphicsFormat format = FormatAndChannelTransformStringToGraphicsFormat(formatString, localChannelTransform); + cacheSizeOverrideProperty.FindPropertyRelative("format").intValue = (int)format; + serializedObject.ApplyModifiedProperties(); + }); + } + + menu.ShowAsContext(); +#endif + } + } + EditorGUI.EndDisabledGroup(); + + // Size + rect.position += new Vector2(channelTransformWidth + spacing, 0); + rect.width = sizeLabelWidth; + + EditorGUI.LabelField(rect, s_Styles.gpuCacheSizeOverrideSize); + + rect.position += new Vector2(sizeLabelWidth, 0); + rect.width = sizeWidth; + + cacheSizeOverride.sizeInMegaBytes = (uint) Mathf.Max(GPUCacheSizeMinValue, + EditorGUI.DelayedIntField(rect, (int) cacheSizeOverride.sizeInMegaBytes)); + cacheSizeOverrideProperty.FindPropertyRelative("sizeInMegaBytes").intValue = + (int) cacheSizeOverride.sizeInMegaBytes; + } + + void DrawStreamingOverrideElement(Rect rect, int settingIdx, bool active, bool focused) + { + GPUCacheSizeOverridesGUI(rect, settingIdx, m_GPUCacheSizeOverridesPropertyStreaming, GetGPUCacheSizeOverrideArrayFromProperty(serializedRPAsset.virtualTexturingSettings.streamingGpuCacheSettings)); + } + + sealed class Styles + { + public readonly GUIContent cpuCacheSize = new GUIContent("CPU Cache Size", "Amount of CPU memory (in MB) that can be allocated by the Streaming Virtual Texturing system to use to cache texture data."); + public readonly GUIContent gpuCacheSize = new GUIContent("GPU Cache Size per Format", "Amount of GPU memory (in MB) that can be allocated per format by the Streaming Virtual Texturing system to cache texture data. The value assigned to None is used for all unspecified formats."); + + public readonly GUIContent gpuCacheSizeOverrideFormat = new GUIContent("Format", "Format and channel transform that will be overridden."); + public readonly GUIContent gpuCacheSizeOverrideSize = new GUIContent("Size", "Size (in MB) of the setting."); + } + + static Styles s_Styles; + + // Can't use a static initializer in case we need to create GUIStyle in the Styles class as + // these can only be created with an active GUI rendering context + void CheckStyles() + { + if (s_Styles == null) + s_Styles = new Styles(); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta new file mode 100644 index 00000000000..0df3a0bc55d --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 33b486c1a65371b4391f4e7c4c53f658 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index dc7867b5116..6750807b7e8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -7,6 +7,10 @@ using UnityEngine.Experimental.Rendering; using UnityEngine.Experimental.Rendering.RenderGraphModule; +#if ENABLE_VIRTUALTEXTURES +using UnityEngine.Rendering.VirtualTexturing; +#endif + namespace UnityEngine.Rendering.HighDefinition { /// @@ -395,6 +399,24 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau return; } +#if ENABLE_VIRTUALTEXTURES + VirtualTexturingSettingsSRP settings = asset.virtualTexturingSettings; + + if (settings == null) + settings = new VirtualTexturingSettingsSRP(); + + VirtualTexturing.Streaming.SetCPUCacheSize(settings.streamingCpuCacheSizeInMegaBytes); + + GPUCacheSetting[] gpuCacheSettings = new GPUCacheSetting[settings.streamingGpuCacheSettings.Count]; + for (int i = 0; i < settings.streamingGpuCacheSettings.Count; ++i) + { + GPUCacheSettingSRP srpSetting = settings.streamingGpuCacheSettings[i]; + gpuCacheSettings[i] = new GPUCacheSetting() { format = srpSetting.format, sizeInMegaBytes = srpSetting.sizeInMegaBytes }; + } + + VirtualTexturing.Streaming.SetGPUCacheSettings(gpuCacheSettings); +#endif + // Initial state of the RTHandle system. // Tells the system that we will require MSAA or not so that we can avoid wasteful render texture allocation. // TODO: Might want to initialize to at least the window resolution to avoid un-necessary re-alloc in the player diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs index 467348ea653..2fb154fa7c5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs @@ -259,6 +259,9 @@ public override Shader defaultShader [SerializeField] internal List afterPostProcessCustomPostProcesses = new List(); + [SerializeField] + public VirtualTexturingSettingsSRP virtualTexturingSettings = new VirtualTexturingSettingsSRP(); + #if UNITY_EDITOR /// HDRP default material. public override Material defaultMaterial diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs new file mode 100644 index 00000000000..33694caf9a0 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.Rendering; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering.VirtualTexturing; + +namespace UnityEngine.Rendering.HighDefinition +{ + [HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "VirtualTexturing - Settings" + Documentation.endURL)] + [Serializable] + public sealed class VirtualTexturingSettingsSRP + { + public int streamingCpuCacheSizeInMegaBytes = 256; + public List streamingGpuCacheSettings = new List() { new GPUCacheSettingSRP() { format = Experimental.Rendering.GraphicsFormat.None, sizeInMegaBytes = 128 } }; + } + + [Serializable] + public struct GPUCacheSettingSRP + { + /// + /// Format of the cache these settings are applied to. + /// + public GraphicsFormat format; + /// + /// Size in MegaBytes of the cache created with these settings. + /// + public uint sizeInMegaBytes; + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta new file mode 100644 index 00000000000..392dfcfb8b0 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0f8c6d5fdfd2044f8b9c09a8fc27ebc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From b3ce84a22b29d5bba2149cc7d0f6341d15515a1a Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Sat, 6 Jun 2020 01:32:45 +0100 Subject: [PATCH 3/8] Hdrp/docs/volumetric lighting format fix (#628) * Updated volumetric lighting and subsurface scattering docs * Update Override-Diffusion-Profile.md --- .../Documentation~/Diffusion-Profile.md | 15 ++++++++++----- .../Images/VolumetricLighting1.png | 3 --- .../Images/VolumetricLighting2.png | 3 --- .../Documentation~/Override-Diffusion-Profile.md | 2 +- .../Documentation~/Subsurface-Scattering.md | 16 ++++++++-------- .../Documentation~/Volumetric-Lighting.md | 12 +++++------- 6 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting1.png delete mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting2.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Diffusion-Profile.md b/com.unity.render-pipelines.high-definition/Documentation~/Diffusion-Profile.md index 09d6da2ae7d..8c85dcee955 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Diffusion-Profile.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Diffusion-Profile.md @@ -1,8 +1,13 @@ # Diffusion Profile -The High Definition Render Pipeline (HDRP) stores most [subsurface scattering](Subsurface-Scattering.html) settings in a __Diffusion Profile__ Asset. You can assign a __Diffusion Profile__ Asset directly to Materials that use Subsurface Scattering. +The High Definition Render Pipeline (HDRP) stores most [subsurface scattering](Subsurface-Scattering.md) settings in a __Diffusion Profile__ Asset. You can assign a __Diffusion Profile__ Asset directly to Materials that use Subsurface Scattering. -To create a Diffusion Profile, navigate to __Assets > Create > Rendering > Diffusion Profile__. To use it, open your HDRP Asset and add it to the __Diffusion Profile List__ property. +To create a Diffusion Profile, navigate to __Assets > Create > Rendering > Diffusion Profile__. + +* To use it by default, open your HDRP Asset and, in the **Material** section, add it to the __Diffusion Profile List__. +* To use it in a particular [Volume](Volumes.md), select a Volume with a [Diffusion Profile Override](Override-Diffusion-Profile.md) and add it to the **Diffusion Profile List** . + +## Properties | Property| Description | |:---|:---| @@ -14,7 +19,7 @@ To create a Diffusion Profile, navigate to __Assets > Create > Rendering > Diffu -## Subsurface Scattering only +### Subsurface Scattering only | Property| Description | |:---|:---| @@ -22,7 +27,7 @@ To create a Diffusion Profile, navigate to __Assets > Create > Rendering > Diffu -## Transmission only +### Transmission only | Property| Description | |:---|:---| @@ -33,7 +38,7 @@ To create a Diffusion Profile, navigate to __Assets > Create > Rendering > Diffu -## Profile Previews +### Profile Previews | Property| Description | |:---|:---| diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting1.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting1.png deleted file mode 100644 index 2e653c96395..00000000000 --- a/com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e93f3e969405031a0b0ab665441d433350ee4560108b83e35fa8ecc9ab3b1750 -size 5823 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting2.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting2.png deleted file mode 100644 index e410c9c1561..00000000000 --- a/com.unity.render-pipelines.high-definition/Documentation~/Images/VolumetricLighting2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c9e453bbd6f2834915a61cb6e6be8abcee01dc6ec3814184a4b73761ad8c8597 -size 20335 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md index c315b00fc1f..23aff332e11 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md @@ -1,6 +1,6 @@ # Diffusion Profile Override -The High Definition Render Pipeline (HDRP) allows you to use up to 15 [Diffusion Profiles](Diffusion-Profile.html) in view at the same time. To use more than 15 Diffusion Profiles in a Scene, you can use the **Diffusion Profile Override** inside a [Volume](Volumes.html). This allows you to specify which Diffusion Profile to use in a certain area (or in the Scene if the Volume is global). +The High Definition Render Pipeline (HDRP) allows you to use up to 15 custom [Diffusion Profiles](Diffusion-Profile.md) in view at the same time. To use more than 15 custom Diffusion Profiles in a Scene, you can use the **Diffusion Profile Override** inside a [Volume](Volumes.md). This allows you to specify which Diffusion Profiles to use in a certain area (or in the Scene if the Volume is global). ## Using a Diffusion Profile Override diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Subsurface-Scattering.md b/com.unity.render-pipelines.high-definition/Documentation~/Subsurface-Scattering.md index 1ec53d0a336..ca59614540c 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Subsurface-Scattering.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Subsurface-Scattering.md @@ -4,20 +4,20 @@ __Subsurface Scattering__ handles light that penetrates and moves within the are Subsurface scattering also handles the light that penetrates GameObjects from behind and makes those GameObjects look transparent. For certain types of objects, the screen-space blur effect may not make a large visual difference. Therefore, HDRP implements two material types: -* __Subsurface Scattering__ implements both the screen-space blur effect and transmission (you can disable the latter) +* __Subsurface Scattering__ implements both the screen-space blur effect and transmission (you can disable the latter). * __Translucent__ only models transmission. ## Enabling Subsurface Scattering -To enable subsurface scattering in your [HDRP Asset](HDRP-Asset.html): +To enable subsurface scattering in your [HDRP Asset](HDRP-Asset.md): -- In the HDRP Asset’s Inspector window, navigate to the __Material__ section and enable the __Subsurface Scattering__ checkbox. -- When you enable the __Subsurface Scattering__ checkbox, HDRP displays the __High Quality__ option. You can Enable the checkbox to increase the sample count and reduce the amount of visual noise the blur pass can cause by undersampling. Note that this is around two and a half times more resource intensive than the default quality. -- Within the __HDRP Asset__, locate the __Default Frame Settings__. Under the __Lighting__ section, enable __Subsurface Scattering__ and __Transmission__. +1. In the HDRP Asset’s Inspector window, go to the __Material__ section and enable the __Subsurface Scattering__ checkbox. +2. When you enable the __Subsurface Scattering__ checkbox, HDRP displays the __High Quality__ option. You can Enable this option to increase the sample count and reduce the amount of visual noise the blur pass can cause by under sampling. Note that this is around two and a half times more resource intensive than the default quality. +3. Go to **Edit > Project Settings > HDRP Default Settings** and, in the **Default Frame Settings** section, under the __Lighting__ subsection, enable __Subsurface Scattering__ and __Transmission__. -HDRP stores most subsurface scattering settings in a [Diffusion Profile Settings](Diffusion-Profile.html) Asset. The __Diffusion Profile List Asset__ contains a set of 15 Diffusion Profiles you can edit and later assign to your Materials. +HDRP stores most subsurface scattering settings in a [Diffusion Profile](Diffusion-Profile.md). HDRP supports up to 15 custom Diffusion Profiles in view at the same time, but you can override which Diffusion Profiles HDRP uses and thus use as many Diffusion Profiles as you want throughout your project. To do this, use the [Diffusion Profile Override](Override-Diffusion-Profile.md) in the [Volume](Volumes.md) system. This [override](Volume-Components.md) lets you specify 15 custom Diffusion Profiles which HDRP can use for a Camera within the override's Volume. -To create a Diffusion Profile Asset, navigate to __Assets > Create > Rendering > Diffusion Profile Settings__. To use it, open your HDRP Asset and assign the new Diffusion Profile Asset to the __Diffusion Profile List__ property. +For information on how to create and use a Diffusion Profile, see the [Diffusion Profile documentation](Diffusion-Profile.md) ## Adding Subsurface Scattering to your Material @@ -27,6 +27,6 @@ For the __Subsurface Scattering__ material type, uncheck the __Transmission__ ch ### Customizing Subsurface Scattering behavior -When you select __Subsurface Scattering__ or __Translucent__ from the __Material Type__ drop-down, Unity exposes several new properties in the Material UI. For information on how to use these properties to customize the behavior of the subsurface scattering effect, see the [Material Type documentation](Material-Type.html). +When you select __Subsurface Scattering__ or __Translucent__ from the __Material Type__ drop-down, Unity exposes several new properties in the Material UI. For information on how to use these properties to customize the behavior of the subsurface scattering effect, see the [Material Type documentation](Material-Type.md). You can learn more about HDRP’s implementation in our [Efficient Screen-Space Subsurface Scattering](http://advances.realtimerendering.com/s2018/Efficient%20screen%20space%20subsurface%20scattering%20Siggraph%202018.pdf) presentation. diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md b/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md index bdf941ed394..f327f6ebe43 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md @@ -4,14 +4,12 @@ The High Definition Render Pipeline (HDRP) includes a volumetric lighting system ## Enabling Volumetric Lighting -To toggle and customize Volumetric Lighting in an [HDRP Asset](HDRP-Asset.html): +To enable and customize Volumetric Lighting in an [HDRP Asset](HDRP-Asset.md): -1. Open an HDRP Asset in your Unity Project and view it in the Inspector. Enable the **Volumetrics** checkbox in the **Lighting** section to enable Volumetric Lighting. - ![](Images/VolumetricLighting1.png) -2. If you want to increase the resolution of the volumetrics, enable the **High Quality** checkbox. Volumetric lighting is an expensive effect, and this option can potentially increase the cost of volumetric lighting by up to eight times. -3. In the **Default Frame Settings** section, under the **Lighting** subsection, make sure you enable **Fog** and **Volumetric** if they are not already. - ![](Images/VolumetricLighting2.png) -4. If you want to enable reprojection support, check **Reprojection**. This option improves the lighting quality in the Scene by taking previous frames into account when calculating the lighting for the current frame. Currently, this option is not compatible with dynamic lights, so you may encounter ghosting artifacts behind moving Lights. Additionally, using high values for **Global Anisotropy** in the [Fog](Override-Fog.html) Volume override may cause flickering Shadows. +1. Select an HDRP Asset in your Unity Project and view it in the Inspector. In the **Lighting** section, enable the **Volumetrics** checkbox. +2. If you want to increase the resolution of the volumetrics, enable the **High Quality** checkbox. Volumetric lighting is a resource intensive effect and this option can potentially increase the resource intensity by up to eight times. +3. Go to **Edit > Project Settings > HDRP Default Settings** and, in the **Default Frame Settings** section, under the **Lighting** subsection, make sure you enable **Fog** and **Volumetrics** if they are not already. +4. Still in **Default Frame Settings**, if you want to enable reprojection support, enable **Reprojection**. This option improves the lighting quality in the Scene by taking previous frames into account when calculating the lighting for the current frame. Currently, this option is not compatible with dynamic lights, so you may encounter ghosting artifacts behind moving Lights. Additionally, using high values for **Anisotropy** in the [Fog](Override-Fog.md) Volume override may cause flickering Shadows. ## Notes Volumetric fog does not work for Cameras that use oblique projection matrices. If you want a Camera to render volumetric fog, do not assign an off-axis projection to it. \ No newline at end of file From 6860198f36aeea6ea940210a1af2e8a41a7357f0 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Sat, 6 Jun 2020 01:33:09 +0100 Subject: [PATCH 4/8] Adds mention of fidelityfx-cas as requested by AMD (#629) --- .../Documentation~/HDRP-Asset.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md index 2933603e2c7..ed8188a7586 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md @@ -75,7 +75,7 @@ These settings control the draw distance and resolution of the decals atlas that | ------------------------------- | ------------------------------------------------------------ | | **Enable** | Enable the checkbox to make HDRP support dynamic resolution in your Unity Project. | | **- Dynamic Resolution Type** | Use the drop-down to select the type of dynamic resolution HDRP uses:
• **Software**: This option allocates render targets to accommodate the maximum resolution possible, then rescales the viewport accordingly. This allows the viewport to render at varying resolutions. | -| **- Upscale Filter** | Use the drop-down to select the filter that HDRP uses for upscaling.
• **Bilinear**: A low quality upsample. The least resource intensive option.
• **Catmull-Rom**: A bicubic upsample with 4 taps.
• **Lanczos**: A sharp upsample. This method can potentially introduce artifacts so you should not use it for extreme upsampling cases for example, when the screen percentage is less than 50%.
• **Contrast Adaptive Sharpen**: An ultra sharp upsample. Not meant for screen percenatage less than 50% and will still sharpen when screen percentage is set to 100% | +| **- Upscale Filter** | Use the drop-down to select the filter that HDRP uses for upscaling.
• **Bilinear**: A low quality upsample. The least resource intensive option.
• **Catmull-Rom**: A bicubic upsample with 4 taps.
• **Lanczos**: A sharp upsample. This method can potentially introduce artifacts so you should not use it for extreme upsampling cases for example, when the screen percentage is less than 50%.
• **Contrast Adaptive Sharpen**: An ultra sharp upsample. This option is not meant for screen percentages less than 50% and still sharpens when the screen percentage is set to 100%. This uses **FidelityFX (CAS) AMD™**. For information about FidelityFX and Contrast Adaptive Sharpening, see [AMD FidelityFX](https://www.amd.com/en/technologies/radeon-software-fidelityfx). | | **- Minimum Screen Percentage** | The minimum screen percentage that dynamic resolution can reach. | | **- Maximum Screen Percentage** | The maximum screen percentage that dynamic resolution can reach. This value must be higher than the **Min Screen Percentage**. | | **- Force Screen Percentage** | Enable the checkbox to force HDRP to use a specific screen percentage for dynamic resolution. This feature is useful for debugging dynamic resolution. | From da5657a25c51d130a9a61607bb5773485391d7e7 Mon Sep 17 00:00:00 2001 From: thomas-zeng <49886741+thomas-zeng@users.noreply.github.com> Date: Fri, 5 Jun 2020 17:34:38 -0700 Subject: [PATCH 5/8] * Updated XR mirrorview logic to use `TryGetAdditionalCameraDataOrDefault`. (#641) --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 6750807b7e8..d3a6f3083de 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2068,9 +2068,8 @@ ref _cullingResults // Render XR mirror view once all render requests have been completed if (i == 0 && renderRequest.hdCamera.camera.cameraType == CameraType.Game && renderRequest.hdCamera.camera.targetTexture == null) - { - HDAdditionalCameraData acd; - if (renderRequest.hdCamera.camera.TryGetComponent(out acd) && acd.xrRendering) + { + if (HDUtils.TryGetAdditionalCameraDataOrDefault(renderRequest.hdCamera.camera).xrRendering) { m_XRSystem.RenderMirrorView(cmd); } From 94043faa55da851fa103872e4ddcc16235f6e5b9 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Sat, 6 Jun 2020 01:40:03 +0100 Subject: [PATCH 6/8] Update Light-Component.md (#682) --- .../Documentation~/Light-Component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md b/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md index cc7d7669fea..a889989aa30 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md @@ -216,7 +216,7 @@ This section is only available in Realtime or Mixed light **Mode**. | **Blur Passes** | Use the slider to set the number of blur passes HDRP performs on this shadow map. Increasing this value softens shadows, but impacts performance. This property only appears if you select **Rectangle** from the **Type** drop-down and enable [more options](More-Options.html) for this section. | | **Dimmer** | Dims the shadows this Light casts so they become more faded and transparent.
This property only appears when you enable [more options](More-Options.html) for this section. | | **Tint** | Specifies whether HDRP should tint the shadows this Light casts. This option affects dynamic shadows, [Contact Shadows](Override-Contact-Shadows.md), and [ShadowMask](Lighting-Mode-Shadowmask.md). It does not affect baked shadows. You can use this behavior to change the color and transparency of shadows.
This property only appears when you enable the [more options](More-Options.html) for this section. | -| **Penumbra Tint** | Specifies whether the tint should only affect the shadow's penumbra.
This property only appears when you enable the [more options](More-Options.htmlMore-Options.html) for this section. | +| **Penumbra Tint** | Specifies whether the tint should only affect the shadow's penumbra. If you enable this property, HDRP only applies the color tint to the shadow's penumbra. If you disable this property, HDRP applies the color tint to the entire shadow including the penumbra. To change the color HDRP tints the shadow to, see the above **Tint** property.
This property only appears when you enable the [more options](More-Options.htmlMore-Options.html) for this section. | | **Fade Distance** | The distance, in meters, between the Camera and the Light at which shadows fade out. This property is available for **Spot** and **Point** Lights.
This property only appears when you enable [more options](More-Options.html) for this section. | | **Link Light Layer** | Enable the checkbox to use the same [Light Layer](Light-Layers.html) for shadows and lighting. If you enable this feature, then HDRP uses the Light Layer from the **Light Layer** drop-down in the **General** section for shadowing. If you disable this feature, then HDRP uses the **Light Layer** drop-down in this section for shadowing.
This property only appears if you enable [more options](More-Options.html) for this section.To access this property, enable **Light Layers** in your [HDRP Asset](HDRP-Asset.html). | | **Light Layer** | Use the drop-down to set the Light Layer HDRP uses for shadowing. This Light therefore only casts shadows for GameObjects that use a matching Light Layer. For more information about using Light Layers for shadowing, see [Shadow Light Layers](Light-Layers.html#ShadowLightLayers).
This property only appears if you enable [more options](More-Options.html) for this section.To access this property, disable the **Link Light Layer** checkbox. | From 3397175350df60ef5614e85142ff438b43c13706 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Sat, 6 Jun 2020 01:40:36 +0100 Subject: [PATCH 7/8] Update HDRP-Camera.md (#706) --- .../Documentation~/HDRP-Camera.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md index aa048554c23..de1b3136bdf 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Camera.md @@ -19,7 +19,7 @@ The HDRP Camera shares many properties with the [Standard Unity Camera](https:// | **Volume Anchor Override** | Assign a Transform that the [Volume](Volumes.html) system uses to handle the position of this Camera. For example, if your application uses a third person view of a character, set this property to the character's Transform. The Camera then uses the post-processing and Scene settings for Volumes that the character enters.If you do not assign a Transform, the Camera uses its own Transform instead. | | **Probe Layer Mask** | Use the drop-down to set the Layer Mask that the Camera uses to exclude environment lights (light from Planar Reflection Probes and Reflection Probes). The Camera only uses Reflection Probes on Layers that you include in this Layer Mask. | | **Occlusion Culling** | Enable the checkbox to make this Camera not render GameObjects that are not currently visible. For more information, see the [Occlusion Culling documentation](). | -| **Projection** | Use the drop-down to select the projection mode for the Camera.
• **Perspective**: The Camera simulates perspective when it renders GameObjects. This means that GameObjects further from the Camera appear smaller than GameObjects that are closer.
• **Orthographic**: The Camera renders GameObjects uniformly with no perspective. This means that GameObjects further from the Camera appear to be the same size as GameObjects that are closer. | +| **Projection** | Use the drop-down to select the projection mode for the Camera.
• **Perspective**: The Camera simulates perspective when it renders GameObjects. This means that GameObjects further from the Camera appear smaller than GameObjects that are closer.
• **Orthographic**: The Camera renders GameObjects uniformly with no perspective. This means that GameObjects further from the Camera appear to be the same size as GameObjects that are closer. Currently, HDRP does not support this projection mode. If you select this projection mode, any HDRP feature that requires lighting does not work consistently. However, this projection mode does work consistently with [Unlit](Unlit-Shader.md) Materials. | | **FOV Axis** | Use the drop-down to select the axis that you want the field of view to relate to.
• **Vertical**: Allows you to set the **Field of View** using the vertical axis.
• **Horizontal**: Allows you to set the **Field of View** using the horizontal axis.This property only appears when you select **Perspective** from the **Projection** drop-down. | | **Field of View** | Use the slider to set the viewing angle for the Camera, in degrees.
This property only appears when you select **Perspective** from the **Projection** drop-down. | | **Link FOV to Physical Camera** | Enable the checkbox to make the Camera use its **Physical Settings** to calculate its viewing angle.This property only appears when you select **Perspective** from the **Projection** drop-down. | From 48f80abdc967018df5bfa469056893e51e302d01 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 12 Jun 2020 00:15:39 +0200 Subject: [PATCH 8/8] Revert "[Skip CI] Virtual Texturing cache settings (#536)" This reverts commit 9794586ee3f9bffdef4b4649eb432830056fa3b7. --- .../CHANGELOG.md | 1 - .../Documentation~/HDRP-Asset.md | 7 - .../RenderPipeline/HDRenderPipelineUI.Skin.cs | 2 +- .../RenderPipeline/HDRenderPipelineUI.cs | 10 +- .../SerializedHDRenderPipelineAsset.cs | 3 - .../SerializedVirtualTexturingSettings.cs | 20 -- ...SerializedVirtualTexturingSettings.cs.meta | 11 - .../VirtualTexturingSettingsUI.cs | 282 ------------------ .../VirtualTexturingSettingsUI.cs.meta | 11 - .../RenderPipeline/HDRenderPipeline.cs | 22 -- .../RenderPipeline/HDRenderPipelineAsset.cs | 3 - .../VirtualTexturingSettingsSRP.cs | 30 -- .../VirtualTexturingSettingsSRP.cs.meta | 11 - 13 files changed, 2 insertions(+), 411 deletions(-) delete mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta delete mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs delete mode 100644 com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 4a4de6e3ed4..6feeab0ea0d 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -131,7 +131,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added few exposure debug modes. - Added support for multiple path-traced views at once (e.g., scene and game views). - Added support for 3DsMax's 2021 Simplified Physical Material from FBX files in the Model Importer. -- Added Virtual Texturing cache settings to control the size of the Streaming Virtual Texturing caches. ### Fixed - Fix when rescale probe all direction below zero (1219246) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md index ed8188a7586..fae814bece9 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md @@ -218,10 +218,3 @@ Use these settings to enable or disable settings relating to lighting in HDRP. | **Grading LUT Size** | The size of the internal and external color grading lookup textures (LUTs). This size is fixed for the Project. You can not mix and match LUT sizes, so decide on a size before you start the color grading process. The default value, **32**, provides a good balance of speed and quality. | | **Grading LUT Format** | Use the drop-down to select the format to encode the color grading LUTs with. Lower precision formats are faster and use less memory at the expense of color precision. These formats directly map to their equivalent in the built-in [GraphicsFormat](https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html) enum value. | | **Buffer Format** | Use the drop-down to select the format of the color buffers that are used in the post-processing passes. Lower precision formats are faster and use less memory at the expense of color precision. These formats directly map to their equivalent in the built-in [GraphicsFormat](https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html) enum value. - -## Virtual Texturing - -| **Property** | **Description** | -| ----------------------- | --------------------------------------------------------------- | -| **CPU Cache Size** | Amount of CPU memory (in MB) that can be allocated by the Streaming Virtual Texturing system to cache texture data. | -| **GPU Cache Size per Format** | Amount of GPU memory (in MB) that can be allocated per format by the Streaming Virtual Texturing system to cache texture data. The value assigned to None is used for all unspecified formats. | diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index a78024c06b3..bf7f0ccc463 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -23,7 +23,7 @@ public class GeneralSection public static readonly GUIContent materialSectionTitle = EditorGUIUtility.TrTextContent("Material"); public static readonly GUIContent postProcessSectionTitle = EditorGUIUtility.TrTextContent("Post-processing"); public static readonly GUIContent xrTitle = EditorGUIUtility.TrTextContent("XR"); - public static readonly GUIContent virtualTexturingTitle = EditorGUIUtility.TrTextContent("Virtual Texturing", "Virtual Texturing Settings. These are only available when Virtual Texturing is enabled in the Player Settings."); + public static readonly GUIContent virtualTexturingTitle = EditorGUIUtility.TrTextContent("Virtual Texturing"); public static readonly GUIContent lightLoopSubTitle = EditorGUIUtility.TrTextContent("Lights"); public static readonly GUIContent postProcessQualitySubTitle = EditorGUIUtility.TrTextContent("Post-processing Quality Settings"); public static readonly GUIContent lightingQualitySettings = EditorGUIUtility.TrTextContent("Lighting Quality Settings"); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index ad24fb02a96..e7862542a9d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -68,8 +68,6 @@ internal enum SelectedFrameSettings internal static SelectedFrameSettings selectedFrameSettings; - internal static VirtualTexturingSettingsUI virtualTexturingSettingsUI = new VirtualTexturingSettingsUI(); - static HDRenderPipelineUI() { Inspector = CED.Group( @@ -101,8 +99,7 @@ static HDRenderPipelineUI() CED.FoldoutGroup(Styles.bloomQualitySettings, Expandable.BloomQuality, k_ExpandedState, FoldoutOption.Indent | FoldoutOption.SubFoldout | FoldoutOption.NoSpaceAtEnd, Drawer_SectionBloomQualitySettings), CED.FoldoutGroup(Styles.chromaticAberrationQualitySettings, Expandable.ChromaticAberrationQuality, k_ExpandedState, FoldoutOption.Indent | FoldoutOption.SubFoldout | FoldoutOption.NoSpaceAtEnd, Drawer_SectionChromaticAberrationQualitySettings) ), - CED.FoldoutGroup(Styles.xrTitle, Expandable.XR, k_ExpandedState, Drawer_SectionXRSettings), - CED.FoldoutGroup(Styles.virtualTexturingTitle, Expandable.VirtualTexturing, k_ExpandedState, Drawer_SectionVTSettings) + CED.FoldoutGroup(Styles.xrTitle, Expandable.XR, k_ExpandedState, Drawer_SectionXRSettings) ); // fix init of selection along what is serialized @@ -572,11 +569,6 @@ static void Drawer_SectionXRSettings(SerializedHDRenderPipelineAsset serialized, EditorGUILayout.PropertyField(serialized.renderPipelineSettings.xrSettings.cameraJitter, Styles.XRCameraJitter); } - static void Drawer_SectionVTSettings(SerializedHDRenderPipelineAsset serialized, Editor owner) - { - virtualTexturingSettingsUI.OnGUI(serialized, owner); - } - static private bool m_ShowDoFLowQualitySection = false; static private bool m_ShowDoFMediumQualitySection = false; static private bool m_ShowDoFHighQualitySection = false; diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs index e8b64eed36f..1f1572a90e6 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDRenderPipelineAsset.cs @@ -20,7 +20,6 @@ class SerializedHDRenderPipelineAsset public SerializedFrameSettings defaultFrameSettings; public SerializedFrameSettings defaultBakedOrCustomReflectionFrameSettings; public SerializedFrameSettings defaultRealtimeReflectionFrameSettings; - public SerializedVirtualTexturingSettings virtualTexturingSettings; //RenderPipelineResources not always exist and thus cannot be serialized normally. public bool editorResourceHasMultipleDifferentValues @@ -64,8 +63,6 @@ public SerializedHDRenderPipelineAsset(SerializedObject serializedObject) defaultFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultCameraFrameSettings"), null); //no overrides in HDRPAsset defaultBakedOrCustomReflectionFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings"), null); //no overrides in HDRPAsset defaultRealtimeReflectionFrameSettings = new SerializedFrameSettings(serializedObject.FindProperty("m_RenderingPathDefaultRealtimeReflectionFrameSettings"), null); //no overrides in HDRPAsset - - virtualTexturingSettings = new SerializedVirtualTexturingSettings(serializedObject.FindProperty("virtualTexturingSettings")); } public void Update() diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs deleted file mode 100644 index b0233c3751b..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using UnityEditor.Rendering; -using UnityEngine.Rendering.HighDefinition; - -namespace UnityEditor.Rendering.HighDefinition -{ - public sealed class SerializedVirtualTexturingSettings - { - public SerializedProperty root; - - public SerializedProperty streamingCpuCacheSizeInMegaBytes; - public SerializedProperty streamingGpuCacheSettings; - public SerializedVirtualTexturingSettings(SerializedProperty root) - { - this.root = root; - - streamingCpuCacheSizeInMegaBytes = root.Find((VirtualTexturingSettingsSRP s) => s.streamingCpuCacheSizeInMegaBytes); - streamingGpuCacheSettings = root.Find((VirtualTexturingSettingsSRP s) => s.streamingGpuCacheSettings); - } - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta deleted file mode 100644 index d2b9c82d69a..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedVirtualTexturingSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2b6b35c2a70589145b2353009c41ecf8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs deleted file mode 100644 index 1fb12cef2aa..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs +++ /dev/null @@ -1,282 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditorInternal; -using UnityEngine; -using UnityEngine.Experimental.Rendering; -using UnityEngine.Rendering.VirtualTexturing; - -namespace UnityEditor.Rendering.HighDefinition -{ - class VirtualTexturingSettingsUI - { - private ReorderableList m_GPUCacheSizeOverrideListStreaming; - private SerializedProperty m_GPUCacheSizeOverridesPropertyStreaming; - - public SerializedObject serializedObject; - private SerializedHDRenderPipelineAsset serializedRPAsset; - - private const int CPUCacheSizeMinValue = 64; - private const int GPUCacheSizeMinValue = 32; - - public void OnGUI(SerializedHDRenderPipelineAsset serialized, Editor owner) - { - CheckStyles(); - - serializedObject = serialized.serializedObject; - serializedRPAsset = serialized; - - EditorGUILayout.Space(); - -#if !ENABLE_VIRTUALTEXTURES - EditorGUI.BeginDisabledGroup(true); -#endif - - using (var scope = new EditorGUI.ChangeCheckScope()) - { - serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue = Mathf.Max(CPUCacheSizeMinValue, EditorGUILayout.DelayedIntField(s_Styles.cpuCacheSize, serialized.virtualTexturingSettings.streamingCpuCacheSizeInMegaBytes.intValue)); - - // GPU Cache size settings - if (m_GPUCacheSizeOverrideListStreaming == null || - m_GPUCacheSizeOverridesPropertyStreaming != serialized.virtualTexturingSettings.streamingGpuCacheSettings) - { - m_GPUCacheSizeOverridesPropertyStreaming = serialized.virtualTexturingSettings.streamingGpuCacheSettings; - m_GPUCacheSizeOverrideListStreaming = CreateGPUCacheSizeOverrideList(m_GPUCacheSizeOverridesPropertyStreaming, DrawStreamingOverrideElement); - } - - m_GPUCacheSizeOverrideListStreaming.DoLayoutList(); - } - -#if !ENABLE_VIRTUALTEXTURES - EditorGUI.EndDisabledGroup(); -#endif - - serialized.serializedObject.ApplyModifiedProperties(); - } - - GPUCacheSetting[] GetGPUCacheSizeOverrideArrayFromProperty(SerializedProperty property) - { - List settings = new List(); - for (int i = 0; i < property.arraySize; ++i) - { - SerializedProperty settingProperty = property.GetArrayElementAtIndex(i); - settings.Add(new GPUCacheSetting() - { format = (GraphicsFormat)settingProperty.FindPropertyRelative("format").intValue, sizeInMegaBytes = (uint)settingProperty.FindPropertyRelative("sizeInMegaBytes").intValue }); - } - - return settings.ToArray(); - } - - ReorderableList CreateGPUCacheSizeOverrideList(SerializedProperty property, ReorderableList.ElementCallbackDelegate drawCallback) - { - ReorderableList list = new ReorderableList(property.serializedObject, property); - - list.drawHeaderCallback = - (Rect rect) => - { - GUI.Label(rect, s_Styles.gpuCacheSize); - }; - - list.drawElementCallback = drawCallback; - - list.onAddCallback = (l) => - { - List availableFormats = new List(EditorHelpers.QuerySupportedFormats()); - - // We can't just pass in existing settings as a parameter to CreateGPUCacheSizeOverrideList() because lambdas can't capture ref params. - GPUCacheSetting[] existingSettings = GetGPUCacheSizeOverrideArrayFromProperty(serializedRPAsset.virtualTexturingSettings.streamingGpuCacheSettings); - RemoveOverriddenFormats(availableFormats, existingSettings); - - int index = property.arraySize; - property.InsertArrayElementAtIndex(index); - var newItemProperty = property.GetArrayElementAtIndex(index); - newItemProperty.FindPropertyRelative("format").intValue = availableFormats.Count > 0 ? (int)availableFormats[0] : 0; - newItemProperty.FindPropertyRelative("sizeInMegaBytes").intValue = 64; - }; - - return list; - } - - void GraphicsFormatToFormatAndChannelTransformString(GraphicsFormat graphicsFormat, out string format, out string channelTransform) - { - string formatString = graphicsFormat.ToString(); - int lastUnderscore = formatString.LastIndexOf('_'); - if (lastUnderscore < 0) - { - format = "None"; - channelTransform = "None"; - return; - } - format = formatString.Substring(0, lastUnderscore); - channelTransform = formatString.Substring(lastUnderscore + 1); - } - GraphicsFormat FormatAndChannelTransformStringToGraphicsFormat(string format, string channelTransform) - { - if (format == "None") return GraphicsFormat.None; - - return (GraphicsFormat)Enum.Parse(typeof(GraphicsFormat), $"{format}_{channelTransform}"); - } - - void RemoveOverriddenFormats(List formats, GPUCacheSetting[] settings) - { - foreach (var existingCacheSizeOverride in settings) - { - formats.Remove(existingCacheSizeOverride.format); - } - } - - void GPUCacheSizeOverridesGUI(Rect rect, int settingIdx, SerializedProperty settingListProperty, GPUCacheSetting[] settingList) - { - var cacheSizeOverrideProperty = settingListProperty.GetArrayElementAtIndex(settingIdx); - var cacheSizeOverride = settingList[settingIdx]; - -#if ENABLE_VIRTUALTEXTURES - List availableFormats = new List(EditorHelpers.QuerySupportedFormats()); - // None is used for a default cache size. - availableFormats.Add(GraphicsFormat.None); - - RemoveOverriddenFormats(availableFormats, settingList); - - // Group formats - Dictionary> formatGroups = new Dictionary>(); - foreach (GraphicsFormat graphicsFormat in availableFormats) - { - GraphicsFormatToFormatAndChannelTransformString(graphicsFormat, out var format, out var channelTransform); - if (!formatGroups.ContainsKey(format)) - { - formatGroups.Add(format, new List()); - } - formatGroups[format].Add(channelTransform); - } -#endif - - GraphicsFormat serializedFormat = (GraphicsFormat) cacheSizeOverrideProperty.FindPropertyRelative("format").intValue; - GraphicsFormatToFormatAndChannelTransformString(serializedFormat, out string formatString, out string channelTransformString); - - - // GUI Drawing - - float settingWidth = rect.width; - - float spacing = Math.Min(5, settingWidth * 0.02f); - - settingWidth -= 2 * spacing; - - float formatLabelWidth = Math.Min(60, settingWidth * 0.25f); - float formatWidth = settingWidth * 0.3f; - float channelTransformWidth = settingWidth * 0.25f; - float sizeLabelWidth = Math.Min(45, settingWidth * 0.2f); - float sizeWidth = settingWidth * 0.15f; - - // Format - rect.width = formatLabelWidth; - rect.position += new Vector2(-15, 0); - EditorGUI.LabelField(rect, s_Styles.gpuCacheSizeOverrideFormat); - - rect.position += new Vector2(formatLabelWidth, 0); - rect.width = formatWidth; - if (EditorGUI.DropdownButton(rect, new GUIContent(formatString), FocusType.Keyboard)) - { -#if ENABLE_VIRTUALTEXTURES - GenericMenu menu = new GenericMenu(); - foreach (string possibleFormat in formatGroups.Keys) - { - string localFormat = possibleFormat; - menu.AddItem(new GUIContent(localFormat), formatString == localFormat, () => - { - // Make sure the channelTransform is valid for the format. - List formatGroup = formatGroups[localFormat]; - if (formatGroup.FindIndex((string possibleChannelTransform) => { return possibleChannelTransform == channelTransformString; }) == -1) - { - channelTransformString = formatGroup[0]; - } - - cacheSizeOverrideProperty.FindPropertyRelative("format").intValue = (int)FormatAndChannelTransformStringToGraphicsFormat(localFormat, channelTransformString); - - serializedObject.ApplyModifiedProperties(); - }); - } - - menu.ShowAsContext(); -#endif - } - - // Channel transform - rect.position += new Vector2(formatWidth, 0); - rect.width = channelTransformWidth; - - List possibleChannelTransforms = new List(); - -#if ENABLE_VIRTUALTEXTURES - if (formatGroups.ContainsKey(formatString)) - { - possibleChannelTransforms = formatGroups[formatString]; - } -#endif - - EditorGUI.BeginDisabledGroup(possibleChannelTransforms.Count == 0); - { - if (serializedFormat != GraphicsFormat.None && EditorGUI.DropdownButton(rect, new GUIContent(channelTransformString), FocusType.Keyboard)) - { -#if ENABLE_VIRTUALTEXTURES - GenericMenu menu = new GenericMenu(); - possibleChannelTransforms.Add(channelTransformString); - possibleChannelTransforms.Sort(); - - foreach (string possibleChannelTransform in possibleChannelTransforms) - { - string localChannelTransform = possibleChannelTransform; - menu.AddItem(new GUIContent(localChannelTransform), localChannelTransform == channelTransformString, () => - { - GraphicsFormat format = FormatAndChannelTransformStringToGraphicsFormat(formatString, localChannelTransform); - cacheSizeOverrideProperty.FindPropertyRelative("format").intValue = (int)format; - serializedObject.ApplyModifiedProperties(); - }); - } - - menu.ShowAsContext(); -#endif - } - } - EditorGUI.EndDisabledGroup(); - - // Size - rect.position += new Vector2(channelTransformWidth + spacing, 0); - rect.width = sizeLabelWidth; - - EditorGUI.LabelField(rect, s_Styles.gpuCacheSizeOverrideSize); - - rect.position += new Vector2(sizeLabelWidth, 0); - rect.width = sizeWidth; - - cacheSizeOverride.sizeInMegaBytes = (uint) Mathf.Max(GPUCacheSizeMinValue, - EditorGUI.DelayedIntField(rect, (int) cacheSizeOverride.sizeInMegaBytes)); - cacheSizeOverrideProperty.FindPropertyRelative("sizeInMegaBytes").intValue = - (int) cacheSizeOverride.sizeInMegaBytes; - } - - void DrawStreamingOverrideElement(Rect rect, int settingIdx, bool active, bool focused) - { - GPUCacheSizeOverridesGUI(rect, settingIdx, m_GPUCacheSizeOverridesPropertyStreaming, GetGPUCacheSizeOverrideArrayFromProperty(serializedRPAsset.virtualTexturingSettings.streamingGpuCacheSettings)); - } - - sealed class Styles - { - public readonly GUIContent cpuCacheSize = new GUIContent("CPU Cache Size", "Amount of CPU memory (in MB) that can be allocated by the Streaming Virtual Texturing system to use to cache texture data."); - public readonly GUIContent gpuCacheSize = new GUIContent("GPU Cache Size per Format", "Amount of GPU memory (in MB) that can be allocated per format by the Streaming Virtual Texturing system to cache texture data. The value assigned to None is used for all unspecified formats."); - - public readonly GUIContent gpuCacheSizeOverrideFormat = new GUIContent("Format", "Format and channel transform that will be overridden."); - public readonly GUIContent gpuCacheSizeOverrideSize = new GUIContent("Size", "Size (in MB) of the setting."); - } - - static Styles s_Styles; - - // Can't use a static initializer in case we need to create GUIStyle in the Styles class as - // these can only be created with an active GUI rendering context - void CheckStyles() - { - if (s_Styles == null) - s_Styles = new Styles(); - } - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta deleted file mode 100644 index 0df3a0bc55d..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VirtualTexturingSettingsUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 33b486c1a65371b4391f4e7c4c53f658 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index d3a6f3083de..92685a57adc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -7,10 +7,6 @@ using UnityEngine.Experimental.Rendering; using UnityEngine.Experimental.Rendering.RenderGraphModule; -#if ENABLE_VIRTUALTEXTURES -using UnityEngine.Rendering.VirtualTexturing; -#endif - namespace UnityEngine.Rendering.HighDefinition { /// @@ -399,24 +395,6 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau return; } -#if ENABLE_VIRTUALTEXTURES - VirtualTexturingSettingsSRP settings = asset.virtualTexturingSettings; - - if (settings == null) - settings = new VirtualTexturingSettingsSRP(); - - VirtualTexturing.Streaming.SetCPUCacheSize(settings.streamingCpuCacheSizeInMegaBytes); - - GPUCacheSetting[] gpuCacheSettings = new GPUCacheSetting[settings.streamingGpuCacheSettings.Count]; - for (int i = 0; i < settings.streamingGpuCacheSettings.Count; ++i) - { - GPUCacheSettingSRP srpSetting = settings.streamingGpuCacheSettings[i]; - gpuCacheSettings[i] = new GPUCacheSetting() { format = srpSetting.format, sizeInMegaBytes = srpSetting.sizeInMegaBytes }; - } - - VirtualTexturing.Streaming.SetGPUCacheSettings(gpuCacheSettings); -#endif - // Initial state of the RTHandle system. // Tells the system that we will require MSAA or not so that we can avoid wasteful render texture allocation. // TODO: Might want to initialize to at least the window resolution to avoid un-necessary re-alloc in the player diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs index 2fb154fa7c5..467348ea653 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineAsset.cs @@ -259,9 +259,6 @@ public override Shader defaultShader [SerializeField] internal List afterPostProcessCustomPostProcesses = new List(); - [SerializeField] - public VirtualTexturingSettingsSRP virtualTexturingSettings = new VirtualTexturingSettingsSRP(); - #if UNITY_EDITOR /// HDRP default material. public override Material defaultMaterial diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs deleted file mode 100644 index 33694caf9a0..00000000000 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEditor.Rendering; -using UnityEngine.Experimental.Rendering; -using UnityEngine.Rendering.VirtualTexturing; - -namespace UnityEngine.Rendering.HighDefinition -{ - [HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "VirtualTexturing - Settings" + Documentation.endURL)] - [Serializable] - public sealed class VirtualTexturingSettingsSRP - { - public int streamingCpuCacheSizeInMegaBytes = 256; - public List streamingGpuCacheSettings = new List() { new GPUCacheSettingSRP() { format = Experimental.Rendering.GraphicsFormat.None, sizeInMegaBytes = 128 } }; - } - - [Serializable] - public struct GPUCacheSettingSRP - { - /// - /// Format of the cache these settings are applied to. - /// - public GraphicsFormat format; - /// - /// Size in MegaBytes of the cache created with these settings. - /// - public uint sizeInMegaBytes; - } -} diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta deleted file mode 100644 index 392dfcfb8b0..00000000000 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/VirtualTexturingSettingsSRP.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b0f8c6d5fdfd2044f8b9c09a8fc27ebc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: