public HDRPreprocessShaders()
        {
            // TODO: Grab correct configuration/quality asset.
            if (ShaderBuildPreprocessor.hdrpAssets == null || ShaderBuildPreprocessor.hdrpAssets.Count == 0)
            {
                return;
            }

            shaderProcessorsList = HDEditorUtils.GetBaseShaderPreprocessorList();
        }
Esempio n. 2
0
 static void Drawer_SectionCookies(SerializedHDRenderPipelineAsset serialized, Editor owner)
 {
     EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.cookieSize, k_CoockieSizeContent);
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize, k_CookieTextureArraySizeContent);
     if (EditorGUI.EndChangeCheck())
     {
         serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
     }
     if (serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.hasMultipleDifferentValues)
     {
         EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
     }
     else
     {
         long currentCache = TextureCache2D.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.cookieTexArraySize.intValue, serialized.renderPipelineSettings.lightLoopSettings.cookieSize.intValue, 1);
         if (currentCache > HDRenderPipeline.k_MaxCacheSize)
         {
             int    reserved = TextureCache2D.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.cookieSize.intValue, 1);
             string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
             EditorGUILayout.HelpBox(message, MessageType.Error);
         }
         else
         {
             string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
             EditorGUILayout.HelpBox(message, MessageType.Info);
         }
     }
     EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize, k_PointCoockieSizeContent);
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize, k_PointCookieTextureArraySizeContent);
     if (EditorGUI.EndChangeCheck())
     {
         serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.intValue, 1, TextureCache.k_MaxSupported);
     }
     if (serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.hasMultipleDifferentValues)
     {
         EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
     }
     else
     {
         long currentCache = TextureCacheCubemap.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.cubeCookieTexArraySize.intValue, serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize.intValue, 1);
         if (currentCache > HDRenderPipeline.k_MaxCacheSize)
         {
             int    reserved = TextureCacheCubemap.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.pointCookieSize.intValue, 1);
             string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
             EditorGUILayout.HelpBox(message, MessageType.Error);
         }
         else
         {
             string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
             EditorGUILayout.HelpBox(message, MessageType.Info);
         }
     }
 }
        void RayTracedReflectionGUI(RayCastingMode tracingMode)
        {
            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            using (new IndentLevelScope())
            {
                EditorGUILayout.LabelField("Fallback", EditorStyles.miniLabel);
                PropertyField(m_RayMiss, k_RayMissFallbackHierarchyText);
                PropertyField(m_LastBounce, k_LastBounceFallbackHierarchyText);
            }
            PropertyField(m_LayerMask, k_LayerMaskText);
            PropertyField(m_TextureLodBias, k_TextureLodBiasText);

            if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both)
            {
                if (tracingMode == RayCastingMode.RayTracing)
                {
                    PropertyField(m_Mode, k_ModeText);

                    using (new IndentLevelScope())
                    {
                        switch (m_Mode.value.GetEnumValue <RayTracingMode>())
                        {
                        case RayTracingMode.Performance:
                            RayTracingPerformanceModeGUI(false);
                            break;

                        case RayTracingMode.Quality:
                            RayTracingQualityModeGUI();
                            break;
                        }
                    }
                }
                else
                {
                    RayTracingPerformanceModeGUI(true);
                }
            }
            else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality)
            {
                if (tracingMode == RayCastingMode.RayTracing)
                {
                    RayTracingQualityModeGUI();
                }
                else
                {
                    HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support the mixed mode which is only available in performance mode.", MessageType.Error,
                                                         HDRenderPipelineUI.Expandable.Rendering, "m_RenderPipelineSettings.supportedRayTracingMode");
                }
            }
            else
            {
                RayTracingPerformanceModeGUI(tracingMode == RayCastingMode.Mixed);
            }
        }
        /// <summary>
        /// Unity calls this method each time it re-draws the Inspector.
        /// </summary>
        /// <remarks>
        /// You can safely override this method and not call <c>base.OnInspectorGUI()</c> unless you
        /// want Unity to display all the properties from the <see cref="VolumeComponent"/>
        /// automatically.
        /// </remarks>
        public override void OnInspectorGUI()
        {
            if (!HDRenderPipelineGlobalSettings.instance?.IsCustomPostProcessRegistered(target.GetType()) ?? false)
            {
                HDEditorUtils.GlobalSettingsHelpBox(Styles.customPostProcessNotInGlobalSettingsText,
                                                    MessageType.Error, HDRenderPipelineGlobalSettingsUI.Styles.customPostProcessOrderLabel.text);
                return;
            }

            base.OnInspectorGUI();
        }
Esempio n. 5
0
        void DrawShaderGraphGUI()
        {
            // Filter out properties we don't want to draw:
            PropertiesDefaultGUI(properties);

            // If we change a property in a shadergraph, we trigger a material keyword reset
            if (CheckPropertyChanged(properties))
            {
                foreach (var material in materials)
                {
                    HDEditorUtils.ResetMaterialKeywords(material);
                }
            }

            if (properties.Length > 0)
            {
                EditorGUILayout.Space();
            }

            if ((m_Features & Features.DiffusionProfileAsset) != 0)
            {
                DrawDiffusionProfileUI();
            }

            if ((m_Features & Features.EnableInstancing) != 0)
            {
                materialEditor.EnableInstancingField();
            }

            if ((m_Features & Features.DoubleSidedGI) != 0)
            {
                // If the shader graph have a double sided flag, then we don't display this field.
                // The double sided GI value will be synced with the double sided property during the SetupBaseUnlitKeywords()
                if (!materials[0].HasProperty(kDoubleSidedEnable))
                {
                    materialEditor.DoubleSidedGIField();
                }
            }

            if ((m_Features & Features.EmissionGI) != 0)
            {
                DrawEmissionGI();
            }

            if ((m_Features & Features.MotionVector) != 0)
            {
                DrawMotionVectorToggle();
            }
        }
