示例#1
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            materialEditor.PropertiesDefaultGUI(props);

            EmissionUIBlock.BakedEmissionEnabledProperty(materialEditor);

            // Make sure all selected materials are initialized.
            string materialTag = "MotionVector";

            foreach (var obj in materialEditor.targets)
            {
                var    material = (Material)obj;
                string tag      = material.GetTag(materialTag, false, "Nothing");
                if (tag == "Nothing")
                {
                    material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, false);
                    material.SetOverrideTag(materialTag, "User");
                }
            }

            {
                // If using multi-select, apply toggled material to all materials.
                bool enabled = ((Material)materialEditor.target).GetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr);
                EditorGUI.BeginChangeCheck();
                enabled = EditorGUILayout.Toggle("Motion Vector For Vertex Animation", enabled);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var obj in materialEditor.targets)
                    {
                        var material = (Material)obj;
                        material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, enabled);
                    }
                }
            }

            if (DiffusionProfileMaterialUI.IsSupported(materialEditor))
            {
                DiffusionProfileMaterialUI.OnGUI(materialEditor, FindProperty("_DiffusionProfileAsset", props), FindProperty("_DiffusionProfileHash", props), 0);
            }
        }
示例#2
0
        void DrawDecalGUI()
        {
            var  material         = materials[0];
            bool affectAlbedo     = material.HasProperty(kAffectAlbedo) && material.GetFloat(kAffectAlbedo) == 1.0f;
            bool affectNormal     = material.HasProperty(kAffectNormal) && material.GetFloat(kAffectNormal) == 1.0f;
            bool affectMetal      = material.HasProperty(kAffectMetal) && material.GetFloat(kAffectMetal) == 1.0f;
            bool affectSmoothness = material.HasProperty(kAffectSmoothness) && material.GetFloat(kAffectSmoothness) == 1.0f;
            bool affectAO         = material.HasProperty(kAffectAO) && material.GetFloat(kAffectAO) == 1.0f;
            bool affectEmission   = material.HasProperty(kAffectEmission) && material.GetFloat(kAffectEmission) == 1.0f;
            bool affectMaskmap    = affectMetal || affectAO || affectSmoothness;

            bool perChannelMask        = false;
            HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset;

            if (hdrp != null)
            {
                perChannelMask = hdrp.currentPlatformRenderPipelineSettings.decalSettings.perChannelMask;
            }

            bool allMaskMap = materials.All(m => m.GetTexture(kMaskMap));

            if (affectAlbedo)
            {
                materialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap, baseColor);
            }
            else
            {
                Color color = baseColor.colorValue;
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = baseColor.hasMixedValue;
                color.a = EditorGUILayout.Slider(Styles.baseOpacityText, color.a, 0.0f, 1.0f);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    baseColor.colorValue = color;
                }
            }

            using (new EditorGUI.DisabledScope(!affectNormal))
            {
                materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap);
                if (materials.All(m => m.GetTexture(kNormalMap)))
                {
                    EditorGUI.indentLevel++;
                    materialEditor.PopupShaderProperty(normalBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap);
                    EditorGUI.indentLevel--;
                }
            }

            using (new EditorGUI.DisabledScope(!affectMaskmap))
            {
                materialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap);
                EditorGUI.indentLevel++;
                if (allMaskMap)
                {
                    if (perChannelMask)
                    {
                        using (new EditorGUI.DisabledScope(!affectMetal))
                            materialEditor.MinMaxShaderProperty(metallicRemapMin, metallicRemapMax, 0.0f, 1.0f, Styles.metallicRemappingText);
                        using (new EditorGUI.DisabledScope(!affectAO))
                            materialEditor.MinMaxShaderProperty(AORemapMin, AORemapMax, 0.0f, 1.0f, Styles.aoRemappingText);
                    }

                    using (new EditorGUI.DisabledScope(!affectSmoothness))
                        materialEditor.MinMaxShaderProperty(smoothnessRemapMin, smoothnessRemapMax, 0.0f, 1.0f, Styles.smoothnessRemappingText);
                }
                else
                {
                    if (perChannelMask)
                    {
                        using (new EditorGUI.DisabledScope(!affectMetal))
                            materialEditor.ShaderProperty(metallic, Styles.metallicText);
                        using (new EditorGUI.DisabledScope(!affectAO))
                            materialEditor.ShaderProperty(AO, Styles.aoText);
                    }
                    using (new EditorGUI.DisabledScope(!affectSmoothness))
                        materialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
                }

                materialEditor.PopupShaderProperty(maskBlendSrc, Styles.maskOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap);

                EditorGUI.indentLevel--;
            }

            bool useBlueScale = (affectMaskmap && maskBlendSrc.floatValue == (float)BlendSource.MaskMapBlue) ||
                                (affectNormal && normalBlendSrc.floatValue == (float)BlendSource.MaskMapBlue);

            using (new EditorGUI.DisabledScope(!useBlueScale))
                materialEditor.ShaderProperty(maskMapBlueScale, allMaskMap ? Styles.maskMapBlueScaleText : Styles.opacityBlueScaleText);
            materialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);

            using (new EditorGUI.DisabledScope(!affectEmission))
            {
                EditorGUI.BeginChangeCheck();
                materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissionIntensityText);
                bool updateEmissiveColor = EditorGUI.EndChangeCheck();

                if (useEmissiveIntensity.floatValue == 0.0f)
                {
                    EditorGUI.BeginChangeCheck();
                    EmissionUIBlock.DoEmissiveTextureProperty(materialEditor, emissiveColorMap, emissiveColorLDR);
                    if (EditorGUI.EndChangeCheck() || updateEmissiveColor)
                    {
                        emissiveColor.colorValue = emissiveColorHDR.colorValue;
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EmissionUIBlock.DoEmissiveTextureProperty(materialEditor, emissiveColorMap, emissiveColorLDR);
                    EmissionUIBlock.DoEmissiveIntensityGUI(materialEditor, emissiveIntensity, emissiveIntensityUnit);
                    if (EditorGUI.EndChangeCheck() || updateEmissiveColor)
                    {
                        EmissionUIBlock.UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(materialEditor, materials);
                    }
                }

                materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText);
            }
        }
