Ejemplo n.º 1
0
 protected virtual void MaterialTesselationPropertiesGUI()
 {
     // Display tessellation option if it exist
     if (tessellationMode != null)
     {
         using (var header = new HeaderScope(StylesBaseLit.tessellationText.text, (uint)Expandable.Tesselation, this))
         {
             if (header.expanded)
             {
                 TessellationModePopup();
                 m_MaterialEditor.ShaderProperty(tessellationFactor, StylesBaseLit.tessellationFactorText);
                 DrawDelayedFloatProperty(tessellationFactorMinDistance, StylesBaseLit.tessellationFactorMinDistanceText);
                 DrawDelayedFloatProperty(tessellationFactorMaxDistance, StylesBaseLit.tessellationFactorMaxDistanceText);
                 // clamp min distance to be below max distance
                 tessellationFactorMinDistance.floatValue = Math.Min(tessellationFactorMaxDistance.floatValue, tessellationFactorMinDistance.floatValue);
                 m_MaterialEditor.ShaderProperty(tessellationFactorTriangleSize, StylesBaseLit.tessellationFactorTriangleSizeText);
                 if ((TessellationMode)tessellationMode.floatValue == TessellationMode.Phong)
                 {
                     m_MaterialEditor.ShaderProperty(tessellationShapeFactor, StylesBaseLit.tessellationShapeFactorText);
                 }
                 if (doubleSidedEnable.floatValue == 0.0)
                 {
                     m_MaterialEditor.ShaderProperty(tessellationBackFaceCullEpsilon, StylesBaseLit.tessellationBackFaceCullEpsilonText);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        protected override void MaterialPropertiesGUI(Material material)
        {
            // Don't draw the header if we have empty content
            if (enableHeightBlend == null && enableInstancedPerPixelNormal == null && customProperties.Count == 0)
            {
                return;
            }

            using (var header = new HeaderScope(styles.terrainText, (uint)Expandable.Other, this))
            {
                if (header.expanded)
                {
                    if (enableHeightBlend != null)
                    {
                        m_MaterialEditor.ShaderProperty(enableHeightBlend, styles.enableHeightBlend);
                        if (enableHeightBlend.floatValue > 0)
                        {
                            EditorGUI.indentLevel++;
                            m_MaterialEditor.ShaderProperty(heightTransition, styles.heightTransition);
                            EditorGUI.indentLevel--;
                        }
                    }
                    if (enableInstancedPerPixelNormal != null)
                    {
                        EditorGUI.BeginDisabledGroup(!m_MaterialEditor.IsInstancingEnabled());
                        m_MaterialEditor.ShaderProperty(enableInstancedPerPixelNormal, styles.enableInstancedPerPixelNormal);
                        EditorGUI.EndDisabledGroup();
                    }
                    foreach (var prop in customProperties)
                    {
                        m_MaterialEditor.ShaderProperty(prop, prop.displayName);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        //override for adding Tesselation
        public override void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                using (var header = new HeaderScope(StylesBaseUnlit.optionText, (uint)Expendable.Base, this))
                {
                    if (header.expended)
                        BaseMaterialPropertiesGUI();
                }
                MaterialTesselationPropertiesGUI();
                VertexAnimationPropertiesGUI();
                FpsModePropertiesGUI();
                MaterialPropertiesGUI(material);
                DoEmissionArea(material);
                using (var header = new HeaderScope(StylesBaseUnlit.advancedText, (uint)Expendable.Advance, this))
                {
                    if (header.expended)
                    {
                        m_MaterialEditor.EnableInstancingField();
                        MaterialPropertiesAdvanceGUI(material);
                    }
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in m_MaterialEditor.targets)
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
            }
        }
Ejemplo n.º 4
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            m_MaterialEditor = materialEditor;

            FindMaterialProperties(props);

            // Copy/Paste of public void PropertiesDefaultGUI(MaterialProperty[] props) in MaterialEditor.cs to allow to customize inspector for
            // decal. We don't want to display GI option or instancing option and want to add tooltips to our parameters.
            m_MaterialEditor.SetDefaultGUIWidths();

            using (var header = new HeaderScope(Styles.InputsText, (uint)Expandable.Input, this))
            {
                if (header.expanded)
                {
                    // We do "- 2" as we always have draw order and decal mesh bias. Update this number if we change the number of mandatory parameters
                    for (var i = 0; i < props.Length - 2; i++)
                    {
                        if ((props[i].flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) != 0)
                        {
                            continue;
                        }

                        float h = m_MaterialEditor.GetPropertyHeight(props[i], props[i].displayName);
                        Rect  r = EditorGUILayout.GetControlRect(true, h, EditorStyles.layerMaskField);

                        m_MaterialEditor.ShaderProperty(r, props[i], props[i].displayName);
                    }
                }
            }

            ShaderPropertiesGUI();

            // We should always do this call at the end
            m_MaterialEditor.serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 5
0
        protected void EmissiveInputGUI(Material material)
        {
            using (var header = new HeaderScope(Styles.emissiveLabelText, (uint)Expendable.Emissive, this))
            {
                if (header.expended)
                {
                    m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);

                    if (material.GetTexture(kEmissiveColorMap))
                    {
                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(UVEmissive, Styles.UVMappingEmissiveText);
                        UVBaseMapping uvEmissiveMapping = (UVBaseMapping)UVEmissive.floatValue;

                        float X, Y, Z, W;
                        X = (uvEmissiveMapping == UVBaseMapping.UV0) ? 1.0f : 0.0f;
                        Y = (uvEmissiveMapping == UVBaseMapping.UV1) ? 1.0f : 0.0f;
                        Z = (uvEmissiveMapping == UVBaseMapping.UV2) ? 1.0f : 0.0f;
                        W = (uvEmissiveMapping == UVBaseMapping.UV3) ? 1.0f : 0.0f;

                        UVMappingMaskEmissive.colorValue = new Color(X, Y, Z, W);


                        m_MaterialEditor.TextureScaleOffsetProperty(emissiveColorMap);
                        EditorGUI.indentLevel--;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        protected override void VertexAnimationPropertiesGUI()
        {
            using (var header = new HeaderScope(StylesBaseLit.vertexAnimation, (uint)Expandable.VertexAnimation, this))
            {
                if (header.expanded)
                {
                    if (windEnable != null)
                    {
                        // Hide wind option. Wind is deprecated and will be remove in the future. Use shader graph instead

                        /*
                         * m_MaterialEditor.ShaderProperty(windEnable, StylesBaseLit.windText);
                         * if (!windEnable.hasMixedValue && windEnable.floatValue > 0.0f)
                         * {
                         *  EditorGUI.indentLevel++;
                         *  m_MaterialEditor.ShaderProperty(windInitialBend, StylesBaseLit.windInitialBendText);
                         *  m_MaterialEditor.ShaderProperty(windStiffness, StylesBaseLit.windStiffnessText);
                         *  m_MaterialEditor.ShaderProperty(windDrag, StylesBaseLit.windDragText);
                         *  m_MaterialEditor.ShaderProperty(windShiverDrag, StylesBaseLit.windShiverDragText);
                         *  m_MaterialEditor.ShaderProperty(windShiverDirectionality, StylesBaseLit.windShiverDirectionalityText);
                         *  EditorGUI.indentLevel--;
                         * }
                         */
                    }

                    if (enableMotionVectorForVertexAnimation != null)
                    {
                        m_MaterialEditor.ShaderProperty(enableMotionVectorForVertexAnimation, StylesBaseUnlit.enableMotionVectorForVertexAnimationText);
                    }
                }
            }
        }
        void DrawLayeringOptions(bool mainLayerInfluenceEnable, uint expended, int layerIndex)
        {
            // do layering option (if main layer (0) check if there is any content before drawing the foldout)
            if (layerIndex > 0 || layerIndex == 0 && !useMainLayerInfluence.hasMixedValue && useMainLayerInfluence.floatValue != 0.0f)
            {
                using (var header = new HeaderScope(styles.layeringOptionText.text, expended, this, colorDot: s_Styles.layerColors[layerIndex], subHeader: true))
                {
                    if (header.expanded)
                    {
                        // Main layer does not have any options but height base blend.
                        if (layerIndex > 0)
                        {
                            m_MaterialEditor.ShaderProperty(opacityAsDensity[layerIndex], styles.opacityAsDensityText);

                            if (mainLayerInfluenceEnable)
                            {
                                m_MaterialEditor.ShaderProperty(inheritBaseColor[layerIndex - 1], styles.inheritBaseColorText);
                                m_MaterialEditor.ShaderProperty(inheritBaseNormal[layerIndex - 1], styles.inheritBaseNormalText);
                                // Main height influence is only available if the shader use the heightmap for displacement (per vertex or per level)
                                // We always display it as it can be tricky to know when per pixel displacement is enabled or not
                                m_MaterialEditor.ShaderProperty(inheritBaseHeight[layerIndex - 1], styles.inheritBaseHeightText);
                            }
                        }
                        else
                        {
                            m_MaterialEditor.TexturePropertySingleLine(styles.layerInfluenceMapMaskText, layerInfluenceMaskMap);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        protected override void MaterialPropertiesGUI(Material material)
        {
            using (var header = new HeaderScope(Styles.InputsText, (uint)Expandable.Input, this))
            {
                if (header.expanded)
                {
                    m_MaterialEditor.TexturePropertySingleLine(Styles.colorText, colorMap, color);
                    m_MaterialEditor.TextureScaleOffsetProperty(colorMap);
                }
            }

            var surfaceTypeValue = (SurfaceType)surfaceType.floatValue;

            if (surfaceTypeValue == SurfaceType.Transparent)
            {
                using (var header = new HeaderScope(StylesBaseUnlit.TransparencyInputsText, (uint)Expandable.Transparency, this))
                {
                    if (header.expanded)
                    {
                        DoDistortionInputsGUI();
                    }
                }
            }

            using (var header = new HeaderScope(Styles.emissiveLabelText, (uint)Expandable.Emissive, this))
            {
                if (header.expanded)
                {
                    m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
                    m_MaterialEditor.TextureScaleOffsetProperty(emissiveColorMap);
                    DoEmissionArea(material);
                }
            }
        }
Ejemplo n.º 9
0
        protected void BaseInputGUI(Material material)
        {
            using (var header = new HeaderScope(Styles.InputsText, (uint)Expendable.Input, this))
            {
                if (header.expended)
                {
                    // The base color map and matching base color value
                    m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap, baseColor);

                    // If no mask texture was provided, we display the smoothness value
                    if (maskMap.textureValue == null)
                    {
                        m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
                    }

                    // If we have a mask map, we do not use values but remapping fields instead
                    m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapSpecularText, maskMap);
                    if (maskMap.textureValue != null)
                    {
                        float remapMin = smoothnessRemapMin.floatValue;
                        float remapMax = smoothnessRemapMax.floatValue;
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.MinMaxSlider(Styles.smoothnessRemappingText, ref remapMin, ref remapMax, 0.0f, 1.0f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            smoothnessRemapMin.floatValue = remapMin;
                            smoothnessRemapMax.floatValue = remapMax;
                        }

                        float aoMin = aoRemapMin.floatValue;
                        float aoMax = aoRemapMax.floatValue;
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.MinMaxSlider(Styles.aoRemappingText, ref aoMin, ref aoMax, 0.0f, 1.0f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            aoRemapMin.floatValue = aoMin;
                            aoRemapMax.floatValue = aoMax;
                        }
                    }

                    // The specular color value (that affects the color of the specular lighting term)
                    m_MaterialEditor.ShaderProperty(specularColor, Styles.specularColorText);
                    // The primal normal map field
                    m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);

                    // m_MaterialEditor.TexturePropertySingleLine(Styles.bentNormalMapText, bentNormalMap);

                    // The diffusion/transmission/subsurface gui
                    ShaderSSSAndTransmissionInputGUI(material);

                    // Anisotropy GUI
                    ShaderAnisoInputGUI(material);

                    // Define the UV mapping for the base textures
                    BaseUVMappingInputGUI();
                }
            }
        }
Ejemplo n.º 10
0
 public void ShaderPropertiesGUI()
 {
     using (var header = new HeaderScope(Styles.SortingText, (uint)Expandable.Sorting, this))
     {
         if (header.expanded)
         {
             m_MaterialEditor.ShaderProperty(drawOrder, Styles.drawOrderText);
             m_MaterialEditor.ShaderProperty(decalMeshDepthBias, Styles.meshDecalDepthBiasText);
         }
     }
 }
Ejemplo n.º 11
0
        protected override void MaterialPropertiesGUI(Material material)
        {
            //if (GUILayout.Button("Generate All Properties"))
            //{
            //    Debug.Log(_materialProperties.ToShaderPropertiesStringInternal());
            //}

            using (var header = new HeaderScope(StylesStackLit.stackOptionText, (uint)Expandable.Input, this, spaceAtEnd: false))
            {
                if (header.expanded)
                {
                    _materialProperties.OnGUI();
                }
            }
        }
        bool DoMaterialReferencesGUI(AssetImporter materialImporter)
        {
            bool layersChanged = false;

            using (var header = new HeaderScope(styles.materialReferencesText.text, (uint)LayerExpendable.MaterialReferences, this))
            {
                if (header.expended)
                {
                    Material material = m_MaterialEditor.target as Material;

                    Color originalContentColor = GUI.contentColor;

                    for (int layerIndex = 0; layerIndex < numLayer; ++layerIndex)
                    {
                        EditorGUI.BeginChangeCheck();
                        GUI.contentColor = styles.layerColors[layerIndex];

                        m_MaterialLayers[layerIndex] = EditorGUILayout.ObjectField(styles.layerLabels[layerIndex], m_MaterialLayers[layerIndex], typeof(Material), true) as Material;
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(materialImporter, "Change layer material");
                            SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true);
                            layersChanged = true;
                        }

                        GUI.contentColor = originalContentColor;

                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button(styles.syncAllButUVButtonText))
                            {
                                SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true);
                                layersChanged = true;
                            }
                            if (GUILayout.Button(styles.syncAllButtonText))
                            {
                                SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, false);
                                layersChanged = true;
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            }

            return(layersChanged);
        }
Ejemplo n.º 13
0
        protected void DetailsInput(Material material)
        {
            using (var header = new HeaderScope(Styles.threadText, (uint)Expendable.Detail, this))
            {
                if (header.expended)
                {
                    m_MaterialEditor.TexturePropertySingleLine(Styles.threadMapText, threadMap);
                    if (material.GetTexture(kThreadMap))
                    {
                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(threadAOScale, Styles.threadAOScaleText);
                        m_MaterialEditor.ShaderProperty(threadNormalScale, Styles.threadNormalScaleText);
                        m_MaterialEditor.ShaderProperty(threadSmoothnessScale, Styles.threadSmoothnessScaleText);
                        EditorGUI.indentLevel--;
                    }

                    m_MaterialEditor.TexturePropertySingleLine(Styles.FuzzDetailText, fuzzDetailMap);
                    if (material.GetTexture(kFuzzDetailMap))
                    {
                        m_MaterialEditor.ShaderProperty(fuzzDetailScale, Styles.FuzzDetailScale);
                        m_MaterialEditor.ShaderProperty(fuzzDetailUVScale, Styles.FuzzDetailUVScale);
                    }

                    if (material.GetTexture(kThreadMap) || material.GetTexture(kFuzzDetailMap))
                    {
                        EditorGUI.indentLevel++;

                        m_MaterialEditor.ShaderProperty(UVThread, Styles.UVThreadMappingText);

                        // Setup the UVSet for detail, if planar/triplanar is use for base, it will override the mapping of detail (See shader code)
                        float X, Y, Z, W;
                        X = ((UVThreadMapping)UVThread.floatValue == UVThreadMapping.UV0) ? 1.0f : 0.0f;
                        Y = ((UVThreadMapping)UVThread.floatValue == UVThreadMapping.UV1) ? 1.0f : 0.0f;
                        Z = ((UVThreadMapping)UVThread.floatValue == UVThreadMapping.UV2) ? 1.0f : 0.0f;
                        W = ((UVThreadMapping)UVThread.floatValue == UVThreadMapping.UV3) ? 1.0f : 0.0f;
                        UVMappingMaskThread.colorValue = new Color(X, Y, Z, W);

                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(linkDetailsWithBase, Styles.linkDetailsWithBaseText);
                        EditorGUI.indentLevel--;
                        m_MaterialEditor.TextureScaleOffsetProperty(threadMap);
                    }
                }
            }
        }
        bool DoLayerGUI(AssetImporter materialImporter, int layerIndex)
        {
            bool result = false;

            Array values = Enum.GetValues(typeof(LayerExpandable));

            if (layerIndex > 1) //main layer (0) and layer 1 always here
            {
                int startShowVal = Array.IndexOf(values, LayerExpandable.ShowLayer1);
                if (!GetExpandedAreas((uint)values.GetValue(startShowVal + layerIndex)))
                {
                    return(false);
                }
            }

            Material material = m_MaterialEditor.target as Material;

            bool mainLayerInfluenceEnable = useMainLayerInfluence.floatValue > 0.0f;

            int startLayer = Array.IndexOf(values, LayerExpandable.MainLayer);

            using (var layerHeader = new HeaderScope(s_Styles.layerLabels[layerIndex].text, (uint)values.GetValue(startLayer + layerIndex), this, false, s_Styles.layerColors[layerIndex]))
            {
                if (layerHeader.expanded)
                {
                    //Note LayeringOptionMain do not preced LayeringOption1
                    int startLayeringOptionValue = Array.IndexOf(values, LayerExpandable.LayeringOption1);
                    var layeringOptionValue      = layerIndex == 0 ? LayerExpandable.LayeringOptionMain : (LayerExpandable)values.GetValue(startLayeringOptionValue + layerIndex - 1);
                    DrawLayeringOptions(mainLayerInfluenceEnable, (uint)layeringOptionValue, layerIndex);

                    int startInputValue  = Array.IndexOf(values, LayerExpandable.MainInput);
                    var inputValue       = (LayerExpandable)values.GetValue(startInputValue + layerIndex);
                    int startDetailValue = Array.IndexOf(values, LayerExpandable.MainDetail);
                    var detailValue      = (LayerExpandable)values.GetValue(startDetailValue + layerIndex);
                    DoLayerGUI(material, layerIndex, true, m_UseHeightBasedBlend, (uint)inputValue, (uint)detailValue, colorDot: s_Styles.layerColors[layerIndex], subHeader: true);

                    if (!GetExpandedAreas((uint)detailValue))
                    {
                        EditorGUILayout.Space();
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 15
0
        protected override void MaterialPropertiesGUI(Material material)
        {
            using (var header = new HeaderScope(Styles.fabricLabelText, (uint)Expendable.Other, this))
            {
                if (header.expended)
                {
                    // The generic type of the fabric (either cotton/wool or silk)
                    m_MaterialEditor.ShaderProperty(fabricType, Styles.fabricTypeText);
                }
            }

            // Base GUI
            BaseInputGUI(material);

            // Emissive GUI
            EmissiveInputGUI(material);

            // Details Input
            DetailsInput(material);
        }
Ejemplo n.º 16
0
        bool DoLayerGUI(AssetImporter materialImporter, int layerIndex)
        {
            bool result = false;

            int   paramIndex = -1;
            Array values     = Enum.GetValues(typeof(LayerExpandable));

            if (layerIndex > 0)
            {
                paramIndex = layerIndex - 1;

                int startShowVal = Array.IndexOf(values, LayerExpandable.ShowLayer1);
                if (!GetExpandedAreas((uint)values.GetValue(startShowVal + paramIndex)))
                {
                    return(false);
                }
            }

            //showLayer[layerIndex].floatValue = EditorGUILayout.Foldout(showLayer[layerIndex].floatValue != 0.0f, styles.layerLabels[layerIndex], styles.layerLabelColors[layerIndex]) ? 1.0f : 0.0f;

            Material material = m_MaterialEditor.target as Material;

            bool mainLayerInfluenceEnable = useMainLayerInfluence.floatValue > 0.0f;

            // Main layer does not have any options but height base blend.
            if (layerIndex > 0)
            {
                int startLayeringOptionValue = Array.IndexOf(values, LayerExpandable.LayeringOption1);
                using (var header = new HeaderScope(s_Styles.layerLabels[layerIndex].text + " " + styles.layeringOptionText.text, (uint)values.GetValue(startLayeringOptionValue + paramIndex), this, colorDot: s_Styles.layerColors[layerIndex]))
                {
                    if (header.expanded)
                    {
                        m_MaterialEditor.ShaderProperty(opacityAsDensity[layerIndex], styles.opacityAsDensityText);

                        if (mainLayerInfluenceEnable)
                        {
                            m_MaterialEditor.ShaderProperty(inheritBaseColor[paramIndex], styles.inheritBaseColorText);
                            m_MaterialEditor.ShaderProperty(inheritBaseNormal[paramIndex], styles.inheritBaseNormalText);
                            // Main height influence is only available if the shader use the heightmap for displacement (per vertex or per level)
                            // We always display it as it can be tricky to know when per pixel displacement is enabled or not
                            m_MaterialEditor.ShaderProperty(inheritBaseHeight[paramIndex], styles.inheritBaseHeightText);
                        }
                    }
                }
            }
            else if (!useMainLayerInfluence.hasMixedValue && useMainLayerInfluence.floatValue != 0.0f)
            {
                using (var header = new HeaderScope(s_Styles.layerLabels[layerIndex].text + " " + styles.layeringOptionText.text, (uint)LayerExpandable.LayeringOptionMain, this, colorDot: s_Styles.layerColors[layerIndex]))
                {
                    if (header.expanded)
                    {
                        m_MaterialEditor.TexturePropertySingleLine(styles.layerInfluenceMapMaskText, layerInfluenceMaskMap);
                    }
                }
            }

            int startInputValue  = Array.IndexOf(values, LayerExpandable.Layer1Input);
            int startDetailValue = Array.IndexOf(values, LayerExpandable.Layer1Detail);

            DoLayerGUI(material, layerIndex, true, m_UseHeightBasedBlend, s_Styles.layerLabels[layerIndex].text + " ", (uint)values.GetValue(startInputValue + paramIndex), (uint)values.GetValue(startDetailValue + paramIndex), colorDot: s_Styles.layerColors[layerIndex]);

            return(result);
        }
Ejemplo n.º 17
0
        protected override void MaterialPropertiesGUI(Material material)
        {
            using (var header = new HeaderScope(Styles.InputsText, (uint)Expandable.Input, this))
            {
                if (header.expanded)
                {
                    m_MaterialEditor.TexturePropertySingleLine(Styles.colorText, colorMap, color);
                    m_MaterialEditor.TextureScaleOffsetProperty(colorMap);
                }
            }

            var surfaceTypeValue = (SurfaceType)surfaceType.floatValue;

            if (surfaceTypeValue == SurfaceType.Transparent)
            {
                using (var header = new HeaderScope(StylesBaseUnlit.TransparencyInputsText, (uint)Expandable.Transparency, this))
                {
                    if (header.expanded)
                    {
                        DoDistortionInputsGUI();
                    }
                }
            }

            using (var header = new HeaderScope(Styles.emissiveLabelText, (uint)Expandable.Emissive, this))
            {
                if (header.expanded)
                {
                    EditorGUI.BeginChangeCheck();
                    m_MaterialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissiveIntensityText);
                    bool updateEmissiveColor = EditorGUI.EndChangeCheck();

                    if (useEmissiveIntensity.floatValue == 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        DoEmissiveTextureProperty(material, emissiveColor);
                        if (EditorGUI.EndChangeCheck() || updateEmissiveColor)
                        {
                            emissiveColor.colorValue = emissiveColor.colorValue;
                        }
                        EditorGUILayout.HelpBox(Styles.emissiveIntensityFromHDRColorText.text, MessageType.Info, true);
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            DoEmissiveTextureProperty(material, emissiveColorLDR);
                            emissiveColorLDR.colorValue = NormalizeEmissionColor(ref updateEmissiveColor, emissiveColorLDR.colorValue);

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue;

                                if (unit == EmissiveIntensityUnit.Luminance)
                                {
                                    m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
                                }
                                else
                                {
                                    float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue);
                                    evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue);
                                    emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue);
                                }
                                emissiveIntensityUnit.floatValue = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit);
                            }
                        }
                        if (EditorGUI.EndChangeCheck() || updateEmissiveColor)
                        {
                            emissiveColor.colorValue = emissiveColorLDR.colorValue * emissiveIntensity.floatValue;
                        }
                    }

                    m_MaterialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText);

                    DoEmissionArea(material);
                }
            }
        }
        void DoLayeringInputGUI()
        {
            using (var header = new HeaderScope(styles.layersText.text, (uint)Expandable.Input, this))
            {
                if (header.expanded)
                {
                    EditorGUI.showMixedValue = layerCount.hasMixedValue;
                    EditorGUI.BeginChangeCheck();
                    int newLayerCount = EditorGUILayout.IntSlider(styles.layerCountText, (int)layerCount.floatValue, 2, 4);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Material material = m_MaterialEditor.target as Material;
                        Undo.RecordObject(material, "Change layer count");
                        numLayer = newLayerCount;
                    }

                    m_MaterialEditor.TexturePropertySingleLine(styles.layerMapMaskText, layerMaskMap);

                    EditorGUI.indentLevel++;
                    m_MaterialEditor.ShaderProperty(UVBlendMask, styles.UVBlendMaskText);
                    UVBaseMapping uvBlendMask = (UVBaseMapping)UVBlendMask.floatValue;

                    float X, Y, Z, W;
                    X = (uvBlendMask == UVBaseMapping.UV0) ? 1.0f : 0.0f;
                    Y = (uvBlendMask == UVBaseMapping.UV1) ? 1.0f : 0.0f;
                    Z = (uvBlendMask == UVBaseMapping.UV2) ? 1.0f : 0.0f;
                    W = (uvBlendMask == UVBaseMapping.UV3) ? 1.0f : 0.0f;

                    UVMappingMaskBlendMask.colorValue = new Color(X, Y, Z, W);

                    if (((UVBaseMapping)UVBlendMask.floatValue == UVBaseMapping.Planar) ||
                        ((UVBaseMapping)UVBlendMask.floatValue == UVBaseMapping.Triplanar))
                    {
                        m_MaterialEditor.ShaderProperty(texWorldScaleBlendMask, styles.layerTexWorldScaleText);
                    }
                    m_MaterialEditor.TextureScaleOffsetProperty(layerMaskMap);
                    EditorGUI.indentLevel--;

                    m_MaterialEditor.ShaderProperty(vertexColorMode, styles.vertexColorModeText);

                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = useMainLayerInfluence.hasMixedValue;
                    bool mainLayerModeInfluenceEnable = EditorGUILayout.Toggle(styles.useMainLayerInfluenceModeText, useMainLayerInfluence.floatValue > 0.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        useMainLayerInfluence.floatValue = mainLayerModeInfluenceEnable ? 1.0f : 0.0f;
                    }

                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = useHeightBasedBlend.hasMixedValue;
                    m_UseHeightBasedBlend    = EditorGUILayout.Toggle(styles.useHeightBasedBlendText, useHeightBasedBlend.floatValue > 0.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        useHeightBasedBlend.floatValue = m_UseHeightBasedBlend ? 1.0f : 0.0f;
                    }

                    if (m_UseHeightBasedBlend)
                    {
                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(heightTransition, styles.heightTransition);
                        EditorGUI.indentLevel--;
                    }

                    m_MaterialEditor.ShaderProperty(objectScaleAffectTile, mainLayerModeInfluenceEnable ? styles.objectScaleAffectTileText2 : styles.objectScaleAffectTileText);
                }
            }
        }
Ejemplo n.º 19
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            FindBaseMaterialProperties(props);
            FindMaterialProperties(props);

            m_MaterialEditor = materialEditor;

            // We should always register the key used to keep collapsable state
            InitExpandableState(materialEditor);

            // We should always do this call at the beginning
            m_MaterialEditor.serializedObject.Update();

            //Material material = m_MaterialEditor.target as Material;
            //AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));

            bool optionsChanged = false;

            EditorGUI.BeginChangeCheck();
            {
                BaseMaterialPropertiesGUI();
                if (enableHeightBlend != null)
                {
                    EditorGUI.indentLevel++;
                    m_MaterialEditor.ShaderProperty(enableHeightBlend, styles.enableHeightBlend);
                    if (enableHeightBlend.floatValue > 0)
                    {
                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(heightTransition, styles.heightTransition);
                        EditorGUI.indentLevel--;
                    }
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.Space();
            }
            if (EditorGUI.EndChangeCheck())
            {
                optionsChanged = true;
            }

            bool enablePerPixelNormalChanged = false;


            using (var header = new HeaderScope(StylesBaseUnlit.advancedText, (uint)Expandable.Advance, this))
            {
                if (header.expanded)
                {
                    // NB RenderQueue editor is not shown on purpose: we want to override it based on blend mode
                    m_MaterialEditor.EnableInstancingField();
                    if (m_MaterialEditor.IsInstancingEnabled())
                    {
                        EditorGUI.indentLevel++;
                        EditorGUI.BeginChangeCheck();
                        m_MaterialEditor.ShaderProperty(enableInstancedPerPixelNormal, styles.enableInstancedPerPixelNormal);
                        enablePerPixelNormalChanged = EditorGUI.EndChangeCheck();
                        EditorGUI.indentLevel--;
                    }
                }
            }

            if (optionsChanged || enablePerPixelNormalChanged)
            {
                foreach (var obj in m_MaterialEditor.targets)
                {
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
                }
            }

            // We should always do this call at the end
            m_MaterialEditor.serializedObject.ApplyModifiedProperties();
        }
        bool DoMaterialReferencesGUI(AssetImporter materialImporter)
        {
            bool layersChanged = false;

            using (var header = new HeaderScope(styles.materialReferencesText.text, (uint)LayerExpandable.MaterialReferences, this))
            {
                if (header.expanded)
                {
                    var width = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 90;

                    Material material = m_MaterialEditor.target as Material;

                    Color originalContentColor = GUI.contentColor;

                    float indentOffset    = EditorGUI.indentLevel * 15f;
                    float colorWidth      = 14;
                    float UVWidth         = 30;
                    float copyButtonWidth = EditorGUIUtility.singleLineHeight;
                    float endOffset       = 5f;

                    Rect headerLineRect         = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
                    Rect headerLabelRect        = new Rect(headerLineRect.x, headerLineRect.y, EditorGUIUtility.labelWidth - indentOffset, headerLineRect.height);
                    Rect headerUVRect           = new Rect(headerLineRect.x + headerLineRect.width - 48 - endOffset, headerLineRect.y, UVWidth + 5, headerLineRect.height);
                    Rect headerMaterialDropRect = new Rect(headerLineRect.x + headerLabelRect.width, headerLineRect.y, headerLineRect.width - headerLabelRect.width - headerUVRect.width, headerLineRect.height);

                    EditorGUI.LabelField(headerLabelRect, styles.layerNameHeader, EditorStyles.centeredGreyMiniLabel);
                    EditorGUI.LabelField(headerMaterialDropRect, styles.materialToCopyHeader, EditorStyles.centeredGreyMiniLabel);
                    EditorGUI.LabelField(headerUVRect, styles.uvHeader, EditorStyles.centeredGreyMiniLabel);

                    for (int layerIndex = 0; layerIndex < numLayer; ++layerIndex)
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUI.BeginChangeCheck();

                            Rect lineRect     = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
                            Rect colorRect    = new Rect(lineRect.x, lineRect.y, colorWidth, lineRect.height);
                            Rect materialRect = new Rect(lineRect.x + colorRect.width, lineRect.y, lineRect.width - UVWidth - colorWidth - copyButtonWidth + endOffset, lineRect.height);
                            Rect uvRect       = new Rect(lineRect.x + lineRect.width - copyButtonWidth - UVWidth - endOffset, lineRect.y, UVWidth, lineRect.height);
                            Rect copyRect     = new Rect(lineRect.x + lineRect.width - copyButtonWidth - endOffset, lineRect.y, copyButtonWidth, lineRect.height);

                            m_MaterialLayers[layerIndex] = EditorGUI.ObjectField(materialRect, styles.layerLabels[layerIndex], m_MaterialLayers[layerIndex], typeof(Material), true) as Material;
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObject(materialImporter, "Change layer material");
                                SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true);
                                layersChanged = true;
                            }


                            colorRect.width  = 30f;
                            GUI.contentColor = styles.layerColors[layerIndex];
                            EditorGUI.LabelField(colorRect, "■");
                            GUI.contentColor = originalContentColor;

                            m_WithUV[layerIndex] = EditorGUI.Toggle(uvRect, m_WithUV[layerIndex]);

                            if (GUI.Button(copyRect, GUIContent.none))
                            {
                                SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, !m_WithUV[layerIndex]);
                                layersChanged = true;
                            }

                            //fake the icon with two Console icon
                            //Rect copyRect = GUILayoutUtility.GetLastRect();
                            copyRect.x    -= 16;
                            copyRect.width = 40;
                            EditorGUI.LabelField(copyRect, styles.copyButtonIcon);
                            copyRect.x -= 3;
                            copyRect.y += 3;
                            EditorGUI.LabelField(copyRect, styles.copyButtonIcon);
                        }
                    }

                    EditorGUIUtility.labelWidth = width;
                }
            }

            return(layersChanged);
        }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            FindBaseMaterialProperties(props);
            FindMaterialProperties(props);

            m_MaterialEditor = materialEditor;

            // We should always register the key used to keep collapsable state
            InitExpandableState(materialEditor);

            // We should always do this call at the beginning
            m_MaterialEditor.serializedObject.Update();

            Material      material         = m_MaterialEditor.target as Material;
            AssetImporter materialImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(material.GetInstanceID()));

            InitializeMaterialLayers(materialImporter, ref m_MaterialLayers);

            bool optionsChanged = false;

            EditorGUI.BeginChangeCheck();
            {
                using (var header = new HeaderScope(StylesBaseUnlit.optionText, (uint)Expandable.Base, this))
                {
                    if (header.expanded)
                    {
                        BaseMaterialPropertiesGUI();
                    }
                }
                MaterialTesselationPropertiesGUI();
                VertexAnimationPropertiesGUI();
            }
            if (EditorGUI.EndChangeCheck())
            {
                optionsChanged = true;
            }

            // In case of pixel displacement and layered shader, all layers must used the same texture mapping for layer that have a heightmap
            // (Else the algorithm will not work correctly)
            if ((DisplacementMode)displacementMode.floatValue == DisplacementMode.Pixel)
            {
                float compareValue = -1.0f;
                bool  match        = true;

                if (material.GetTexture(kHeightMap + 0))
                {
                    compareValue = UVBase[0].floatValue;
                }
                if (material.GetTexture(kHeightMap + 1))
                {
                    if (compareValue == -1.0f)
                    {
                        compareValue = UVBase[1].floatValue;
                    }
                    else if (compareValue != UVBase[1].floatValue)
                    {
                        match = false;
                    }
                }
                if (material.GetTexture(kHeightMap + 2))
                {
                    if (compareValue == -1.0f)
                    {
                        compareValue = UVBase[2].floatValue;
                    }
                    else if (compareValue != UVBase[2].floatValue)
                    {
                        match = false;
                    }
                }
                if (material.GetTexture(kHeightMap + 3))
                {
                    if (compareValue == -1.0f)
                    {
                        compareValue = UVBase[3].floatValue;
                    }
                    else if (compareValue != UVBase[3].floatValue)
                    {
                        match = false;
                    }
                }

                if (!match)
                {
                    EditorGUILayout.HelpBox(styles.perPixelDisplacementLayersWarning.text, MessageType.Warning);
                }
            }


            bool layerChanged = DoLayersGUI(materialImporter);

            EditorGUI.BeginChangeCheck();
            {
                DoEmissiveGUI(material);
            }
            if (EditorGUI.EndChangeCheck())
            {
                optionsChanged = true;
            }

            using (var header = new HeaderScope(StylesBaseUnlit.advancedText, (uint)Expandable.Advance, this))
            {
                if (header.expanded)
                {
                    // NB RenderQueue editor is not shown on purpose: we want to override it based on blend mode
                    m_MaterialEditor.EnableInstancingField();
                    m_MaterialEditor.ShaderProperty(enableSpecularOcclusion, Styles.enableSpecularOcclusionText);
                }
            }

            if (layerChanged || optionsChanged)
            {
                foreach (var obj in m_MaterialEditor.targets)
                {
                    SetupMaterialKeywordsAndPassInternal((Material)obj);
                }

                // SaveAssetsProcessor the referenced material in the users data
                SaveMaterialLayers(materialImporter);
            }

            // We should always do this call at the end
            m_MaterialEditor.serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 22
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;
            float normalBlendSrcValue = normalBlendSrc.floatValue;
            float maskBlendSrcValue   = maskBlendSrc.floatValue;

            Decal.MaskBlendFlags maskBlendFlags = (Decal.MaskBlendFlags)maskBlendMode.floatValue;

            HDRenderPipelineAsset hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
            bool perChannelMask        = hdrp.renderPipelineSettings.decalSettings.perChannelMask;

            using (var header = new HeaderScope(Styles.InputsText, (uint)Expendable.Input, this))
            {
                if (header.expended)
                {
                    // Detect any changes to the material
                    EditorGUI.BeginChangeCheck();
                    {
                        m_MaterialEditor.TexturePropertySingleLine((material.GetFloat(kAlbedoMode) == 1.0f) ? Styles.baseColorText : Styles.baseColorText2, baseColorMap, baseColor);
                        // Currently always display Albedo contribution as we have an albedo tint that apply
                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(albedoMode, Styles.AlbedoModeText);
                        EditorGUI.indentLevel--;

                        m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap);
                        if (material.GetTexture(kNormalMap))
                        {
                            EditorGUI.indentLevel++;
                            normalBlendSrcValue = EditorGUILayout.Popup("Normal Opacity channel", (int)normalBlendSrcValue, blendSourceNames);
                            EditorGUI.indentLevel--;
                        }

                        m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapText[(int)maskBlendFlags], maskMap);
                        if (material.GetTexture(kMaskMap))
                        {
                            EditorGUI.indentLevel++;
                            maskBlendSrcValue = EditorGUILayout.Popup("Mask Opacity channel", (int)maskBlendSrcValue, blendSourceNames);
                            if (perChannelMask)
                            {
                                // Following condition force users to always have at least one attribute enabled
                                m_MaterialEditor.ShaderProperty(maskmapMetal, "Affect Metal");
                                if ((maskmapMetal.floatValue == 0.0f) && (maskmapAO.floatValue == 0.0f) && (maskmapSmoothness.floatValue == 0.0f))
                                {
                                    maskmapMetal.floatValue = 1.0f;
                                }
                                m_MaterialEditor.ShaderProperty(maskmapAO, "Affect AO");
                                if ((maskmapMetal.floatValue == 0.0f) && (maskmapAO.floatValue == 0.0f) && (maskmapSmoothness.floatValue == 0.0f))
                                {
                                    maskmapAO.floatValue = 1.0f;
                                }
                                m_MaterialEditor.ShaderProperty(maskmapSmoothness, "Affect Smoothness");
                                if ((maskmapMetal.floatValue == 0.0f) && (maskmapAO.floatValue == 0.0f) && (maskmapSmoothness.floatValue == 0.0f))
                                {
                                    maskmapSmoothness.floatValue = 1.0f;
                                }

                                maskBlendFlags = 0; // Re-init the mask

                                if (maskmapMetal.floatValue == 1.0f)
                                {
                                    maskBlendFlags |= Decal.MaskBlendFlags.Metal;
                                }
                                if (maskmapAO.floatValue == 1.0f)
                                {
                                    maskBlendFlags |= Decal.MaskBlendFlags.AO;
                                }
                                if (maskmapSmoothness.floatValue == 1.0f)
                                {
                                    maskBlendFlags |= Decal.MaskBlendFlags.Smoothness;
                                }
                            }
                            else // if perChannelMask is not enabled, force to have smoothness
                            {
                                maskBlendFlags = Decal.MaskBlendFlags.Smoothness;
                            }
                            EditorGUI.indentLevel--;
                        }

                        m_MaterialEditor.ShaderProperty(drawOrder, Styles.DrawOrderText);
                        m_MaterialEditor.ShaderProperty(decalMeshDepthBias, Styles.MeshDecalDepthBiasText);
                        m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);

                        EditorGUI.indentLevel--;

                        EditorGUILayout.HelpBox(
                            "Control of AO and Metal is based on option 'Enable Metal and AO properties' in HDRP Asset.\nThere is a performance cost of enabling this option.",
                            MessageType.Info);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        normalBlendSrc.floatValue = normalBlendSrcValue;
                        maskBlendSrc.floatValue   = maskBlendSrcValue;
                        maskBlendMode.floatValue  = (float)maskBlendFlags;
                        foreach (var obj in m_MaterialEditor.targets)
                        {
                            SetupMaterialKeywordsAndPassInternal((Material)obj);
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;
            float normalBlendSrcValue     = normalBlendSrc.floatValue;
            float maskBlendSrcValue       = maskBlendSrc.floatValue;
            float smoothnessRemapMinValue = smoothnessRemapMin.floatValue;
            float smoothnessRemapMaxValue = smoothnessRemapMax.floatValue;
            float AORemapMinValue         = AORemapMin.floatValue;
            float AORemapMaxValue         = AORemapMax.floatValue;

            Decal.MaskBlendFlags maskBlendFlags = (Decal.MaskBlendFlags)maskBlendMode.floatValue;

            HDRenderPipelineAsset hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
            bool perChannelMask        = hdrp.currentPlatformRenderPipelineSettings.decalSettings.perChannelMask;

            using (var header = new HeaderScope(Styles.InputsText, (uint)Expandable.Input, this))
            {
                if (header.expanded)
                {
                    // Detect any changes to the material
                    EditorGUI.BeginChangeCheck();
                    {
                        m_MaterialEditor.TexturePropertySingleLine((material.GetFloat(kAlbedoMode) == 1.0f) ? Styles.baseColorText : Styles.baseColorText2, baseColorMap, baseColor);
                        // Currently always display Albedo contribution as we have an albedo tint that apply
                        EditorGUI.indentLevel++;
                        m_MaterialEditor.ShaderProperty(albedoMode, Styles.albedoModeText);
                        EditorGUI.indentLevel--;
                        m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap);
                        if (material.GetTexture(kNormalMap))
                        {
                            EditorGUI.indentLevel++;
                            normalBlendSrcValue = EditorGUILayout.Popup("Normal Opacity channel", (int)normalBlendSrcValue, blendSourceNames);
                            EditorGUI.indentLevel--;
                        }

                        m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapText[(int)maskBlendFlags], maskMap);
                        if (material.GetTexture(kMaskMap))
                        {
                            EditorGUI.indentLevel++;

                            EditorGUILayout.MinMaxSlider(Styles.smoothnessRemappingText, ref smoothnessRemapMinValue, ref smoothnessRemapMaxValue, 0.0f, 1.0f);
                            if (perChannelMask)
                            {
                                m_MaterialEditor.ShaderProperty(metallicScale, Styles.metallicText);
                                EditorGUILayout.MinMaxSlider(Styles.aoRemappingText, ref AORemapMinValue, ref AORemapMaxValue, 0.0f, 1.0f);
                            }

                            maskBlendSrcValue = EditorGUILayout.Popup("Mask Opacity channel", (int)maskBlendSrcValue, blendSourceNames);

                            if (perChannelMask)
                            {
                                bool mustDisableScope = false;
                                if (maskmapMetal.floatValue + maskmapAO.floatValue + maskmapSmoothness.floatValue == 1.0f)
                                {
                                    mustDisableScope = true;
                                }

                                using (new EditorGUI.DisabledScope(mustDisableScope && maskmapMetal.floatValue == 1.0f))
                                {
                                    m_MaterialEditor.ShaderProperty(maskmapMetal, "Affect Metal");
                                }
                                using (new EditorGUI.DisabledScope(mustDisableScope && maskmapAO.floatValue == 1.0f))
                                {
                                    m_MaterialEditor.ShaderProperty(maskmapAO, "Affect AO");
                                }
                                using (new EditorGUI.DisabledScope(mustDisableScope && maskmapSmoothness.floatValue == 1.0f))
                                {
                                    m_MaterialEditor.ShaderProperty(maskmapSmoothness, "Affect Smoothness");
                                }

                                // Sanity condition in case for whatever reasons all value are 0.0 but it should never happen
                                if ((maskmapMetal.floatValue == 0.0f) && (maskmapAO.floatValue == 0.0f) && (maskmapSmoothness.floatValue == 0.0f))
                                {
                                    maskmapSmoothness.floatValue = 1.0f;
                                }

                                maskBlendFlags = 0; // Re-init the mask

                                if (maskmapMetal.floatValue == 1.0f)
                                {
                                    maskBlendFlags |= Decal.MaskBlendFlags.Metal;
                                }
                                if (maskmapAO.floatValue == 1.0f)
                                {
                                    maskBlendFlags |= Decal.MaskBlendFlags.AO;
                                }
                                if (maskmapSmoothness.floatValue == 1.0f)
                                {
                                    maskBlendFlags |= Decal.MaskBlendFlags.Smoothness;
                                }
                            }
                            else // if perChannelMask is not enabled, force to have smoothness
                            {
                                maskBlendFlags = Decal.MaskBlendFlags.Smoothness;
                            }

                            EditorGUI.indentLevel--;
                        }

                        m_MaterialEditor.ShaderProperty(maskMapBlueScale, Styles.maskMapBlueScaleText);
                        m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);
                        m_MaterialEditor.ShaderProperty(emissive, "Emissive");
                        if (emissive.floatValue == 1.0f)
                        {
                            m_MaterialEditor.ShaderProperty(useEmissiveIntensity, "Use Emission Intensity");

                            if (useEmissiveIntensity.floatValue == 1.0f)
                            {
                                m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColorLDR);
                                using (new EditorGUILayout.HorizontalScope())
                                {
                                    EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue;

                                    if (unit == EmissiveIntensityUnit.Luminance)
                                    {
                                        m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
                                    }
                                    else
                                    {
                                        float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue);
                                        evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue);
                                        emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue);
                                    }
                                    emissiveIntensityUnit.floatValue = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit);
                                }
                            }
                            else
                            {
                                m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColorHDR);
                            }
                        }

                        EditorGUI.indentLevel--;

                        EditorGUILayout.HelpBox(
                            "Control of AO and Metal is based on option 'Enable Metal and AO properties' in HDRP Asset.\nThere is a performance cost of enabling this option.",
                            MessageType.Info);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        normalBlendSrc.floatValue     = normalBlendSrcValue;
                        maskBlendSrc.floatValue       = maskBlendSrcValue;
                        maskBlendMode.floatValue      = (float)maskBlendFlags;
                        smoothnessRemapMin.floatValue = smoothnessRemapMinValue;
                        smoothnessRemapMax.floatValue = smoothnessRemapMaxValue;
                        AORemapMin.floatValue         = AORemapMinValue;
                        AORemapMax.floatValue         = AORemapMaxValue;
                        if (useEmissiveIntensity.floatValue == 1.0f)
                        {
                            emissiveColor.colorValue = emissiveColorLDR.colorValue * emissiveIntensity.floatValue;
                        }
                        else
                        {
                            emissiveColor.colorValue = emissiveColorHDR.colorValue;
                        }

                        foreach (var obj in m_MaterialEditor.targets)
                        {
                            SetupMaterialKeywordsAndPassInternal((Material)obj);
                        }
                    }
                }
            }

            EditorGUI.indentLevel++;
            using (var header = new HeaderScope(Styles.SortingText, (uint)Expandable.Sorting, this))
            {
                if (header.expanded)
                {
                    m_MaterialEditor.ShaderProperty(drawOrder, Styles.drawOrderText);
                    m_MaterialEditor.ShaderProperty(decalMeshDepthBias, Styles.meshDecalDepthBiasText);
                }
            }
            EditorGUI.indentLevel--;
        }