Esempio n. 6
0
        public override void OnInspectorGUI()
        {
            m_SerializedCamera.Update();

            if (HDEditorUtils.IsPresetEditor(this))
            {
                HDCameraUI.PresetInspector.Draw(m_SerializedCamera, this);
            }
            else
            {
                HDCameraUI.Inspector.Draw(m_SerializedCamera, this);
            }

            m_SerializedCamera.Apply();
        }
            // Tool bars
            public static void DrawToolbars(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.changed = false;

                for (int i = 0; i < k_ListModes.Length; ++i)
                {
                    EditMode.DoInspectorToolbar(k_ListModes[i], k_ListContent[i], HDEditorUtils.GetBoundsGetter(owner), owner);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
        void LogShaderVariants(Shader shader, ShaderSnippetData snippetData, ShaderVariantLogLevel logLevel, uint prevVariantsCount, uint currVariantsCount)
        {
            if (logLevel == ShaderVariantLogLevel.AllShaders ||
                (logLevel == ShaderVariantLogLevel.OnlyHDRPShaders && HDEditorUtils.IsHDRPShader(shader)))
            {
                float percentageCurrent = ((float)currVariantsCount / prevVariantsCount) * 100.0f;
                float percentageTotal   = ((float)m_TotalVariantsOutputCount / m_TotalVariantsInputCount) * 100.0f;

                string result = string.Format("STRIPPING: {0} ({1} pass) ({2}) -" +
                                              " Remaining shader variants = {3}/{4} = {5}% - Total = {6}/{7} = {8}%",
                                              shader.name, snippetData.passName, snippetData.shaderType.ToString(), currVariantsCount,
                                              prevVariantsCount, percentageCurrent, m_TotalVariantsOutputCount, m_TotalVariantsInputCount,
                                              percentageTotal);
                Debug.Log(result);
            }
        }
Esempio n. 9
0
 public override void OnInspectorGUI()
 {
     if (HDEditorUtils.IsPresetEditor(this))
     {
         EditorGUILayout.HelpBox(HDProbeUI.k_UnsupportedPresetPropertiesMessage, MessageType.Info);
     }
     else
     {
         m_SerializedHDProbe.Update();
         EditorGUI.BeginChangeCheck();
         Draw(m_SerializedHDProbe, this);
         if (EditorGUI.EndChangeCheck())
         {
             m_SerializedHDProbe.Apply();
         }
     }
 }
Esempio n. 10
0
        public static SettingsProvider CreateSettingsProvider()
        {
            return(new SettingsProvider("Project/Quality/HDRP", SettingsScope.Project)
            {
                activateHandler = (searchContext, rootElement) =>
                {
                    HDEditorUtils.AddStyleSheets(rootElement, HDEditorUtils.FormatingPath);
                    HDEditorUtils.AddStyleSheets(rootElement, HDEditorUtils.QualitySettingsSheetPath);

                    var panel = new QualitySettingsPanelVisualElement(searchContext);
                    panel.style.flexGrow = 1;

                    rootElement.Add(panel);
                },
                keywords = new [] { "quality", "hdrp" }
            });
        }
        private void OnEnable()
        {
            titleContent = Style.title;

            HDEditorUtils.AddStyleSheets(rootVisualElement, HDEditorUtils.FormatingPath); //.h1
            HDEditorUtils.AddStyleSheets(rootVisualElement, HDEditorUtils.WizardSheetPath);

            var scrollView = new ScrollView(ScrollViewMode.Vertical);

            rootVisualElement.Add(scrollView);
            var container = scrollView.contentContainer;

            container.Add(CreateTitle(Style.defaultSettingsTitle));
            container.Add(CreateFolderData());
            container.Add(m_DefaultScene = CreateDefaultScene());

            container.Add(CreateTitle(Style.configurationTitle));
            container.Add(CreateTabbedBox(
                              RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                    ? new[] {
        public override void OnInspectorGUI()
        {
            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            if (currentAsset == null)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("The current pipeline is not HDRP", MessageType.Error, wide: true);
                return;
            }

            if (!currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing)
            {
                EditorGUILayout.Space();
                HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support Ray Tracing.", MessageType.Error, HDRenderPipelineUI.Expandable.Rendering, "m_RenderPipelineSettings.supportRayTracing");
                return;
            }

            // If ray tracing is supported display the content of the volume component
            if (RenderPipelineManager.currentPipeline is not HDRenderPipeline {
                rayTracingSupported : true
            })
Esempio n. 13
0
 internal static void Checkout(string targetFile)
 {
     // Try to checkout through the VCS
     if (Provider.isActive &&
         HDEditorUtils.IsAssetPath(targetFile) &&
         Provider.GetAssetByPath(targetFile) != null)
     {
         Provider.Checkout(targetFile, CheckoutMode.Both).Wait();
     }
     else if (File.Exists(targetFile))
     {
         // There is no VCS, but the file is still locked
         // Try to make it writeable
         var attributes = File.GetAttributes(targetFile);
         if ((attributes & FileAttributes.ReadOnly) == 0)
         {
             return;
         }
         attributes &= ~FileAttributes.ReadOnly;
         File.SetAttributes(targetFile, attributes);
     }
 }
Esempio n. 14
0
            // Tool bars
            public static void DrawToolbars(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.changed = false;

                for (int i = 0; i < k_ListModes.Length - 1; ++i)
                {
                    EditMode.DoInspectorToolbar(k_ListModes[i], k_ListContent[i], HDEditorUtils.GetBoundsGetter(owner), owner);
                }

                //Special case: show chrome gizmo should be mouved to overlay tool.
                //meanwhile, display it as an option of toolbar
                EditorGUI.BeginChangeCheck();
                IHDProbeEditor probeEditor = owner as IHDProbeEditor;
                int            selected    = probeEditor.showChromeGizmo ? 0 : -1;
                int            newSelected = GUILayout.Toolbar(selected, new[] { k_ListContent[k_ListModes.Length - 1][0] }, GUILayout.Height(20), GUILayout.Width(30));

                if (EditorGUI.EndChangeCheck())
                {
                    //allow deselection
                    if (selected >= 0 && newSelected == selected)
                    {
                        selected = -1;
                    }
                    else
                    {
                        selected = newSelected;
                    }
                    probeEditor.showChromeGizmo = selected == 0;
                    SceneView.RepaintAll();
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
Esempio n. 15
0
        static void ResetAllMaterialAssetsKeywords(float progressScale, float progressOffset)
        {
            var matIds = AssetDatabase.FindAssets("t:Material");

            bool VCSEnabled = (UnityEditor.VersionControl.Provider.enabled && UnityEditor.VersionControl.Provider.isActive);

            for (int i = 0, length = matIds.Length; i < length; i++)
            {
                var path = AssetDatabase.GUIDToAssetPath(matIds[i]);
                var mat  = AssetDatabase.LoadAssetAtPath <Material>(path);

                EditorUtility.DisplayProgressBar(
                    "Setup material asset's Keywords...",
                    string.Format("{0} / {1} materials cleaned.", i, length),
                    (i / (float)(length - 1)) * progressScale + progressOffset);

                CoreEditorUtils.CheckOutFile(VCSEnabled, mat);
                var h = Debug.unityLogger.logHandler;
                Debug.unityLogger.logHandler = new UnityContextualLogHandler(mat);
                HDEditorUtils.ResetMaterialKeywords(mat);
                Debug.unityLogger.logHandler = h;
            }
        }
Esempio n. 16
0
        static void Execute(CommandLineAction action)
        {
            switch (action.operation)
            {
            case CommandLineOperation.ResetMaterialKeywords:
            {
                Console.WriteLine("[HDEditorCLI][ResetMaterialKeywords] Starting material reset");

                var matIds = AssetDatabase.FindAssets("t:Material");

                for (int i = 0, length = matIds.Length; i < length; i++)
                {
                    var path = AssetDatabase.GUIDToAssetPath(matIds[i]);
                    var mat  = AssetDatabase.LoadAssetAtPath <Material>(path);

                    if (HDEditorUtils.ResetMaterialKeywords(mat))
                    {
                        Console.WriteLine("[HDEditorCLI][ResetMaterialKeywords] " + path);
                    }
                }
                break;
            }
            }
        }
        public override void Convert(Material srcMaterial, Material dstMaterial)
        {
            dstMaterial.hideFlags = HideFlags.DontUnloadUnusedAsset;

            base.Convert(srcMaterial, dstMaterial);

            // ---------- Mask Map ----------

            // Metallic
            bool    hasMetallic = false;
            Texture metallicMap = TextureCombiner.TextureFromColor(Color.black);

            if ((srcMaterial.shader.name == Standard) || (srcMaterial.shader.name == Standard_Rough))
            {
                hasMetallic = srcMaterial.GetTexture("_MetallicGlossMap") != null;
                if (hasMetallic)
                {
                    metallicMap = TextureCombiner.GetTextureSafe(srcMaterial, "_MetallicGlossMap", Color.white);
                }
                else
                {
                    metallicMap = TextureCombiner.TextureFromColor(Color.white);
                }

                // Convert _Metallic value from Gamma to Linear, or set to 1 if a map is used
                float metallicValue = Mathf.Pow(srcMaterial.GetFloat("_Metallic"), 2.2f);
                dstMaterial.SetFloat("_Metallic", hasMetallic? 1f : metallicValue);
            }

            // Occlusion
            bool    hasOcclusion = srcMaterial.GetTexture("_OcclusionMap") != null;
            Texture occlusionMap = Texture2D.whiteTexture;

            if (hasOcclusion)
            {
                occlusionMap = TextureCombiner.GetTextureSafe(srcMaterial, "_OcclusionMap", Color.white);
            }

            dstMaterial.SetFloat("_AORemapMin", 1f - srcMaterial.GetFloat("_OcclusionStrength"));

            // Detail Mask
            bool    hasDetailMask = srcMaterial.GetTexture("_DetailMask") != null;
            Texture detailMaskMap = Texture2D.whiteTexture;

            if (hasDetailMask)
            {
                detailMaskMap = TextureCombiner.GetTextureSafe(srcMaterial, "_DetailMask", Color.white);
            }

            // Smoothness
            bool      hasSmoothness = false;
            Texture2D smoothnessMap = TextureCombiner.TextureFromColor(Color.white);

            dstMaterial.SetFloat("_SmoothnessRemapMax", srcMaterial.GetFloat("_Glossiness"));

            if (srcMaterial.shader.name == Standard_Rough)
            {
                hasSmoothness = srcMaterial.GetTexture("_SpecGlossMap") != null;

                if (hasSmoothness)
                {
                    smoothnessMap = (Texture2D)TextureCombiner.GetTextureSafe(srcMaterial, "_SpecGlossMap", Color.grey);
                }
            }
            else
            {
                string smoothnessTextureChannel = "_MainTex";

                if (srcMaterial.GetFloat("_SmoothnessTextureChannel") == 0)
                {
                    if (srcMaterial.shader.name == Standard)
                    {
                        smoothnessTextureChannel = "_MetallicGlossMap";
                    }
                    if (srcMaterial.shader.name == Standard_Spec)
                    {
                        smoothnessTextureChannel = "_SpecGlossMap";
                    }
                }

                smoothnessMap = (Texture2D)srcMaterial.GetTexture(smoothnessTextureChannel);
                if (smoothnessMap != null)
                {
                    hasSmoothness = true;

                    dstMaterial.SetFloat("_SmoothnessRemapMax", srcMaterial.GetFloat("_GlossMapScale"));

                    if (!TextureCombiner.TextureHasAlpha(smoothnessMap))
                    {
                        smoothnessMap = TextureCombiner.TextureFromColor(Color.white);
                    }
                }
                else
                {
                    smoothnessMap = TextureCombiner.TextureFromColor(Color.white);
                }
            }


            // Build the mask map
            if (hasMetallic || hasOcclusion || hasDetailMask || hasSmoothness)
            {
                Texture2D maskMap;

                TextureCombiner maskMapCombiner = new TextureCombiner(
                    metallicMap, 0,                                                         // R: Metallic from red
                    occlusionMap, 1,                                                        // G: Occlusion from green
                    detailMaskMap, 3,                                                       // B: Detail Mask from alpha
                    smoothnessMap, (srcMaterial.shader.name == Standard_Rough) ? -4 : 3     // A: Smoothness Texture from inverse greyscale for roughness setup, or alpha
                    );

                string maskMapPath = AssetDatabase.GetAssetPath(srcMaterial);
                maskMapPath = maskMapPath.Remove(maskMapPath.Length - 4) + "_MaskMap.png";
                maskMap     = maskMapCombiner.Combine(maskMapPath);
                dstMaterial.SetTexture("_MaskMap", maskMap);
            }

            // Specular Setup Specific
            if (srcMaterial.shader.name == Standard_Spec)
            {
                // if there is a specular map, change the specular color to white
                if (srcMaterial.GetTexture("_SpecGlossMap") != null)
                {
                    dstMaterial.SetColor("_SpecularColor", Color.white);
                }
            }

            // ---------- Height Map ----------
            bool hasHeightMap = srcMaterial.GetTexture("_ParallaxMap") != null;

            if (hasHeightMap) // Enable Parallax Occlusion Mapping
            {
                dstMaterial.SetFloat("_DisplacementMode", 2);
                dstMaterial.SetFloat("_HeightPoMAmplitude", srcMaterial.GetFloat("_Parallax") * 2f);
            }

            // ---------- Detail Map ----------
            bool hasDetailAlbedo = srcMaterial.GetTexture("_DetailAlbedoMap") != null;
            bool hasDetailNormal = srcMaterial.GetTexture("_DetailNormalMap") != null;

            if (hasDetailAlbedo || hasDetailNormal)
            {
                Texture2D       detailMap;
                TextureCombiner detailCombiner = new TextureCombiner(
                    TextureCombiner.GetTextureSafe(srcMaterial, "_DetailAlbedoMap", Color.grey), 4,     // Albedo (overlay)
                    TextureCombiner.GetTextureSafe(srcMaterial, "_DetailNormalMap", Color.grey), 1,     // Normal Y
                    TextureCombiner.midGrey, 1,                                                         // Smoothness
                    TextureCombiner.GetTextureSafe(srcMaterial, "_DetailNormalMap", Color.grey), 0      // Normal X
                    );
                string detailMapPath = AssetDatabase.GetAssetPath(srcMaterial);
                detailMapPath = detailMapPath.Remove(detailMapPath.Length - 4) + "_DetailMap.png";
                detailMap     = detailCombiner.Combine(detailMapPath);
                dstMaterial.SetTexture("_DetailMap", detailMap);
            }


            // Blend Mode
            int previousBlendMode = srcMaterial.GetInt("_Mode");

            switch (previousBlendMode)
            {
            case 0:     // Opaque
                dstMaterial.SetFloat("_SurfaceType", 0);
                dstMaterial.SetFloat("_BlendMode", 0);
                dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
                dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
                break;

            case 1:     // Cutout
                dstMaterial.SetFloat("_SurfaceType", 0);
                dstMaterial.SetFloat("_BlendMode", 0);
                dstMaterial.SetFloat("_AlphaCutoffEnable", 1);
                dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
                break;

            case 2:     // Fade -> Alpha + Disable preserve specular
                dstMaterial.SetFloat("_SurfaceType", 1);
                dstMaterial.SetFloat("_BlendMode", 0);
                dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
                dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 0);
                break;

            case 3:     // Transparent -> Alpha
                dstMaterial.SetFloat("_SurfaceType", 1);
                dstMaterial.SetFloat("_BlendMode", 0);
                dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
                dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
                break;
            }

            Color hdrEmission = srcMaterial.GetColor("_EmissionColor");

            // Get the _EMISSION keyword of the Standard shader
            if (!srcMaterial.IsKeywordEnabled("_EMISSION"))
            {
                hdrEmission = Color.black;
            }

            // Emission toggle of Particle Standard Surface
            if (srcMaterial.HasProperty("_EmissionEnabled"))
            {
                if (srcMaterial.GetFloat("_EmissionEnabled") == 0)
                {
                    hdrEmission = Color.black;
                }
            }

            dstMaterial.SetColor("_EmissiveColor", hdrEmission);

            HDEditorUtils.ResetMaterialKeywords(dstMaterial);
        }
Esempio n. 18
0
 /// <summary>
 /// Draws a light layer enum.
 /// </summary>
 /// <param name="position">The rect to draw.</param>
 /// <param name="property">The property to draw.</param>
 /// <param name="label">The label to draw.</param>
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 => HDEditorUtils.DrawLightLayerMask_Internal(position, label, property);
Esempio n. 19
0
        public override void OnInspectorGUI()
        {
            if (!HDRenderPipeline.currentAsset?.currentPlatformRenderPipelineSettings.supportSSAO ?? false)
            {
                EditorGUILayout.Space();
                HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support Ambient Occlusion.", MessageType.Error,
                                                     HDRenderPipelineUI.Expandable.Lighting, "m_RenderPipelineSettings.supportSSAO");
                return;
            }

            if (HDRenderPipeline.assetSupportsRayTracing)
            {
                PropertyField(m_RayTracing, EditorGUIUtility.TrTextContent("Ray Tracing (Preview)", "Enable ray traced ambient occlusion."));
            }

            // Shared attributes
            PropertyField(m_Intensity, EditorGUIUtility.TrTextContent("Intensity", "Controls the strength of the ambient occlusion effect. Increase this value to produce darker areas."));
            PropertyField(m_DirectLightingStrength, EditorGUIUtility.TrTextContent("Direct Lighting Strength", "Controls how much the ambient light affects occlusion."));

            // If ray tracing is supported and it is enabled on this volume, display the ray tracing options.
            if (HDRenderPipeline.assetSupportsRayTracing && m_RayTracing.overrideState.boolValue && m_RayTracing.value.boolValue)
            {
                PropertyField(m_LayerMask, EditorGUIUtility.TrTextContent("Layer Mask", "Layer mask used to include the objects for ambient occlusion."));
                base.OnInspectorGUI(); // Quality Setting
                using (new QualityScope(this))
                {
                    using (new IndentLevelScope())
                    {
                        PropertyField(m_RayLength, EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of ambient occlusion rays. The higher this value is, the more expensive ray traced ambient occlusion is."));
                        PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for ray traced ambient occlusion."));
                        PropertyField(m_Denoise, EditorGUIUtility.TrTextContent("Denoise", "Enable denoising on the ray traced ambient occlusion."));
                        {
                            using (new IndentLevelScope())
                                PropertyField(m_DenoiserRadius, EditorGUIUtility.TrTextContent("Denoiser Radius", "Radius parameter for the denoising."));
                        }
                    }
                }

                PropertyField(m_OccluderMotionRejection, EditorGUIUtility.TrTextContent("Occluder Motion Rejection", "When enabled, the occluder's movement should be considered a valid rejection condition."));
                PropertyField(m_ReceiverMotionRejection, EditorGUIUtility.TrTextContent("Receiver Motion Rejection", "When enabled, the receiver's movement should be considered a valid rejection condition."));
            }
            else
            {
                PropertyField(m_Radius, EditorGUIUtility.TrTextContent("Radius", "Sampling radius. Bigger the radius, wider AO will be achieved, risking to lose fine details and increasing cost of the effect due to increasing cache misses."));

                base.OnInspectorGUI(); // Quality Setting

                using (new QualityScope(this))
                {
                    using (new IndentLevelScope())
                    {
                        PropertyField(m_MaximumRadiusInPixels, EditorGUIUtility.TrTextContent("Maximum Radius In Pixels", "This poses a maximum radius in pixels that we consider. It is very important to keep this as tight as possible to preserve good performance. Note that this is the value used for 1080p when *not* running the effect at full resolution, it will be scaled accordingly for other resolutions."));
                        PropertyField(m_FullResolution, EditorGUIUtility.TrTextContent("Full Resolution", "The effect runs at full resolution. This increases quality, but also decreases performance significantly."));
                        PropertyField(m_StepCount, EditorGUIUtility.TrTextContent("Step Count", "Number of steps to take along one signed direction during horizon search (this is the number of steps in positive and negative direction)."));
                    }

                    PropertyField(m_TemporalAccumulation, EditorGUIUtility.TrTextContent("Temporal Accumulation", "Whether the results are accumulated over time or not. This can get better results cheaper, but it can lead to temporal artifacts. Requires Motion Vectors to be enabled."));

                    using (new IndentLevelScope())
                    {
                        if (!m_TemporalAccumulation.value.boolValue)
                        {
                            PropertyField(m_DirectionCount, EditorGUIUtility.TrTextContent("Direction Count", "Number of directions searched for occlusion at each each pixel."));

                            if (m_DirectionCount.value.intValue > 3)
                            {
                                EditorGUILayout.HelpBox("Performance will be seriously impacted by high direction count.", MessageType.Warning, wide: true);
                            }
                            PropertyField(m_BlurSharpness, EditorGUIUtility.TrTextContent("Blur sharpness", "Modify the non-temporal blur to change how sharp features are preserved. Lower values blurrier/softer, higher values sharper but with risk of noise."));
                        }
                        else
                        {
                            PropertyField(m_SpatialBilateralAggressiveness, EditorGUIUtility.TrTextContent("Bilateral Aggressiveness", "Higher this value, the less lenient with depth differences the spatial filter is. Increase if for example noticing white halos where AO should be."));
                            PropertyField(m_GhostingAdjustement, EditorGUIUtility.TrTextContent("Ghosting reduction", "Moving this factor closer to 0 will increase the amount of accepted samples during temporal accumulation, increasing the ghosting, but reducing the temporal noise."));
                            if (!m_FullResolution.value.boolValue)
                            {
                                PropertyField(m_BilateralUpsample, EditorGUIUtility.TrTextContent("Bilateral Upsample", "This upsample method preserves sharp edges better, however can result in visible aliasing and it is slightly more expensive."));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        public override void OnInspectorGUI()
        {
            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            if (!currentAsset?.currentPlatformRenderPipelineSettings.supportSSGI ?? false)
            {
                EditorGUILayout.Space();
                HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support Screen Space Global illumination.", MessageType.Error,
                                                     HDRenderPipelineUI.Expandable.Reflection, "m_RenderPipelineSettings.supportSSGI");
                return;
            }

            PropertyField(m_Enable);
            EditorGUILayout.Space();

            // If ray tracing is supported display the content of the volume component
            if (HDRenderPipeline.assetSupportsRayTracing)
            {
                PropertyField(m_Tracing);
            }

            // Flag to track if the ray tracing parameters were displayed
            RayCastingMode tracingMode = m_Tracing.value.GetEnumValue <RayCastingMode>();
            bool           rayTracingSettingsDisplayed = HDRenderPipeline.assetSupportsRayTracing &&
                                                         m_Tracing.overrideState.boolValue &&
                                                         tracingMode != RayCastingMode.RayMarching;

            using (new IndentLevelScope())
            {
                if (rayTracingSettingsDisplayed)
                {
                    PropertyField(m_LayerMask);
                    PropertyField(m_TextureLodBias);

                    using (new IndentLevelScope())
                    {
                        EditorGUILayout.LabelField("Fallback", EditorStyles.miniLabel);
                        PropertyField(m_RayMiss, k_RayMissFallbackHierarchyText);
                        PropertyField(m_LastBounce, k_LastBounceFallbackHierarchyText);
                    }

                    if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both)
                    {
                        if (tracingMode == RayCastingMode.RayTracing)
                        {
                            PropertyField(m_Mode);
                            using (new IndentLevelScope())
                            {
                                switch (m_Mode.value.GetEnumValue <RayTracingMode>())
                                {
                                case RayTracingMode.Performance:
                                {
                                    RayTracingPerformanceModeGUI(false);
                                }
                                break;

                                case RayTracingMode.Quality:
                                {
                                    RayTracingQualityModeGUI();
                                }
                                break;
                                }
                            }
                        }
                        else
                        {
                            RayTracingPerformanceModeGUI(true);
                        }
                    }
                    else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality)
                    {
                        if (tracingMode == RayCastingMode.RayTracing)
                        {
                            RayTracingQualityModeGUI();
                        }
                        else
                        {
                            HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support the mixed mode which is only available in performance mode.", MessageType.Error,
                                                                 HDRenderPipelineUI.Expandable.Rendering, "m_RenderPipelineSettings.supportedRayTracingMode");
                        }
                    }
                    else
                    {
                        RayTracingPerformanceModeGUI(tracingMode == RayCastingMode.Mixed);
                    }
                    PropertyField(m_ReceiverMotionRejection);
                }
                else
                {
                    base.OnInspectorGUI(); // Quality Setting

                    using (new IndentLevelScope())
                        using (new QualityScope(this))
                        {
                            PropertyField(m_RaySteps);
                            DenoiserSSGUI();
                        }
                    PropertyField(m_FullResolutionSS, k_FullResolutionSSText);
                    PropertyField(m_DepthBufferThickness, k_DepthBufferThicknessText);
                    PropertyField(m_RayMiss, k_RayMissFallbackHierarchyText);
                }
            }
        }
Esempio n. 21
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            if (!currentAsset?.currentPlatformRenderPipelineSettings.supportWater ?? false)
            {
                EditorGUILayout.Space();
                HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support Water Surfaces.", MessageType.Error,
                                                     HDRenderPipelineUI.Expandable.Water, "m_RenderPipelineSettings.supportWater");
                return;
            }

            EditorGUILayout.LabelField("Geometry", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_Infinite);
                using (new IndentLevelScope())
                {
                    if (!m_Infinite.boolValue)
                    {
                        EditorGUILayout.PropertyField(m_GeometryType);
                        if ((WaterSurface.WaterGeometryType)m_GeometryType.enumValueIndex == WaterSurface.WaterGeometryType.Custom)
                        {
                            EditorGUILayout.PropertyField(m_Geometry);
                        }
                    }
                }
            }

            bool highBandCount = false;

            EditorGUILayout.LabelField("Simulation", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_WaterMaxPatchSize);
                m_WaterMaxPatchSize.floatValue = Mathf.Clamp(m_WaterMaxPatchSize.floatValue, 25.0f, 10000.0f);

                EditorGUILayout.PropertyField(m_HighBandCount);
                highBandCount = m_HighBandCount.boolValue;
                using (new IndentLevelScope())
                {
                    if (m_HighBandCount.boolValue)
                    {
                        EditorGUI.BeginChangeCheck();
                        m_Amplitude.vector4Value = EditorGUILayout.Vector4Field(k_Amplitude, m_Amplitude.vector4Value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            SanitizeVector4(m_Amplitude, 0.0f, 1.0f);
                        }
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector2 amplitude2D = new Vector2(m_Amplitude.vector4Value.x, m_Amplitude.vector4Value.y);
                        amplitude2D = EditorGUILayout.Vector2Field(k_Amplitude, amplitude2D);
                        m_Amplitude.vector4Value = new Vector4(amplitude2D.x, amplitude2D.y, m_Amplitude.vector4Value.z, m_Amplitude.vector4Value.w);
                        if (EditorGUI.EndChangeCheck())
                        {
                            SanitizeVector4(m_Amplitude, 0.0f, 1.0f);
                        }
                    }
                }

                m_Choppiness.floatValue     = EditorGUILayout.Slider(k_Choppiness, m_Choppiness.floatValue, 0.0f, 1.0f);
                m_TimeMultiplier.floatValue = EditorGUILayout.Slider(k_TimeMultiplier, m_TimeMultiplier.floatValue, 0.0f, 10.0f);
            }

            EditorGUILayout.LabelField("Material", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_CustomMaterial);
                // Water Smoothness from 0.0f to 0.99f
                m_WaterSmoothness.floatValue = EditorGUILayout.Slider(k_WaterSmoothness, m_WaterSmoothness.floatValue, 0.0f, 0.99f);
            }

            EditorGUILayout.LabelField("Refraction", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_RefractionColor);
                m_MaxRefractionDistance.floatValue = EditorGUILayout.Slider(k_MaxRefractionDistance, m_MaxRefractionDistance.floatValue, 0.0f, 3.5f);
                m_AbsorptionDistance.floatValue    = EditorGUILayout.Slider(k_AbsorptionDistance, m_AbsorptionDistance.floatValue, 0.0f, 100.0f);
            }

            EditorGUILayout.LabelField("Scattering", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_ScatteringColor);
                m_HeightScattering.floatValue          = EditorGUILayout.Slider(k_HeightScattering, m_HeightScattering.floatValue, 0.0f, 1.0f);
                m_DisplacementScattering.floatValue    = EditorGUILayout.Slider(k_DisplacementScattering, m_DisplacementScattering.floatValue, 0.0f, 1.0f);
                m_DirectLightTipScattering.floatValue  = EditorGUILayout.Slider(k_DirectLightTipScattering, m_DirectLightTipScattering.floatValue, 0.0f, 1.0f);
                m_DirectLightBodyScattering.floatValue = EditorGUILayout.Slider(k_DirectLightBodyScattering, m_DirectLightBodyScattering.floatValue, 0.0f, 1.0f);
            }

            EditorGUILayout.LabelField("Caustics", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_Caustics);
                if (m_Caustics.boolValue)
                {
                    EditorGUILayout.PropertyField(m_CausticsIntensity);
                    m_CausticsIntensity.floatValue = Mathf.Max(m_CausticsIntensity.floatValue, 0.0f);

                    EditorGUILayout.PropertyField(m_CausticsPlaneBlendDistance);
                    m_CausticsPlaneBlendDistance.floatValue = Mathf.Max(m_CausticsPlaneBlendDistance.floatValue, 0.0f);

                    EditorGUILayout.PropertyField(m_CausticsAlgorithm);

                    if ((WaterSurface.WaterCausticsType)m_CausticsAlgorithm.enumValueIndex == WaterSurface.WaterCausticsType.Simulation)
                    {
                        using (new IndentLevelScope())
                        {
                            EditorGUILayout.PropertyField(m_CausticsResolution);
                            m_CausticsBand.intValue = EditorGUILayout.IntSlider(k_CausticsBand, m_CausticsBand.intValue, 0, highBandCount ? 3 : 1);

                            EditorGUILayout.PropertyField(m_CausticsVirtualPlaneDistance);
                            m_CausticsVirtualPlaneDistance.floatValue = Mathf.Max(m_CausticsVirtualPlaneDistance.floatValue, 0.001f);
                        }
                    }
                    else
                    {
                        using (new IndentLevelScope())
                        {
                            EditorGUILayout.PropertyField(m_CausticsTiling);
                            m_CausticsTiling.floatValue = Mathf.Max(m_CausticsTiling.floatValue, 0.001f);
                            EditorGUILayout.PropertyField(m_CausticsSpeed);
                            m_CausticsSpeed.floatValue = Mathf.Clamp(m_CausticsSpeed.floatValue, 0.0f, 100.0f);
                        }
                    }
                }
            }

            EditorGUILayout.LabelField("Masking", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_WaterMask);
                if (m_WaterMask.objectReferenceValue != null)
                {
                    EditorGUILayout.PropertyField(m_WaterMaskExtent);
                    EditorGUILayout.PropertyField(m_WaterMaskOffset);
                }
            }

            EditorGUILayout.LabelField("Foam", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                // Surface foam
                m_SimulationFoamAmount.floatValue     = EditorGUILayout.Slider(k_SimulationFoamAmount, m_SimulationFoamAmount.floatValue, 0.0f, 1.0f);
                m_SimulationFoamDrag.floatValue       = EditorGUILayout.Slider(k_SimulationFoamDrag, m_SimulationFoamDrag.floatValue, 0.0f, 1.0f);
                m_SimulationFoamSmoothness.floatValue = EditorGUILayout.Slider(k_SimulationFoamSmoothness, m_SimulationFoamSmoothness.floatValue, 0.0f, 1.0f);

                // Foam masking
                EditorGUILayout.PropertyField(m_FoamMask);
                if (m_FoamMask.objectReferenceValue != null)
                {
                    using (new IndentLevelScope())
                    {
                        EditorGUILayout.PropertyField(m_FoamMaskExtent);
                        EditorGUILayout.PropertyField(m_FoamMaskOffset);
                    }
                }
            }

            EditorGUILayout.LabelField("Wind", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_WindOrientation);
                m_WindSpeed.floatValue         = EditorGUILayout.Slider(k_WindSpeed, m_WindSpeed.floatValue, 0.0f, 100.0f);
                m_WindAffectCurrent.floatValue = EditorGUILayout.Slider(k_WindAffectsCurrent, m_WindAffectCurrent.floatValue, 0.0f, 1.0f);
                EditorGUILayout.PropertyField(m_WindFoamCurve);
            }

            // Decal controls
            EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel);
            if (HDRenderPipeline.currentPipeline != null && HDRenderPipeline.currentPipeline.currentPlatformRenderPipelineSettings.supportDecals)
            {
                bool decalLayerEnabled = false;
                using (new IndentLevelScope())
                {
                    decalLayerEnabled = HDRenderPipeline.currentPipeline.currentPlatformRenderPipelineSettings.supportDecalLayers;
                    using (new EditorGUI.DisabledScope(!decalLayerEnabled))
                    {
                        EditorGUILayout.PropertyField(m_DecalLayerMask);
                    }
                }

                if (!decalLayerEnabled)
                {
                    HDEditorUtils.QualitySettingsHelpBox("Enable 'Decal Layers' in your HDRP Asset if you want to control which decals affect water surfaces. There is a performance cost of enabling this option.",
                                                         MessageType.Info, HDRenderPipelineUI.Expandable.Decal, "m_RenderPipelineSettings.supportDecalLayers");
                    EditorGUILayout.Space();
                }
            }

            if (HDRenderPipeline.currentPipeline != null)
            {
                bool lightLayersEnabled = HDRenderPipeline.currentPipeline.currentPlatformRenderPipelineSettings.supportLightLayers;
                using (new IndentLevelScope())
                {
                    using (new EditorGUI.DisabledScope(!lightLayersEnabled))
                    {
                        EditorGUILayout.PropertyField(m_LightLayerMask);
                    }
                }

                if (!lightLayersEnabled)
                {
                    HDEditorUtils.QualitySettingsHelpBox("Enable 'Light Layers' in your HDRP Asset if you want defined which lights affect water surfaces. There is a performance cost of enabling this option.",
                                                         MessageType.Info, HDRenderPipelineUI.Expandable.Lighting, "m_RenderPipelineSettings.supportLightLayers");
                    EditorGUILayout.Space();
                }
            }

            // Under Water Rendering
            EditorGUILayout.LabelField("Underwater", EditorStyles.boldLabel);
            using (new IndentLevelScope())
            {
                EditorGUILayout.PropertyField(m_UnderWater);
                using (new IndentLevelScope())
                {
                    if (m_UnderWater.boolValue)
                    {
                        // Bounds data
                        if (!m_Infinite.boolValue)
                        {
                            EditorGUILayout.PropertyField(m_VolumeBounds);
                            m_VolumeBounds.floatValue = Mathf.Max(m_VolumeBounds.floatValue, 0.0f);
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(m_VolumeDepth);
                        }

                        // Priority
                        EditorGUILayout.PropertyField(m_VolumePriority);
                        m_VolumePriority.intValue = m_VolumePriority.intValue > 0 ? m_VolumePriority.intValue : 0;

                        // Transition size
                        EditorGUILayout.PropertyField(m_TransitionSize);
                        m_TransitionSize.floatValue = Mathf.Max(m_TransitionSize.floatValue, 0.0f);

                        // View distance
                        EditorGUILayout.PropertyField(m_AbsorbtionDistanceMultiplier);
                        m_AbsorbtionDistanceMultiplier.floatValue = Mathf.Max(m_AbsorbtionDistanceMultiplier.floatValue, 0.0f);
                    }
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 22
0
        public override void Tick(
            SceneStateHash sceneStateHash,
            IScriptableBakedReflectionSystemStageNotifier handle
            )
        {
            if (!AreAllOpenedSceneSaved())
            {
                handle.SetIsDone(true);
                return;
            }

            // On the C# side, we don't have non blocking asset import APIs, and we don't want to block the
            //   UI when the user is editing the world.
            //   So, we skip the baking when the user is editing any UI control.
            if (GUIUtility.hotControl != 0)
            {
                return;
            }

            if (!IsCurrentSRPValid(out HDRenderPipeline hdPipeline))
            {
                if (ShouldIssueWarningForCurrentSRP())
                {
                    Debug.LogWarning("HDBakedReflectionSystem work with HDRP, " +
                                     "Either switch your render pipeline or use a different reflection system. You may need to trigger a " +
                                     "C# domain reload to initialize the appropriate reflection system. One way to do this is to compile a script.");
                }

                handle.ExitStage((int)BakingStages.ReflectionProbes);
                handle.SetIsDone(true);
                return;
            }

            var ambientProbeHash = sceneStateHash.ambientProbeHash;
            var sceneObjectsHash = sceneStateHash.sceneObjectsHash;
            var skySettingsHash  = sceneStateHash.skySettingsHash;

            DeleteCubemapAssets(true);

            // Explanation of the algorithm:
            // 1. First we create the hash of the world that can impact the reflection probes.
            // 2. Then for each probe, we calculate a hash that represent what this specific probe should have baked.
            // 3. We compare those hashes against the baked one and decide:
            //   a. If we have to remove a baked data
            //   b. If we have to bake a probe
            // 4. Bake all required probes
            //   a. Bake probe that were added or modified
            //   b. Bake probe with a missing baked texture
            // 5. Remove unused baked data
            // 6. Update probe assets

            // == 1. ==
            var allProbeDependencyHash = new Hash128();

            // TODO: All baked probes depend on custom probes (hash all custom probes and set as dependency)
            // TODO: All baked probes depend on HDRP specific Light settings
            HashUtilities.AppendHash(ref ambientProbeHash, ref allProbeDependencyHash);
            HashUtilities.AppendHash(ref sceneObjectsHash, ref allProbeDependencyHash);
            HashUtilities.AppendHash(ref skySettingsHash, ref allProbeDependencyHash);

            var bakedProbes     = HDProbeSystem.bakedProbes;
            var bakedProbeCount = HDProbeSystem.bakedProbeCount;

            // == 2. ==
            var states = stackalloc HDProbeBakingState[bakedProbeCount];
            // A list of indices of probe we may want to force to rebake, even if the hashes matches.
            // Usually, add a probe when something external to its state or the world state forces the bake.
            var probeForcedToBakeIndices      = stackalloc int[bakedProbeCount];
            var probeForcedToBakeIndicesCount = 0;
            var probeForcedToBakeIndicesList  = new ListBuffer <int>(
                probeForcedToBakeIndices,
                &probeForcedToBakeIndicesCount,
                bakedProbeCount
                );

            ComputeProbeInstanceID(bakedProbes, states);
            ComputeProbeSettingsHashes(bakedProbes, states);
            // TODO: Handle bounce dependency here
            ComputeProbeBakingHashes(bakedProbeCount, allProbeDependencyHash, states);

            // Force to rebake probe with missing baked texture
            for (var i = 0; i < bakedProbeCount; ++i)
            {
                var instanceId = states[i].instanceID;
                var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                if (probe.bakedTexture != null && !probe.bakedTexture.Equals(null))
                {
                    continue;
                }

                probeForcedToBakeIndicesList.TryAdd(i);
            }

            CoreUnsafeUtils.QuickSort <HDProbeBakingState, Hash128, HDProbeBakingState.ProbeBakingHash>(
                bakedProbeCount, states
                );

            int operationCount = 0, addCount = 0, remCount = 0;
            var maxProbeCount = Mathf.Max(bakedProbeCount, m_HDProbeBakedStates.Length);
            var addIndices    = stackalloc int[maxProbeCount];
            var remIndices    = stackalloc int[maxProbeCount];

            if (m_HDProbeBakedStates.Length == 0)
            {
                for (int i = 0; i < bakedProbeCount; ++i)
                {
                    addIndices[addCount++] = i;
                }
                operationCount = addCount;
            }
            else
            {
                fixed(HDProbeBakedState *oldBakedStates = &m_HDProbeBakedStates[0])
                {
                    // == 3. ==
                    // Compare hashes between baked probe states and desired probe states
                    operationCount = CoreUnsafeUtils.CompareHashes <
                        HDProbeBakedState, HDProbeBakedState.ProbeBakedHash,
                        HDProbeBakingState, HDProbeBakingState.ProbeBakingHash
                        > (
                        m_HDProbeBakedStates.Length, oldBakedStates, // old hashes
                        bakedProbeCount, states,                     // new hashes
                        addIndices, remIndices,
                        out addCount, out remCount
                        );
                }
            }

            if (operationCount > 0 || probeForcedToBakeIndicesList.Count > 0)
            {
                // == 4. ==
                var cubemapSize = (int)hdPipeline.currentPlatformRenderPipelineSettings.lightLoopSettings.reflectionCubemapSize;
                // We force RGBAHalf as we don't support 11-11-10 textures (only RT)
                var probeFormat = GraphicsFormat.R16G16B16A16_SFloat;

                var cubeRT = HDRenderUtilities.CreateReflectionProbeRenderTarget(cubemapSize, probeFormat);

                handle.EnterStage(
                    (int)BakingStages.ReflectionProbes,
                    string.Format("Reflection Probes | {0} jobs", addCount),
                    0
                    );

                // Compute indices of probes to bake: added, modified probe or with a missing baked texture.
                var toBakeIndices      = stackalloc int[bakedProbeCount];
                var toBakeIndicesCount = 0;
                var toBakeIndicesList  = new ListBuffer <int>(toBakeIndices, &toBakeIndicesCount, bakedProbeCount);
                {
                    // Note: we will add probes from change check and baked texture missing check.
                    //   So we can add at most 2 time the probe in the list.
                    var toBakeIndicesTmp      = stackalloc int[bakedProbeCount * 2];
                    var toBakeIndicesTmpCount = 0;
                    var toBakeIndicesTmpList  =
                        new ListBuffer <int>(toBakeIndicesTmp, &toBakeIndicesTmpCount, bakedProbeCount * 2);

                    // Add the indices from the added or modified detection check
                    toBakeIndicesTmpList.TryCopyFrom(addIndices, addCount);
                    // Add the probe with missing baked texture check
                    probeForcedToBakeIndicesList.TryCopyTo(toBakeIndicesTmpList);

                    // Sort indices
                    toBakeIndicesTmpList.QuickSort();
                    // Add to final list without the duplicates
                    var lastValue = int.MaxValue;
                    for (var i = 0; i < toBakeIndicesTmpList.Count; ++i)
                    {
                        if (lastValue == toBakeIndicesTmpList.GetUnchecked(i))
                        {
                            // Skip duplicates
                            continue;
                        }

                        lastValue = toBakeIndicesTmpList.GetUnchecked(i);
                        toBakeIndicesList.TryAdd(lastValue);
                    }
                }

                // Render probes that were added or modified
                for (int i = 0; i < toBakeIndicesList.Count; ++i)
                {
                    handle.EnterStage(
                        (int)BakingStages.ReflectionProbes,
                        string.Format("Reflection Probes | {0} jobs", addCount),
                        i / (float)toBakeIndicesCount
                        );

                    var index      = toBakeIndicesList.GetUnchecked(i);
                    var instanceId = states[index].instanceID;
                    var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                    var cacheFile  = GetGICacheFileForHDProbe(states[index].probeBakingHash);

                    // Get from cache or render the probe
                    if (!File.Exists(cacheFile))
                    {
                        var planarRT = HDRenderUtilities.CreatePlanarProbeRenderTarget((int)probe.resolution, probeFormat);
                        RenderAndWriteToFile(probe, cacheFile, cubeRT, planarRT);
                        planarRT.Release();
                    }
                }
                cubeRT.Release();

                // Copy texture from cache
                for (int i = 0; i < toBakeIndicesList.Count; ++i)
                {
                    var index      = toBakeIndicesList.GetUnchecked(i);
                    var instanceId = states[index].instanceID;
                    var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                    var cacheFile  = GetGICacheFileForHDProbe(states[index].probeBakingHash);

                    if (string.IsNullOrEmpty(probe.gameObject.scene.path))
                    {
                        continue;
                    }

                    Assert.IsTrue(File.Exists(cacheFile));

                    var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
                    HDBakingUtilities.CreateParentDirectoryIfMissing(bakedTexturePath);
                    Checkout(bakedTexturePath);
                    // Checkout will make those file writeable, but this is not immediate,
                    // so we retries when this fails.
                    if (!HDEditorUtils.CopyFileWithRetryOnUnauthorizedAccess(cacheFile, bakedTexturePath))
                    {
                        return;
                    }
                }
                // AssetPipeline bug
                // Sometimes, the baked texture reference is destroyed during 'AssetDatabase.StopAssetEditing()'
                //   thus, the reference to the baked texture in the probe is lost
                // Although, importing twice the texture seems to workaround the issue
                for (int j = 0; j < 2; ++j)
                {
                    AssetDatabase.StartAssetEditing();
                    for (int i = 0; i < bakedProbeCount; ++i)
                    {
                        var index      = toBakeIndicesList.GetUnchecked(i);
                        var instanceId = states[index].instanceID;
                        var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                        if (string.IsNullOrEmpty(probe.gameObject.scene.path))
                        {
                            continue;
                        }

                        var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
                        AssetDatabase.ImportAsset(bakedTexturePath);
                        ImportAssetAt(probe, bakedTexturePath);
                    }
                    AssetDatabase.StopAssetEditing();
                }
                // Import assets
                AssetDatabase.StartAssetEditing();
                for (int i = 0; i < toBakeIndicesList.Count; ++i)
                {
                    var index      = toBakeIndicesList.GetUnchecked(i);
                    var instanceId = states[index].instanceID;
                    var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                    if (string.IsNullOrEmpty(probe.gameObject.scene.path))
                    {
                        continue;
                    }

                    var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
                    var bakedTexture     = AssetDatabase.LoadAssetAtPath <Texture>(bakedTexturePath);
                    Assert.IsNotNull(bakedTexture, "The baked texture was imported before, " +
                                     "so it must exists in AssetDatabase");

                    probe.SetTexture(ProbeSettings.Mode.Baked, bakedTexture);
                    EditorUtility.SetDirty(probe);
                }
                AssetDatabase.StopAssetEditing();

                // == 5. ==

                // Create new baked state array
                var targetSize        = m_HDProbeBakedStates.Length - remCount + toBakeIndicesList.Count;
                var targetBakedStates = stackalloc HDProbeBakedState[targetSize];
                // Copy baked state that are not removed
                var targetI = 0;
                for (int i = 0; i < m_HDProbeBakedStates.Length; ++i)
                {
                    if (CoreUnsafeUtils.IndexOf(remIndices, remCount, i) != -1)
                    {
                        continue;
                    }
                    Assert.IsTrue(targetI < targetSize);
                    targetBakedStates[targetI++] = m_HDProbeBakedStates[i];
                }
                // Add new baked states
                for (int i = 0; i < toBakeIndicesList.Count; ++i)
                {
                    var state = states[toBakeIndicesList.GetUnchecked(i)];
                    Assert.IsTrue(targetI < targetSize);
                    targetBakedStates[targetI++] = new HDProbeBakedState
                    {
                        instanceID     = state.instanceID,
                        probeBakedHash = state.probeBakingHash
                    };
                }
                CoreUnsafeUtils.QuickSort <HDProbeBakedState, Hash128, HDProbeBakedState.ProbeBakedHash>(
                    targetI, targetBakedStates
                    );

                Array.Resize(ref m_HDProbeBakedStates, targetSize);
                if (targetSize > 0)
                {
                    fixed(HDProbeBakedState *bakedStates = &m_HDProbeBakedStates[0])
                    {
                        UnsafeUtility.MemCpy(
                            bakedStates,
                            targetBakedStates,
                            sizeof(HDProbeBakedState) * targetSize
                            );
                    }
                }

                // Update state hash
                Array.Resize(ref m_StateHashes, m_HDProbeBakedStates.Length);
                for (int i = 0; i < m_HDProbeBakedStates.Length; ++i)
                {
                    m_StateHashes[i] = m_HDProbeBakedStates[i].probeBakedHash;
                }
                stateHashes = m_StateHashes;
            }

            handle.ExitStage((int)BakingStages.ReflectionProbes);

            handle.SetIsDone(true);
        }
        public override void OnInspectorGUI()
        {
            // This whole editor has nothing to display if the SSR feature is not supported
            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            if (!currentAsset?.currentPlatformRenderPipelineSettings.supportSSR ?? false)
            {
                EditorGUILayout.Space();
                HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support Screen Space Reflection.", MessageType.Error,
                                                     HDRenderPipelineUI.Expandable.Reflection, "m_RenderPipelineSettings.supportSSR");
                return;
            }

            PropertyField(m_Enable, k_EnabledOpaque);

            bool transparentSSRSupported = currentAsset.currentPlatformRenderPipelineSettings.supportSSR &&
                                           currentAsset.currentPlatformRenderPipelineSettings.supportSSRTransparent &&
                                           currentAsset.currentPlatformRenderPipelineSettings.supportTransparentDepthPrepass;

            if (transparentSSRSupported)
            {
                PropertyField(m_EnableTransparent, k_EnabledTransparent);
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("The current HDRP Asset does not support Transparent Screen Space Reflection.", MessageType.Info, wide: true);
            }

            // If ray tracing is supported display the tracing choice
            if (HDRenderPipeline.assetSupportsRayTracing)
            {
                PropertyField(m_Tracing, k_TracingText);
            }

            // Flag to track if the ray tracing parameters were displayed
            RayCastingMode tracingMode = m_Tracing.value.GetEnumValue <RayCastingMode>();
            bool           rayTracingSettingsDisplayed = HDRenderPipeline.assetSupportsRayTracing &&
                                                         m_Tracing.overrideState.boolValue &&
                                                         tracingMode != RayCastingMode.RayMarching;

            // The rest of the ray tracing UI is only displayed if the asset supports ray tracing and the checkbox is checked.
            if (rayTracingSettingsDisplayed)
            {
                RayTracedReflectionGUI(tracingMode);
            }
            else
            {
                PropertyField(m_UsedAlgorithm, k_Algo);

                // Shared Data
                PropertyField(m_MinSmoothness, k_MinimumSmoothnessText);
                PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
                PropertyField(m_ReflectSky, k_ReflectSkyText);
                m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);

                PropertyField(m_ScreenFadeDistance, k_ScreenFaceDistanceText);
                PropertyField(m_DepthBufferThickness, k_DepthBufferThicknessText);

                m_DepthBufferThickness.value.floatValue = Mathf.Clamp(m_DepthBufferThickness.value.floatValue, 0.001f, 1.0f);

                base.OnInspectorGUI();

                using (new IndentLevelScope())
                    using (new QualityScope(this))
                    {
                        PropertyField(m_RayMaxIterations, k_RayMaxIterationsText);
                        m_RayMaxIterations.value.intValue = Mathf.Max(0, m_RayMaxIterations.value.intValue);
                    }
                if (m_UsedAlgorithm.value.intValue == (int)ScreenSpaceReflectionAlgorithm.PBRAccumulation)
                {
                    PropertyField(m_AccumulationFactor, k_AccumulationFactorText);
                    PropertyField(m_EnableWorldSpeedRejection, k_EnableSpeedRejectionText);
                    if (BeginAdditionalPropertiesScope())
                    {
                        if (m_EnableWorldSpeedRejection.value.boolValue)
                        {
                            using (new IndentLevelScope())
                            {
                                PropertyField(m_SpeedRejectionScalerFactor, k_SpeedRejectionScalerFactorText);
                                PropertyField(m_SpeedSmoothReject, k_SpeedSmoothRejectText);
                            }
                        }
                        PropertyField(m_SpeedRejectionFactor, k_SpeedRejectionFactorText);
                        if (!m_SpeedSurfaceOnly.value.boolValue && !m_SpeedTargetOnly.value.boolValue)
                        {
                            m_SpeedSurfaceOnly.value.boolValue = true;
                        }
                        PropertyField(m_SpeedSurfaceOnly, k_SpeedSurfaceOnlyText);
                        PropertyField(m_SpeedTargetOnly, k_SpeedTargetOnlyText);
                        PropertyField(m_BiasFactor, k_BiasFactorText);
                    }
                    EndAdditionalPropertiesScope();
                }
            }
        }
        void DrawField(Field field, bool withOverride)
        {
            int indentLevel = attributes[field.field].indentLevel;

            if (indentLevel == 0)
            {
                --EditorGUI.indentLevel;    //alignment provided by the space for override checkbox
            }
            else
            {
                for (int i = indentLevel - 1; i > 0; --i)
                {
                    ++EditorGUI.indentLevel;
                }
            }
            bool enabled = field.IsOverrideableWithDependencies(serializedFrameSettings, defaultFrameSettings);

            withOverride &= enabled & GUI.enabled;
            bool shouldBeDisabled = withOverride || !enabled || !GUI.enabled;

            const int k_IndentPerLevel         = 15;
            const int k_CheckBoxWidth          = 15;
            const int k_CheckboxLabelSeparator = 5;
            const int k_LabelFieldSeparator    = 2;
            float     indentValue = k_IndentPerLevel * EditorGUI.indentLevel;

            Rect lineRect     = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
            Rect overrideRect = lineRect;

            overrideRect.width = k_CheckBoxWidth;
            Rect labelRect = lineRect;

            labelRect.x    += k_CheckBoxWidth + k_CheckboxLabelSeparator;
            labelRect.width = EditorGUIUtility.labelWidth - indentValue;
            Rect fieldRect = lineRect;

            fieldRect.x      = labelRect.xMax + k_LabelFieldSeparator;
            fieldRect.width -= fieldRect.x - lineRect.x;

            if (withOverride)
            {
                int currentIndent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;

                bool mixedValue    = serializedFrameSettings.HaveMultipleOverride(field.field);
                bool originalValue = serializedFrameSettings.GetOverrides(field.field) && !mixedValue;
                overrideRect.yMin += 4f;

                // MixedValueState is handled by style for small tickbox for strange reason
                //EditorGUI.showMixedValue = mixedValue;
                bool modifiedValue = EditorGUI.Toggle(overrideRect, overrideTooltip, originalValue, mixedValue? CoreEditorStyles.smallMixedTickbox : CoreEditorStyles.smallTickbox);
                //EditorGUI.showMixedValue = false;

                if (originalValue ^ modifiedValue)
                {
                    serializedFrameSettings.SetOverrides(field.field, modifiedValue);
                }

                shouldBeDisabled      = !modifiedValue;
                EditorGUI.indentLevel = currentIndent;
            }

            using (new SerializedFrameSettings.TitleDrawingScope(labelRect, field.label, serializedFrameSettings))
            {
                HDEditorUtils.HandlePrefixLabelWithIndent(lineRect, labelRect, field.label);
            }

            using (new EditorGUI.DisabledScope(shouldBeDisabled))
            {
                EditorGUI.showMixedValue = serializedFrameSettings.HaveMultipleValue(field.field) || field.hasMixedValues;
                using (new EditorGUILayout.VerticalScope())
                {
                    //the following block will display a default value if provided instead of actual value (case if(true))
                    if (shouldBeDisabled)
                    {
                        if (field.overridedDefaultValue == null)
                        {
                            switch (attributes[field.field].type)
                            {
                            case FrameSettingsFieldAttribute.DisplayType.BoolAsCheckbox:
                                DrawFieldShape(fieldRect, defaultFrameSettings.IsEnabled(field.field));
                                break;

                            case FrameSettingsFieldAttribute.DisplayType.BoolAsEnumPopup:
                                //shame but it is not possible to use Convert.ChangeType to convert int into enum in current C#
                                //rely on string parsing for the moment
                                var oldEnumValue = Enum.Parse(attributes[field.field].targetType, defaultFrameSettings.IsEnabled(field.field) ? "1" : "0");
                                DrawFieldShape(fieldRect, oldEnumValue);
                                break;

                            case FrameSettingsFieldAttribute.DisplayType.Others:
                                var oldValue = field.customGetter();
                                DrawFieldShape(fieldRect, oldValue);
                                break;

                            default:
                                throw new ArgumentException("Unknown FrameSettingsFieldAttribute");
                            }
                        }
                        else
                        {
                            DrawFieldShape(fieldRect, field.overridedDefaultValue);
                        }
                    }
                    else
                    {
                        switch (attributes[field.field].type)
                        {
                        case FrameSettingsFieldAttribute.DisplayType.BoolAsCheckbox:
                            bool oldBool = serializedFrameSettings.IsEnabled(field.field) ?? false;
                            bool newBool = (bool)DrawFieldShape(fieldRect, oldBool);
                            if (oldBool ^ newBool)
                            {
                                Undo.RecordObject(serializedFrameSettings.serializedObject.targetObject, "Changed FrameSettings " + field.field);
                                serializedFrameSettings.SetEnabled(field.field, newBool);
                            }
                            break;

                        case FrameSettingsFieldAttribute.DisplayType.BoolAsEnumPopup:
                            //shame but it is not possible to use Convert.ChangeType to convert int into enum in current C#
                            //Also, Enum.Equals and Enum operator!= always send true here. As it seams to compare object reference instead of value.
                            var    oldBoolValue    = serializedFrameSettings.IsEnabled(field.field);
                            int    oldEnumIntValue = -1;
                            int    newEnumIntValue;
                            object newEnumValue;
                            if (oldBoolValue.HasValue)
                            {
                                var oldEnumValue = Enum.GetValues(attributes[field.field].targetType).GetValue(oldBoolValue.Value ? 1 : 0);
                                newEnumValue    = Convert.ChangeType(DrawFieldShape(fieldRect, oldEnumValue), attributes[field.field].targetType);
                                oldEnumIntValue = ((IConvertible)oldEnumValue).ToInt32(System.Globalization.CultureInfo.CurrentCulture);
                                newEnumIntValue = ((IConvertible)newEnumValue).ToInt32(System.Globalization.CultureInfo.CurrentCulture);
                            }
                            else     //in multi edition, do not assume any previous value
                            {
                                newEnumIntValue = EditorGUI.Popup(fieldRect, -1, Enum.GetNames(attributes[field.field].targetType));
                                newEnumValue    = newEnumIntValue < 0 ? null : Enum.GetValues(attributes[field.field].targetType).GetValue(newEnumIntValue);
                            }
                            if (oldEnumIntValue != newEnumIntValue)
                            {
                                Undo.RecordObject(serializedFrameSettings.serializedObject.targetObject, "Changed FrameSettings " + field.field);
                                serializedFrameSettings.SetEnabled(field.field, Convert.ToInt32(newEnumValue) == 1);
                            }
                            break;

                        case FrameSettingsFieldAttribute.DisplayType.Others:
                            var oldValue = field.customGetter();
                            EditorGUI.BeginChangeCheck();
                            var newValue = DrawFieldShape(fieldRect, oldValue);
                            // We need an extensive check here, otherwise in some case with boxing or polymorphism
                            // the != operator won't be accurate. (This is the case for enum types).
                            var valuesAreEquals = oldValue == null && newValue == null || oldValue != null && oldValue.Equals(newValue);
                            // If the UI reported a change, we also assign values.
                            // When assigning to a multiple selection, the equals check may fail while there was indeed a change.
                            if (EditorGUI.EndChangeCheck() || !valuesAreEquals)
                            {
                                Undo.RecordObject(serializedFrameSettings.serializedObject.targetObject, "Changed FrameSettings " + field.field);
                                field.customSetter(newValue);
                            }
                            break;

                        default:
                            throw new ArgumentException("Unknown FrameSettingsFieldAttribute");
                        }
                    }
                }
                EditorGUI.showMixedValue = false;
            }

            if (indentLevel == 0)
            {
                ++EditorGUI.indentLevel;
            }
            else
            {
                for (int i = indentLevel - 1; i > 0; --i)
                {
                    --EditorGUI.indentLevel;
                }
            }
        }