示例#3
0
        void DrawDecalGUI()
        {
            bool perChannelMask        = false;
            HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset;

            if (hdrp != null)
            {
                perChannelMask = hdrp.currentPlatformRenderPipelineSettings.decalSettings.perChannelMask;
            }

            bool allMaskMap = materials.All(m => m.GetTexture(kMaskMap));

            materialEditor.TexturePropertySingleLine((materials[0].GetFloat(kAffectAlbedo) == 1.0f) ? Styles.baseColorText : Styles.baseColorText2, baseColorMap, baseColor);

            materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap);
            if (materials.All(m => m.GetTexture(kNormalMap)))
            {
                EditorGUI.indentLevel++;
                PopupShaderProperty(normalBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap);
                EditorGUI.indentLevel--;
            }

            materialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap);
            EditorGUI.indentLevel++;
            if (allMaskMap)
            {
                if (perChannelMask)
                {
                    MinMaxShaderProperty(metallicRemapMin, metallicRemapMax, 0.0f, 1.0f, Styles.metallicRemappingText);
                    MinMaxShaderProperty(AORemapMin, AORemapMax, 0.0f, 1.0f, Styles.aoRemappingText);
                }

                MinMaxShaderProperty(smoothnessRemapMin, smoothnessRemapMax, 0.0f, 1.0f, Styles.smoothnessRemappingText);
            }
            else
            {
                if (perChannelMask)
                {
                    materialEditor.ShaderProperty(metallic, Styles.metallicText);
                    materialEditor.ShaderProperty(AO, Styles.aoText);
                }
                materialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
            }

            PopupShaderProperty(maskBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap);

            EditorGUI.indentLevel--;

            materialEditor.ShaderProperty(maskMapBlueScale, allMaskMap ? Styles.maskMapBlueScaleText : Styles.opacityBlueScaleText);
            materialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);

            EditorGUI.BeginChangeCheck();
            materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissionIntensityText);
            bool updateEmissiveColor = EditorGUI.EndChangeCheck();

            if (useEmissiveIntensity.floatValue == 0.0f)
            {
                EditorGUI.BeginChangeCheck();
                materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorHDR);
                if (EditorGUI.EndChangeCheck() || updateEmissiveColor)
                {
                    emissiveColor.colorValue = emissiveColorHDR.colorValue;
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorLDR);
                EmissionUIBlock.DoEmissiveIntensityGUI(materialEditor, emissiveIntensity, emissiveIntensityUnit);
                if (EditorGUI.EndChangeCheck() || updateEmissiveColor)
                {
                    EmissionUIBlock.UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(materialEditor, materials);
                }
            }

            materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText);
        }
示例#4
0
 void DrawEmissionGI()
 {
     EmissionUIBlock.BakedEmissionEnabledProperty(materialEditor);
 }