internal static void DoEmissiveIntensityGUI(MaterialEditor materialEditor, MaterialProperty emissiveIntensity, MaterialProperty emissiveIntensityUnit) { bool unitIsMixed = emissiveIntensityUnit.hasMixedValue; bool intensityIsMixed = unitIsMixed || emissiveIntensity.hasMixedValue; using (new EditorGUILayout.HorizontalScope()) { EditorGUI.showMixedValue = intensityIsMixed; EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; if (unitIsMixed) { using (new EditorGUI.DisabledScope(true)) materialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); } else { if (!intensityIsMixed && unit == EmissiveIntensityUnit.EV100) { float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue); evValue = Mathf.Clamp(evValue, 0, float.MaxValue); emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); } else { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); if (EditorGUI.EndChangeCheck()) { emissiveIntensity.floatValue = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); } } } EditorGUI.showMixedValue = emissiveIntensityUnit.hasMixedValue; EditorGUI.BeginChangeCheck(); var newUnit = (EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit); if (EditorGUI.EndChangeCheck()) { emissiveIntensityUnit.floatValue = (float)newUnit; } } EditorGUI.showMixedValue = false; }
void DrawDecalGUI() { normalBlendSrcValue = normalBlendSrc.floatValue; maskBlendSrcValue = maskBlendSrc.floatValue; smoothnessRemapMinValue = smoothnessRemapMin.floatValue; smoothnessRemapMaxValue = smoothnessRemapMax.floatValue; AORemapMinValue = AORemapMin.floatValue; AORemapMaxValue = AORemapMax.floatValue; maskBlendFlags = (Decal.MaskBlendFlags)maskBlendMode.floatValue; HDRenderPipelineAsset hdrp = HDRenderPipeline.currentAsset; bool perChannelMask = hdrp.currentPlatformRenderPipelineSettings.decalSettings.perChannelMask; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { materialEditor.TexturePropertySingleLine((materials[0].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++; materialEditor.ShaderProperty(albedoMode, Styles.albedoModeText); EditorGUI.indentLevel--; materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap); if (materials.All(m => m.GetTexture(kNormalMap))) { EditorGUI.indentLevel++; normalBlendSrcValue = EditorGUILayout.Popup(Styles.normalOpacityChannelText, (int)normalBlendSrcValue, blendSourceNames); EditorGUI.indentLevel--; } materialEditor.TexturePropertySingleLine(Styles.maskMapText[(int)maskBlendFlags], maskMap); if (materials.All(m => m.GetTexture(kMaskMap))) { EditorGUI.indentLevel++; EditorGUILayout.MinMaxSlider(Styles.smoothnessRemappingText, ref smoothnessRemapMinValue, ref smoothnessRemapMaxValue, 0.0f, 1.0f); if (perChannelMask) { materialEditor.ShaderProperty(metallicScale, Styles.metallicText); EditorGUILayout.MinMaxSlider(Styles.aoRemappingText, ref AORemapMinValue, ref AORemapMaxValue, 0.0f, 1.0f); } maskBlendSrcValue = EditorGUILayout.Popup(Styles.maskOpacityChannelText, (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)) { materialEditor.ShaderProperty(maskmapMetal, Styles.affectMetalText); } using (new EditorGUI.DisabledScope(mustDisableScope && maskmapAO.floatValue == 1.0f)) { materialEditor.ShaderProperty(maskmapAO, Styles.affectAmbientOcclusionText); } using (new EditorGUI.DisabledScope(mustDisableScope && maskmapSmoothness.floatValue == 1.0f)) { materialEditor.ShaderProperty(maskmapSmoothness, Styles.affectSmoothnessText); } // 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--; } materialEditor.ShaderProperty(maskMapBlueScale, Styles.maskMapBlueScaleText); materialEditor.ShaderProperty(decalBlend, Styles.decalBlendText); materialEditor.ShaderProperty(emissive, Styles.emissiveText); if (emissive.floatValue == 1.0f) { materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissionIntensityText); if (useEmissiveIntensity.floatValue == 1.0f) { materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorLDR); using (new EditorGUILayout.HorizontalScope()) { EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; if (unit == EmissiveIntensityUnit.Nits) { 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 { materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorHDR); } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); } if (!perChannelMask) { EditorGUILayout.HelpBox("Enable 'Metal and AO properties' in your HDRP Asset if you want to control the Metal and AO properties of decals.\nThere is a performance cost of enabling this option.", MessageType.Info); } } }
void DrawEmissionGUI() { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissiveIntensityText); bool updateEmissiveColor = EditorGUI.EndChangeCheck(); if (useEmissiveIntensity.floatValue == 0) { EditorGUI.BeginChangeCheck(); DoEmissiveTextureProperty(emissiveColor); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { emissiveColor.colorValue = emissiveColor.colorValue; } EditorGUILayout.HelpBox(Styles.emissiveIntensityFromHDRColorText.text, MessageType.Info, true); } else { EditorGUI.BeginChangeCheck(); { DoEmissiveTextureProperty(emissiveColorLDR); emissiveColorLDR.colorValue = NormalizeEmissionColor(ref updateEmissiveColor, emissiveColorLDR.colorValue); using (new EditorGUILayout.HorizontalScope()) { EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; if (unit == EmissiveIntensityUnit.Luminance) { using (var change = new EditorGUI.ChangeCheckScope()) { materialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); if (change.changed) { emissiveIntensity.floatValue = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); } } } else { float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue); evValue = Mathf.Clamp(evValue, 0, float.MaxValue); emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); } emissiveIntensityUnit.floatValue = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit); } } if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { emissiveColor.colorValue = emissiveColorLDR.colorValue * emissiveIntensity.floatValue; } } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); if ((m_Features & Features.MultiplyWithBase) != 0) { materialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText); } // Emission for GI? if ((m_Features & Features.EnableEmissionForGI) != 0) { if (materialEditor.EmissionEnabledProperty()) { // change the GI flag and fix it up with emissive as black if necessary materialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true, true); } } }
void DrawEmissionGUI() { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissiveIntensityText); bool updateEmissiveColor = EditorGUI.EndChangeCheck(); if (useEmissiveIntensity.floatValue == 0) { EditorGUI.BeginChangeCheck(); DoEmissiveTextureProperty(emissiveColor); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { emissiveColor.colorValue = emissiveColor.colorValue; } EditorGUILayout.HelpBox(Styles.emissiveIntensityFromHDRColorText.text, MessageType.Info, true); } else { float newUnitFloat; float newIntensity = emissiveIntensity.floatValue; bool unitIsMixed = emissiveIntensityUnit.hasMixedValue; bool intensityIsMixed = unitIsMixed || emissiveIntensity.hasMixedValue; bool intensityChanged = false; bool unitChanged = false; EditorGUI.BeginChangeCheck(); { DoEmissiveTextureProperty(emissiveColorLDR); using (new EditorGUILayout.HorizontalScope()) { EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; EditorGUI.showMixedValue = intensityIsMixed; if (unit == EmissiveIntensityUnit.Nits) { using (var change = new EditorGUI.ChangeCheckScope()) { materialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); intensityChanged = change.changed; if (intensityChanged) { newIntensity = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); } } } else { float value = emissiveIntensity.floatValue; if (!intensityIsMixed) { float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue); newIntensity = Mathf.Clamp(evValue, 0, float.MaxValue); emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); } else { using (var change = new EditorGUI.ChangeCheckScope()) { newIntensity = EditorGUILayout.FloatField(Styles.emissiveIntensityText, value); intensityChanged = change.changed; } } } EditorGUI.showMixedValue = false; EditorGUI.showMixedValue = emissiveIntensityUnit.hasMixedValue; using (var change = new EditorGUI.ChangeCheckScope()) { newUnitFloat = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit); unitChanged = change.changed; } EditorGUI.showMixedValue = false; } } if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { if (unitChanged) { if (unitIsMixed) { UpdateEmissionUnit(newUnitFloat); } else { emissiveIntensityUnit.floatValue = newUnitFloat; } } // We don't allow changes on intensity if units are mixed if (intensityChanged && !unitIsMixed) { emissiveIntensity.floatValue = newIntensity; } UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(); } } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); if ((m_Features & Features.MultiplyWithBase) != 0) { materialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText); } // Emission for GI? if ((m_Features & Features.EnableEmissionForGI) != 0) { // Change the GI emission flag and fix it up with emissive as black if necessary. materialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); } }
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 DrawEmissionGUI() { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissiveIntensityText); bool updateEmissiveColor = EditorGUI.EndChangeCheck(); if (useEmissiveIntensity.floatValue == 0) { EditorGUI.BeginChangeCheck(); DoEmissiveTextureProperty(emissiveColor); if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { emissiveColor.colorValue = emissiveColor.colorValue; } EditorGUILayout.HelpBox(Styles.emissiveIntensityFromHDRColorText.text, MessageType.Info, true); } else { EditorGUI.BeginChangeCheck(); DoEmissiveTextureProperty(emissiveColorLDR); // Normalize all emissive colors for each target separately foreach (Material material in materials) { if (material.HasProperty(kEmissiveColorLDR)) { material.SetColor(kEmissiveColorLDR, NormalizeEmissionColor(ref updateEmissiveColor, material.GetColor(kEmissiveColorLDR))); } } if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { UpdateEmissiveColorAndIntensity(); } float newUnitFloat; float newIntensity = emissiveIntensity.floatValue; bool unitIsMixed = emissiveIntensityUnit.hasMixedValue; bool intensityIsMixed = unitIsMixed || emissiveIntensity.hasMixedValue; bool intensityChanged = false; bool unitChanged = false; EditorGUI.BeginChangeCheck(); { using (new EditorGUILayout.HorizontalScope()) { EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; EditorGUI.showMixedValue = intensityIsMixed; if (unit == EmissiveIntensityUnit.Nits) { using (var change = new EditorGUI.ChangeCheckScope()) { materialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); intensityChanged = change.changed; if (intensityChanged) { newIntensity = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); } } } else { float value = emissiveIntensity.floatValue; if (!intensityIsMixed) { float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue); newIntensity = Mathf.Clamp(evValue, 0, float.MaxValue); emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); } else { using (var change = new EditorGUI.ChangeCheckScope()) { newIntensity = EditorGUILayout.FloatField(Styles.emissiveIntensityText, value); intensityChanged = change.changed; } } } EditorGUI.showMixedValue = false; EditorGUI.showMixedValue = emissiveIntensityUnit.hasMixedValue; using (var change = new EditorGUI.ChangeCheckScope()) { newUnitFloat = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit); unitChanged = change.changed; } EditorGUI.showMixedValue = false; } } if (EditorGUI.EndChangeCheck() || updateEmissiveColor) { if (unitChanged) { if (unitIsMixed) { UpdateEmissionUnit(newUnitFloat); } else { emissiveIntensityUnit.floatValue = newUnitFloat; } } // We don't allow changes on intensity if units are mixed if (intensityChanged && !unitIsMixed) { emissiveIntensity.floatValue = newIntensity; } UpdateEmissiveColorAndIntensity(); } } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); if ((m_Features & Features.MultiplyWithBase) != 0) { materialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText); } // Emission for GI? if ((m_Features & Features.EnableEmissionForGI) != 0) { BakedEmissionEnabledProperty(materialEditor); } }
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++; EditorGUI.BeginChangeCheck(); var normalBlendSrcValue = (int)normalBlendSrc.floatValue; normalBlendSrcValue = EditorGUILayout.Popup(Styles.normalOpacityChannelText, normalBlendSrcValue, allMaskMap ? blendSourceNames : blendSourceNamesNoMap); if (EditorGUI.EndChangeCheck()) { normalBlendSrc.floatValue = normalBlendSrcValue; } EditorGUI.indentLevel--; } materialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap); EditorGUI.indentLevel++; if (allMaskMap) { if (perChannelMask) { float MetalRemapMinValue = metallicRemapMin.floatValue; float MetalRemapMaxValue = metallicRemapMax.floatValue; EditorGUI.BeginChangeCheck(); EditorGUILayout.MinMaxSlider(Styles.metallicRemappingText, ref MetalRemapMinValue, ref MetalRemapMaxValue, 0.0f, 1.0f); if (EditorGUI.EndChangeCheck()) { metallicRemapMin.floatValue = MetalRemapMinValue; metallicRemapMax.floatValue = MetalRemapMaxValue; } float AORemapMinValue = AORemapMin.floatValue; float AORemapMaxValue = AORemapMax.floatValue; EditorGUI.BeginChangeCheck(); EditorGUILayout.MinMaxSlider(Styles.aoRemappingText, ref AORemapMinValue, ref AORemapMaxValue, 0.0f, 1.0f); if (EditorGUI.EndChangeCheck()) { AORemapMin.floatValue = AORemapMinValue; AORemapMax.floatValue = AORemapMaxValue; } } float smoothnessRemapMinValue = smoothnessRemapMin.floatValue; float smoothnessRemapMaxValue = smoothnessRemapMax.floatValue; EditorGUI.BeginChangeCheck(); EditorGUILayout.MinMaxSlider(Styles.smoothnessRemappingText, ref smoothnessRemapMinValue, ref smoothnessRemapMaxValue, 0.0f, 1.0f); if (EditorGUI.EndChangeCheck()) { smoothnessRemapMin.floatValue = smoothnessRemapMinValue; smoothnessRemapMax.floatValue = smoothnessRemapMaxValue; } } else { if (perChannelMask) { materialEditor.ShaderProperty(metallic, Styles.metallicText); materialEditor.ShaderProperty(AO, Styles.aoText); } materialEditor.ShaderProperty(smoothness, Styles.smoothnessText); } EditorGUI.BeginChangeCheck(); var maskBlendSrcValue = (int)maskBlendSrc.floatValue; maskBlendSrcValue = EditorGUILayout.Popup(Styles.maskOpacityChannelText, maskBlendSrcValue, allMaskMap ? blendSourceNames : blendSourceNamesNoMap); if (EditorGUI.EndChangeCheck()) { maskBlendSrc.floatValue = maskBlendSrcValue; } EditorGUI.indentLevel--; materialEditor.ShaderProperty(maskMapBlueScale, allMaskMap ? Styles.maskMapBlueScaleText : Styles.opacityBlueScaleText); materialEditor.ShaderProperty(decalBlend, Styles.decalBlendText); //if (affectEmission.floatValue == 1.0f) // Always show emissive part using (var scope = new EditorGUI.ChangeCheckScope()) { materialEditor.ShaderProperty(useEmissiveIntensity, Styles.useEmissionIntensityText); if (useEmissiveIntensity.floatValue == 1.0f) { materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorLDR); using (new EditorGUILayout.HorizontalScope()) { EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; if (unit == EmissiveIntensityUnit.Nits) { 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 { materialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissiveColorMap, emissiveColorHDR); } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); // If anything change, update the emission value if (scope.changed) { if (useEmissiveIntensity.floatValue == 1.0f) { materialEditor.serializedObject.ApplyModifiedProperties(); foreach (Material target in materials) { target.UpdateEmissiveColorFromIntensityAndEmissiveColorLDR(); } materialEditor.serializedObject.Update(); } else { emissiveColor.colorValue = emissiveColorHDR.colorValue; } } } }
internal static void DoEmissiveIntensityGUI(MaterialEditor materialEditor, MaterialProperty emissiveIntensity, MaterialProperty emissiveIntensityUnit) { MaterialEditor.BeginProperty(emissiveIntensity); MaterialEditor.BeginProperty(emissiveIntensityUnit); bool unitIsMixed = emissiveIntensityUnit.hasMixedValue; bool intensityIsMixed = unitIsMixed || emissiveIntensity.hasMixedValue; float indent = 15 * EditorGUI.indentLevel; const int k_ValueUnitSeparator = 2; const int k_UnitWidth = 100; Rect valueRect = EditorGUILayout.GetControlRect(); valueRect.width += indent - k_ValueUnitSeparator - k_UnitWidth; Rect unitRect = valueRect; unitRect.x += valueRect.width - indent + k_ValueUnitSeparator; unitRect.width = k_UnitWidth + .5f; { EditorGUI.showMixedValue = intensityIsMixed; EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; if (unitIsMixed) { using (new EditorGUI.DisabledScope(true)) materialEditor.ShaderProperty(valueRect, emissiveIntensity, Styles.emissiveIntensityText); } else { if (!intensityIsMixed && unit == EmissiveIntensityUnit.EV100) { float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); evValue = EditorGUI.FloatField(valueRect, Styles.emissiveIntensityText, evValue); evValue = Mathf.Clamp(evValue, 0, s_MaxEvValue); emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); } else { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(valueRect, emissiveIntensity, Styles.emissiveIntensityText); if (EditorGUI.EndChangeCheck()) { emissiveIntensity.floatValue = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); } } } EditorGUI.showMixedValue = emissiveIntensityUnit.hasMixedValue; EditorGUI.BeginChangeCheck(); var newUnit = (EmissiveIntensityUnit)EditorGUI.EnumPopup(unitRect, unit); if (EditorGUI.EndChangeCheck()) { emissiveIntensityUnit.floatValue = (float)newUnit; } } EditorGUI.showMixedValue = false; MaterialEditor.EndProperty(); MaterialEditor.EndProperty(); }
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--; }