Esempio n. 25
0
        protected virtual LightingExplorerTableColumn[] GetHDLightColumns()
        {
            return(new[]
            {
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, HDStyles.Name, null, 200),                                               // 0: Name
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.On, "m_Enabled", 25),                                       // 1: Enabled
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.Type, "m_Type", 60),                                            // 2: Type
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.Mode, "m_Lightmapping", 60),                                    // 3: Mixed mode
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.Range, "m_Range", 60),                                          // 4: Range
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.ColorTemperatureMode, "m_UseColorTemperature", 100),        // 5: Color Temperature Mode
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Color, HDStyles.Color, "m_Color", 60),                                         // 6: Color
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.ColorTemperature, "m_ColorTemperature", 100, (r, prop, dep) => // 7: Color Temperature
                {
                    if (prop.serializedObject.FindProperty("m_UseColorTemperature").boolValue)
                    {
                        prop = prop.serializedObject.FindProperty("m_ColorTemperature");
                        prop.floatValue = EditorGUI.FloatField(r, prop.floatValue);
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.Intensity, "m_Intensity", 60, (r, prop, dep) =>                // 8: Intensity
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    float intensity = lightDataPairing[light].hdAdditionalLightData.intensity;
                    EditorGUI.BeginChangeCheck();
                    intensity = EditorGUI.FloatField(r, intensity);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(lightDataPairing[light].hdAdditionalLightData, "Changed light intensity");
                        lightDataPairing[light].hdAdditionalLightData.intensity = intensity;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.Unit, "m_Intensity", 60, (r, prop, dep) =>                // 9: Unit
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    LightUnit unit = lightDataPairing[light].hdAdditionalLightData.lightUnit;
                    EditorGUI.BeginChangeCheck();
                    unit = (LightUnit)EditorGUI.EnumPopup(r, unit);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.lightUnit = unit;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.IndirectMultiplier, "m_BounceIntensity", 90),                  // 10: Indirect multiplier
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.Shadows, "m_Shadows.m_Type", 60, (r, prop, dep) =>          // 11: Shadows
                {
                    EditorGUI.BeginChangeCheck();
                    bool shadows = EditorGUI.Toggle(r, prop.intValue != (int)LightShadows.None);
                    if (EditorGUI.EndChangeCheck())
                    {
                        prop.intValue = shadows ? (int)LightShadows.Soft : (int)LightShadows.None;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.ContactShadows, "m_Shadows.m_Type", 100, (r, prop, dep) =>  // 12: Contact Shadows
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    bool contactShadows = lightDataPairing[light].hdAdditionalLightData.contactShadows;
                    EditorGUI.BeginChangeCheck();
                    contactShadows = EditorGUI.Toggle(r, contactShadows);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.contactShadows = contactShadows;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.UseShadowQualitySettings, "m_Intensity", 60, (r, prop, dep) =>           // 13: Use Custom Shadow Res
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    bool useQualitySettings = lightDataPairing[light].hdAdditionalLightData.useShadowQualitySettings;
                    EditorGUI.BeginChangeCheck();
                    useQualitySettings = EditorGUI.Toggle(r, useQualitySettings);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.useShadowQualitySettings = useQualitySettings;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.ShadowResolutionTier, "m_Intensity", 60, (r, prop, dep) =>           // 14: Shadow tiers
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    ShadowResolutionTier resTier = lightDataPairing[light].hdAdditionalLightData.shadowResolutionTier;
                    EditorGUI.BeginChangeCheck();
                    resTier = (ShadowResolutionTier)EditorGUI.EnumPopup(r, resTier);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.shadowResolutionTier = resTier;
                    }
                }),

                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Int, HDStyles.CustomShadowResolution, "m_Intensity", 60, (r, prop, dep) =>           // 15: Custom Shadow resolution
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    int customResolution = lightDataPairing[light].hdAdditionalLightData.customResolution;
                    EditorGUI.BeginChangeCheck();
                    customResolution = EditorGUI.IntField(r, customResolution);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.customResolution = customResolution;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.AffectDiffuse, "m_Intensity", 90, (r, prop, dep) =>         // 16: Affect Diffuse
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    bool affectDiffuse = lightDataPairing[light].hdAdditionalLightData.affectDiffuse;
                    EditorGUI.BeginChangeCheck();
                    affectDiffuse = EditorGUI.Toggle(r, affectDiffuse);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.affectDiffuse = affectDiffuse;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.AffectSpecular, "m_Intensity", 90, (r, prop, dep) =>        // 17: Affect Specular
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    bool affectSpecular = lightDataPairing[light].hdAdditionalLightData.affectSpecular;
                    EditorGUI.BeginChangeCheck();
                    affectSpecular = EditorGUI.Toggle(r, affectSpecular);
                    if (EditorGUI.EndChangeCheck())
                    {
                        lightDataPairing[light].hdAdditionalLightData.affectSpecular = affectSpecular;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.FadeDistance, "m_Intensity", 60, (r, prop, dep) =>                // 18: Fade Distance
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    float fadeDistance = lightDataPairing[light].hdAdditionalLightData.fadeDistance;
                    EditorGUI.BeginChangeCheck();
                    fadeDistance = EditorGUI.FloatField(r, fadeDistance);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(lightDataPairing[light].hdAdditionalLightData, "Changed light fade distance");
                        lightDataPairing[light].hdAdditionalLightData.fadeDistance = fadeDistance;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.ShadowFadeDistance, "m_Intensity", 60, (r, prop, dep) =>           // 19: Shadow Fade Distance
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null || lightDataPairing[light].hdAdditionalLightData == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    float shadowFadeDistance = lightDataPairing[light].hdAdditionalLightData.shadowFadeDistance;
                    EditorGUI.BeginChangeCheck();
                    shadowFadeDistance = EditorGUI.FloatField(r, shadowFadeDistance);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(lightDataPairing[light].hdAdditionalLightData, "Changed light shadow fade distance");
                        lightDataPairing[light].hdAdditionalLightData.shadowFadeDistance = shadowFadeDistance;
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, HDStyles.LightLayer, "m_RenderingLayerMask", 80, (r, prop, dep) =>     // 20: Light Layer
                {
                    using (new EditorGUI.DisabledScope(!(GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset).currentPlatformRenderPipelineSettings.supportLightLayers))
                    {
                        HDEditorUtils.LightLayerMaskPropertyDrawer(r, prop);
                    }
                }),
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, HDStyles.IsPrefab, "m_Intensity", 60, (r, prop, dep) =>                // 21: Prefab
                {
                    Light light = prop.serializedObject.targetObject as Light;
                    if (light == null)
                    {
                        EditorGUI.LabelField(r, "null");
                        return;
                    }
                    bool isPrefab = lightDataPairing[light].isPrefab;
                    if (isPrefab)
                    {
                        EditorGUI.ObjectField(r, lightDataPairing[light].prefabRoot, typeof(GameObject), false);
                    }
                }),
            });
        }
        public override void Tick(
            SceneStateHash sceneStateHash,
            IScriptableBakedReflectionSystemStageNotifier handle
            )
        {
            if (!AreAllOpenedSceneSaved())
            {
                handle.SetIsDone(true);
                return;
            }

            // On the C# side, we don't have non blocking asset import APIs, and we don't want to block the
            //   UI when the user is editing the world.
            //   So, we skip the baking when the user is editing any UI control.
            if (GUIUtility.hotControl != 0)
            {
                return;
            }

            if (!IsCurrentSRPValid(out HDRenderPipeline hdPipeline))
            {
                if (ShouldIssueWarningForCurrentSRP())
                {
                    Debug.LogWarning("HDBakedReflectionSystem work with HDRP, " +
                                     "please switch your render pipeline or use another reflection system");
                }

                handle.ExitStage((int)BakingStages.ReflectionProbes);
                handle.SetIsDone(true);
                return;
            }

            var ambientProbeHash = sceneStateHash.ambientProbeHash;
            var sceneObjectsHash = sceneStateHash.sceneObjectsHash;
            var skySettingsHash  = sceneStateHash.skySettingsHash;

            DeleteCubemapAssets(true);

            // Explanation of the algorithm:
            // 1. First we create the hash of the world that can impact the reflection probes.
            // 2. Then for each probe, we calculate a hash that represent what this specific probe should have baked.
            // 3. We compare those hashes against the baked one and decide:
            //   a. If we have to remove a baked data
            //   b. If we have to bake a probe
            // 4. Bake all required probes
            // 5. Remove unused baked data
            // 6. Update probe assets

            // == 1. ==
            var allProbeDependencyHash = new Hash128();

            // TODO: All baked probes depend on custom probes (hash all custom probes and set as dependency)
            // TODO: All baked probes depend on HDRP specific Light settings
            HashUtilities.AppendHash(ref ambientProbeHash, ref allProbeDependencyHash);
            HashUtilities.AppendHash(ref sceneObjectsHash, ref allProbeDependencyHash);
            HashUtilities.AppendHash(ref skySettingsHash, ref allProbeDependencyHash);

            var bakedProbes = HDProbeSystem.bakedProbes;

            // == 2. ==
            var states = stackalloc HDProbeBakingState[bakedProbes.Count];

            ComputeProbeInstanceID(bakedProbes, states);
            ComputeProbeSettingsHashes(bakedProbes, states);
            // TODO: Handle bounce dependency here
            ComputeProbeBakingHashes(bakedProbes.Count, allProbeDependencyHash, states);

            CoreUnsafeUtils.QuickSort <HDProbeBakingState, Hash128, HDProbeBakingState.ProbeBakingHash>(
                bakedProbes.Count, states
                );

            int operationCount = 0, addCount = 0, remCount = 0;
            var maxProbeCount = Mathf.Max(bakedProbes.Count, m_HDProbeBakedStates.Length);
            var addIndices    = stackalloc int[maxProbeCount];
            var remIndices    = stackalloc int[maxProbeCount];

            if (m_HDProbeBakedStates.Length == 0)
            {
                for (int i = 0; i < bakedProbes.Count; ++i)
                {
                    addIndices[addCount++] = i;
                }
                operationCount = addCount;
            }
            else
            {
                fixed(HDProbeBakedState *oldBakedStates = &m_HDProbeBakedStates[0])
                {
                    // == 3. ==
                    // Compare hashes between baked probe states and desired probe states
                    operationCount = CoreUnsafeUtils.CompareHashes <
                        HDProbeBakedState, HDProbeBakedState.ProbeBakedHash,
                        HDProbeBakingState, HDProbeBakingState.ProbeBakingHash
                        > (
                        m_HDProbeBakedStates.Length, oldBakedStates, // old hashes
                        bakedProbes.Count, states,                   // new hashes
                        addIndices, remIndices,
                        out addCount, out remCount
                        );
                }
            }

            if (operationCount > 0)
            {
                // == 4. ==
                var cubemapSize = (int)hdPipeline.currentPlatformRenderPipelineSettings.lightLoopSettings.reflectionCubemapSize;
                var planarSize  = (int)hdPipeline.currentPlatformRenderPipelineSettings.lightLoopSettings.planarReflectionTextureSize;
                var cubeRT      = HDRenderUtilities.CreateReflectionProbeRenderTarget(cubemapSize);
                var planarRT    = HDRenderUtilities.CreatePlanarProbeRenderTarget(planarSize);

                handle.EnterStage(
                    (int)BakingStages.ReflectionProbes,
                    string.Format("Reflection Probes | {0} jobs", addCount),
                    0
                    );

                // Render probes
                for (int i = 0; i < addCount; ++i)
                {
                    handle.EnterStage(
                        (int)BakingStages.ReflectionProbes,
                        string.Format("Reflection Probes | {0} jobs", addCount),
                        i / (float)addCount
                        );

                    var index      = addIndices[i];
                    var instanceId = states[index].instanceID;
                    var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                    var cacheFile  = GetGICacheFileForHDProbe(states[index].probeBakingHash);

                    // Get from cache or render the probe
                    if (!File.Exists(cacheFile))
                    {
                        RenderAndWriteToFile(probe, cacheFile, cubeRT, planarRT);
                    }
                }
                cubeRT.Release();
                planarRT.Release();

                // Copy texture from cache
                for (int i = 0; i < addCount; ++i)
                {
                    var index      = addIndices[i];
                    var instanceId = states[index].instanceID;
                    var probe      = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                    var cacheFile  = GetGICacheFileForHDProbe(states[index].probeBakingHash);

                    Assert.IsTrue(File.Exists(cacheFile));

                    var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
                    HDBakingUtilities.CreateParentDirectoryIfMissing(bakedTexturePath);
                    Checkout(bakedTexturePath);
                    // Checkout will make those file writeable, but this is not immediate,
                    // so we retries when this fails.
                    if (!HDEditorUtils.CopyFileWithRetryOnUnauthorizedAccess(cacheFile, bakedTexturePath))
                    {
                        return;
                    }
                }
                // AssetPipeline bug
                // Sometimes, the baked texture reference is destroyed during 'AssetDatabase.StopAssetEditing()'
                //   thus, the reference to the baked texture in the probe is lost
                // Although, importing twice the texture seems to workaround the issue
                for (int j = 0; j < 2; ++j)
                {
                    AssetDatabase.StartAssetEditing();
                    for (int i = 0; i < bakedProbes.Count; ++i)
                    {
                        var index            = addIndices[i];
                        var instanceId       = states[index].instanceID;
                        var probe            = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                        var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
                        AssetDatabase.ImportAsset(bakedTexturePath);
                        ImportAssetAt(probe, bakedTexturePath);
                    }
                    AssetDatabase.StopAssetEditing();
                }
                // Import assets
                AssetDatabase.StartAssetEditing();
                for (int i = 0; i < addCount; ++i)
                {
                    var index            = addIndices[i];
                    var instanceId       = states[index].instanceID;
                    var probe            = (HDProbe)EditorUtility.InstanceIDToObject(instanceId);
                    var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe);
                    var bakedTexture     = AssetDatabase.LoadAssetAtPath <Texture>(bakedTexturePath);
                    Assert.IsNotNull(bakedTexture, "The baked texture was imported before, " +
                                     "so it must exists in AssetDatabase");

                    probe.SetTexture(ProbeSettings.Mode.Baked, bakedTexture);
                    EditorUtility.SetDirty(probe);
                }
                AssetDatabase.StopAssetEditing();

                // == 5. ==

                // Create new baked state array
                var targetSize        = m_HDProbeBakedStates.Length + addCount - remCount;
                var targetBakedStates = stackalloc HDProbeBakedState[targetSize];
                // Copy baked state that are not removed
                var targetI = 0;
                for (int i = 0; i < m_HDProbeBakedStates.Length; ++i)
                {
                    if (CoreUnsafeUtils.IndexOf(remIndices, remCount, i) != -1)
                    {
                        continue;
                    }
                    targetBakedStates[targetI++] = m_HDProbeBakedStates[i];
                }
                // Add new baked states
                for (int i = 0; i < addCount; ++i)
                {
                    var state = states[addIndices[i]];
                    targetBakedStates[targetI++] = new HDProbeBakedState
                    {
                        instanceID     = state.instanceID,
                        probeBakedHash = state.probeBakingHash
                    };
                }
                CoreUnsafeUtils.QuickSort <HDProbeBakedState, Hash128, HDProbeBakedState.ProbeBakedHash>(
                    targetI, targetBakedStates
                    );

                Array.Resize(ref m_HDProbeBakedStates, targetSize);
                if (targetSize > 0)
                {
                    fixed(HDProbeBakedState *bakedStates = &m_HDProbeBakedStates[0])
                    {
                        UnsafeUtility.MemCpy(
                            bakedStates,
                            targetBakedStates,
                            sizeof(HDProbeBakedState) * targetSize
                            );
                    }
                }

                // Update state hash
                Array.Resize(ref m_StateHashes, m_HDProbeBakedStates.Length);
                for (int i = 0; i < m_HDProbeBakedStates.Length; ++i)
                {
                    m_StateHashes[i] = m_HDProbeBakedStates[i].probeBakedHash;
                }
                stateHashes = m_StateHashes;
            }

            handle.ExitStage((int)BakingStages.ReflectionProbes);

            handle.SetIsDone(true);
        }
 static internal void Drawer_ToolBarButton(
     ToolBar button, Editor owner,
     params GUILayoutOption[] options
     )
 => HDEditorUtils.DrawToolBarButton(button, owner, k_ToolbarMode, k_ToolbarContents, options);
            public static void DoToolbarShortcutKey(Editor owner)
            {
                var provider  = new TProvider();
                var toolbars  = provider.toolbars;
                var shortcuts = provider.shortcuts;

                var evt = Event.current;

                if (evt.type != EventType.KeyDown || !evt.shift)
                {
                    return;
                }

                if (shortcuts.TryGetValue(evt.keyCode, out ToolBar toolbar))
                {
                    bool used = false;
                    foreach (ToolBar t in toolbars)
                    {
                        if ((t & toolbar) > 0)
                        {
                            used = true;
                            break;
                        }
                    }
                    if (!used)
                    {
                        return;
                    }

                    var targetMode = k_ToolbarMode[toolbar];
                    var mode       = EditMode.editMode == targetMode ? EditMode.SceneViewEditMode.None : targetMode;
                    EditorApplication.delayCall += () => EditMode.ChangeEditMode(mode, HDEditorUtils.GetBoundsGetter(owner)(), owner);
                    evt.Use();
                }
            }
Esempio n. 29
0
        public override void OnInspectorGUI()
        {
            // This whole editor has nothing to display if the SSR feature is not supported
            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            if (!currentAsset?.currentPlatformRenderPipelineSettings.supportVolumetricClouds ?? false)
            {
                EditorGUILayout.Space();
                HDEditorUtils.QualitySettingsHelpBox("The current HDRP Asset does not support Volumetric Clouds.", MessageType.Error,
                                                     HDRenderPipelineUI.Expandable.Volumetric, "m_RenderPipelineSettings.supportVolumetricClouds");
                return;
            }


            EditorGUILayout.LabelField("General", EditorStyles.miniLabel);
            PropertyField(m_Enable);
            PropertyField(m_LocalClouds);
            if (m_LocalClouds.value.boolValue)
            {
                EditorGUILayout.HelpBox("Volumetric Clouds are only displayed up to the far plane of the used camera. Make sure to increase the far and near planes accordingly.", MessageType.Info);
            }
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Shape", EditorStyles.miniLabel);
            PropertyField(m_CloudControl);
            VolumetricClouds.CloudControl controlMode = (VolumetricClouds.CloudControl)m_CloudControl.value.enumValueIndex;
            bool hasCloudMap = true;

            using (new IndentLevelScope())
            {
                bool needsIntendation = false;
                if (controlMode == VolumetricClouds.CloudControl.Advanced)
                {
                    PropertyField(m_CumulusMap);
                    PropertyField(m_CumulusMapMultiplier);
                    PropertyField(m_AltoStratusMap);
                    PropertyField(m_AltoStratusMapMultiplier);
                    PropertyField(m_CumulonimbusMap);
                    PropertyField(m_CumulonimbusMapMultiplier);
                    PropertyField(m_RainMap);
                    PropertyField(m_CloudMapResolution);
                    PropertyField(m_CloudTiling, k_CloudMapTilingText);
                    PropertyField(m_CloudOffset, k_CloudMapOffsetText);
                }
                else if (controlMode == VolumetricClouds.CloudControl.Manual)
                {
                    PropertyField(m_CloudMap);
                    PropertyField(m_CloudLut);
                    PropertyField(m_CloudTiling, k_CloudMapTilingText);
                    PropertyField(m_CloudOffset, k_CloudMapOffsetText);
                }
                else
                {
                    hasCloudMap      = false;
                    needsIntendation = true;
                    PropertyField(m_CloudPreset);
                }

                VolumetricClouds.CloudPresets controlPreset = (VolumetricClouds.CloudPresets)m_CloudPreset.value.enumValueIndex;
                if ((controlMode != VolumetricClouds.CloudControl.Simple) || controlMode == VolumetricClouds.CloudControl.Simple && controlPreset == VolumetricClouds.CloudPresets.Custom)
                {
                    using (new IndentLevelScope(needsIntendation ? 16 : 0))
                    {
                        PropertyField(m_DensityMultiplier);
                        if (controlMode == VolumetricClouds.CloudControl.Simple)
                        {
                            PropertyField(m_CustomDensityCurve);
                        }
                        PropertyField(m_ShapeFactor);
                        PropertyField(m_ShapeScale);
                        PropertyField(m_ShapeOffset);
                        PropertyField(m_ErosionFactor);
                        PropertyField(m_ErosionScale);
                        PropertyField(m_ErosionNoiseType);
                        if (controlMode == VolumetricClouds.CloudControl.Simple)
                        {
                            PropertyField(m_CustomErosionCurve);
                            PropertyField(m_CustomAmbientOcclusionCurve);
                        }
                    }
                }
                else
                {
                    PropertyField(m_ShapeOffset);
                }
            }

            PropertyField(m_EarthCurvature);
            PropertyField(m_LowestCloudAltitude);
            PropertyField(m_CloudThickness);

            DrawHeader("Wind");
            PropertyField(m_GlobalWindSpeed, k_GlobalHorizontalWindSpeedText);
            if (showAdditionalProperties)
            {
                using (new IndentLevelScope())
                {
                    if (hasCloudMap)
                    {
                        PropertyField(m_CloudMapSpeedMultiplier);
                    }
                    PropertyField(m_ShapeSpeedMultiplier);
                    PropertyField(m_ErosionSpeedMultiplier);
                }
            }
            PropertyField(m_Orientation);
            using (new IndentLevelScope())
            {
                PropertyField(m_AltitudeDistortion);
            }

            PropertyField(m_VerticalShapeWindSpeed);
            PropertyField(m_VerticalErosionWindSpeed);

            DrawHeader("Lighting");
            {
                PropertyField(m_AmbientLightProbeDimmer);
                PropertyField(m_SunLightDimmer);
                PropertyField(m_ErosionOcclusion);
                PropertyField(m_ScatteringTint);
                PropertyField(m_PowderEffectIntensity);
                PropertyField(m_MultiScattering);
            }

            DrawHeader("Shadows");
            {
                PropertyField(m_Shadows);
                using (new IndentLevelScope())
                {
                    PropertyField(m_ShadowResolution);
                    PropertyField(m_ShadowOpacity);
                    PropertyField(m_ShadowDistance);
                    PropertyField(m_ShadowPlaneHeightOffset);
                    PropertyField(m_ShadowOpacityFallback);
                }
            }

            DrawHeader("Quality");
            {
                PropertyField(m_TemporalAccumulationFactor);
                PropertyField(m_GhostingReduction);
                PropertyField(m_NumPrimarySteps);
                PropertyField(m_NumLightSteps);
                PropertyField(m_FadeInMode);
                using (new IndentLevelScope())
                {
                    if ((VolumetricClouds.CloudFadeInMode)m_FadeInMode.value.enumValueIndex == (VolumetricClouds.CloudFadeInMode.Manual))
                    {
                        PropertyField(m_FadeInStart);
                        PropertyField(m_FadeInDistance);
                    }
                }
            }
        }
Esempio n. 30
0
        static void Drawer_SectionReflection(SerializedHDRenderPipelineAsset serialized, Editor owner)
        {
            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.supportSSR, k_SupportSSRContent);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.reflectionCacheCompressed, k_CompressProbeCacheContent);
            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.reflectionCubemapSize, k_CubemapSizeContent);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize, k_ProbeCacheSizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.intValue, 1, TextureCache.k_MaxSupported);
            }
            if (serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
            }
            else
            {
                long currentCache = ReflectionProbeCache.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.reflectionProbeCacheSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.reflectionCubemapSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.supportFabricConvolution.boolValue ? 2 : 1);
                if (currentCache > HDRenderPipeline.k_MaxCacheSize)
                {
                    int    reserved = ReflectionProbeCache.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.reflectionCubemapSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.supportFabricConvolution.boolValue ? 2 : 1);
                    string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
                    EditorGUILayout.HelpBox(message, MessageType.Error);
                }
                else
                {
                    string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
                    EditorGUILayout.HelpBox(message, MessageType.Info);
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed, k_CompressPlanarProbeCacheContent);
            EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCubemapSize, k_PlanarTextureSizeContent);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize, k_PlanarProbeCacheSizeContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.intValue, 1, TextureCache.k_MaxSupported);
            }
            if (serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox(k_MultipleDifferenteValueMessage, MessageType.Info);
            }
            else
            {
                long currentCache = PlanarReflectionProbeCache.GetApproxCacheSizeInByte(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize.intValue, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCubemapSize.intValue, 1);
                if (currentCache > HDRenderPipeline.k_MaxCacheSize)
                {
                    int    reserved = PlanarReflectionProbeCache.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionCubemapSize.intValue, 1);
                    string message  = string.Format(k_CacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved);
                    EditorGUILayout.HelpBox(message, MessageType.Error);
                }
                else
                {
                    string message = string.Format(k_CacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
                    EditorGUILayout.HelpBox(message, MessageType.Info);
                }
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.lightLoopSettings.maxEnvLightsOnScreen, k_MaxEnvContent);
            if (EditorGUI.EndChangeCheck())
            {
                serialized.renderPipelineSettings.lightLoopSettings.maxEnvLightsOnScreen.intValue = Mathf.Clamp(serialized.renderPipelineSettings.lightLoopSettings.maxEnvLightsOnScreen.intValue, 1, HDRenderPipeline.k_MaxEnvLightsOnScreen);
            }
        }