public TexturePropertyWithHDRColor ( |
||
label | ||
textureProp | ||
colorProperty | ||
hdrConfig | ||
showAlpha | bool | |
return |
void DoEmissionArea(Material material) { // Emission for GI? if (m_MaterialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls #if UNITY_2018_1_OR_NEWER m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false); #else m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false); #endif // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); } }
void DoAlbedoArea(Material material) { m_MaterialEditor.TexturePropertyWithHDRColor(Styles.albedoText, albedoMap, albedoColor, true); if (((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout)) { m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText, MaterialEditor.kMiniTextureFieldLabelIndentLevel); } }
void DoEmissionArea(Material material) { // Emission for GI? if (m_MaterialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false); if (material.globalIlluminationFlags.HasFlag(MaterialGlobalIlluminationFlags.EmissiveIsBlack)) { material.GetPropertyState(MaterialSerializedProperty.LightmapFlags, out _, out _, out bool lockedByAncestor); if (lockedByAncestor) { EditorGUILayout.HelpBox("Emissive lighting is locked to black by a parent Material. Changing the emissive color will have no effect.", MessageType.Warning); } } // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); } }
public void WireframePropertiesGUI(MaterialEditor materialEditor, Material material) { AlphaMode alphaMode = (AlphaMode)wireframeAlphaMode.floatValue; EditorGUILayout.Space(); if (WireframeGridShaderGUI.logo == null) { WireframeGridShaderGUI.logo = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Digicrafts/WireframeGrid/Shaders/Editor/logo.png"); } if (WireframeGridShaderGUI.logoStyle == null) { WireframeGridShaderGUI.logoStyle = new GUIStyle(GUI.skin.GetStyle("Label")); WireframeGridShaderGUI.logoStyle.alignment = TextAnchor.UpperCenter; WireframeGridShaderGUI.logoStyle.normal.background = WireframeGridShaderGUI.logo; } GUILayout.Label("", WireframeGridShaderGUI.logoStyle, GUILayout.Height(50)); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Wireframe Settings", MessageType.None); EditorGUILayout.Space(); GUILayout.Label(Styles.wireframeBasicTitleText, EditorStyles.boldLabel); materialEditor.ShaderProperty(wireframeSize, Styles.wireframeSizeText.text); // materialEditor.ShaderProperty(_WireframeSizeScale,Styles._WireframeSizeScale.text); materialEditor.ShaderProperty(_GridSpacing, Styles._GridSpacing.text); materialEditor.ShaderProperty(_GridSpacingScale, Styles._GridSpacingScale.text); materialEditor.ShaderProperty(_GridUseWorldspace, Styles._GridUseWorldspace.text); materialEditor.ShaderProperty(wireframeDoubleSided, Styles.wireframeDoubleSidedText.text); materialEditor.ShaderProperty(wireframeAA, Styles.wireframeAAText.text); materialEditor.ShaderProperty(wireframeLighting, Styles.wireframeLightingText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.wireframeColorTitleText, EditorStyles.boldLabel); materialEditor.TexturePropertyWithHDRColor(Styles.wireframeTexText, wireframeTex, wireframeColor, new ColorPickerHDRConfig(0, 2, 0, 2), true); if (alphaMode == AlphaMode.Mask) { materialEditor.TexturePropertySingleLine(Styles.wireframeMaskTexText, wireframeMaskTex); } WireframeAlphaModePopup(materialEditor, material); materialEditor.ShaderProperty(wireframeAlphaCutoff, Styles.wireframeAlphaCutoffText.text); if (wireframeEmissionColor != null) { materialEditor.ShaderProperty(wireframeEmissionColor, Styles.wireframeEmissionColor.text); } EditorGUILayout.Space(); materialEditor.TextureScaleOffsetProperty(wireframeTex); materialEditor.ShaderProperty(wireframeUV, Styles.wireframeUVText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.wireframeAnimationTitleText, EditorStyles.boldLabel); materialEditor.ShaderProperty(wireframeTexAniSpeedX, Styles.wireframeTexAniSpeedXText.text); materialEditor.ShaderProperty(wireframeTexAniSpeedY, Styles.wireframeTexAniSpeedYText.text); EditorGUILayout.Space(); // Double Sided if (wireframeDoubleSided.floatValue > 0) { material.SetInt("_WireframeCull", (int)UnityEngine.Rendering.CullMode.Off); } else { material.SetInt("_WireframeCull", (int)UnityEngine.Rendering.CullMode.Back); } }
void DoEmissionArea(Material material) { float brightness = emissionColorForRendering.colorValue.maxColorComponent; bool showHelpBox = !HasValidEmissiveKeyword(material); bool showEmissionColorAndGIControls = brightness > 0.0f; bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false); // If texture was assigned and color was black set color to white if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // Dynamic Lightmapping mode if (showEmissionColorAndGIControls) { bool shouldEmissionBeEnabled = ShouldEmissionBeEnabled(emissionColorForRendering.colorValue); EditorGUI.BeginDisabledGroup(!shouldEmissionBeEnabled); m_MaterialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); EditorGUI.EndDisabledGroup(); } if (showHelpBox) { EditorGUILayout.HelpBox(Styles.emissiveWarning.text, MessageType.Warning); } }
void DoEmissionArea(Material material) { bool showHelpBox = !HasValidEmissiveKeyword(material); bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false); // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // Emission for GI? m_MaterialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); if (showHelpBox) { EditorGUILayout.HelpBox(Styles.emissiveWarning.text, MessageType.Warning); } }
void DoEmissionArea(Material material) { // Emission for GI? if (m_MaterialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false); // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // LW does not support RealtimeEmissive. We set it to bake emissive and handle the emissive is black right. material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive; if (brightness <= 0f) { material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack; } } }
void DoEmissionArea(Material material) { // Emission for GI? if (m_MaterialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = siMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.siMapTintText, siMap, siTint, m_ColorPickerHDRConfig, false); // If texture was assigned and color was black set color to white float brightness = siTint.colorValue.maxColorComponent; if (siMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { siTint.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); m_MaterialEditor.TexturePropertySingleLine(Styles.siPackText, siPack); m_MaterialEditor.ShaderProperty(siPanSpeed, Styles.siPanSpeed); // #### Oscillators #### // m_MaterialEditor.ShaderProperty(siOscEnabled, Styles.siOscEnabled); if (siOscEnabled.floatValue == 1) { m_MaterialEditor.RangeProperty(siOscPower, Styles.siOscPower); m_MaterialEditor.RangeProperty(siOscSpeed, Styles.siOscSpeed); m_MaterialEditor.ShaderProperty(siOscMode, Styles.siOscMode); m_MaterialEditor.ShaderProperty(siOscClampsEnabled, Styles.siOscClampsEnabled); if (siOscClampsEnabled.floatValue == 1) { m_MaterialEditor.ShaderProperty(siOscClamps, Styles.siOscClamps); } } } }
void Albedo2Popup(Material material) { EditorGUI.showMixedValue = albedo2Enabled.hasMixedValue; var enabled = (albedo2Enabled.floatValue != 0.0f); EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.albedo2EnabledText, enabled); if (EditorGUI.EndChangeCheck()) { m_MaterialEditor.RegisterPropertyChangeUndo("Distortion Enabled"); albedo2Enabled.floatValue = enabled ? 1.0f : 0.0f; } if (enabled) { int indentation = 2; m_MaterialEditor.TexturePropertyWithHDRColor(Styles.albedo2Text, albedo2Map, albedo2Color, true); if (albedo2Mode != null) { EditorGUI.showMixedValue = albedo2Mode.hasMixedValue; var mode = (VRLBlend)albedo2Mode.floatValue; EditorGUI.BeginChangeCheck(); mode = (VRLBlend)EditorGUILayout.Popup(Styles.albedo2BlendText, (int)mode, Styles.VRLblendNames); if (EditorGUI.EndChangeCheck()) { m_MaterialEditor.RegisterPropertyChangeUndo("Color Mode"); albedo2Mode.floatValue = (float)mode; } EditorGUI.showMixedValue = false; } m_MaterialEditor.ShaderProperty(albedo2Scroll, Styles.albedo2ScrollText, indentation); } EditorGUI.showMixedValue = false; }
protected void DoEmissionArea() { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls editor.TexturePropertyWithHDRColor(emissionTexturePropertyText, emissionMap, emissionColor, false); // If texture was assigned and color was black set color to white float brightness = emissionColor.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColor.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary editor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); }
void DoEmissionArea(Material material) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColor, false); // If texture was assigned and color was black set color to white float brightness = emissionColor.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColor.colorValue = Color.white; } }
private void DoEmissionArea(Material material) { if (_mMaterialEditor.EmissionEnabledProperty()) { var hadEmissionTexture = _emissionMap.textureValue != null; _mMaterialEditor.TexturePropertyWithHDRColor(Styles.EmissionText, _emissionMap, _emissionColorForRendering, _mColorPickerHdrConfig, false); var brightness = _emissionColorForRendering.colorValue.maxColorComponent; if (_emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { _emissionColorForRendering.colorValue = Color.white; } _mMaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); } }
void DoEmissionArea(Material material) { // Emission for GI? if (m_MaterialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false); // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); m_MaterialEditor.FloatProperty(emissiveBoost, "GI Emissive boost"); } m_MaterialEditor.ShaderProperty(isAVProInput, "Is AVPro input"); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Front-face properties", EditorStyles.boldLabel); EditorGUILayout.Space(); // albedo materialEditor.TexturePropertySingleLine(_albedoText, _mainTex, _color); // metallic / smoothness if (_metallicGlossMap.textureValue == null) materialEditor.TexturePropertyTwoLines(_metallicText, _metallicGlossMap, _metallic, _smoothnessText, _glossiness); else materialEditor.TexturePropertySingleLine(_metallicText, _metallicGlossMap); // normal map materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null); // occlusion materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue != null ? _occlusionStrength : null); // emission bool hadEmissionTexture = _emissionMap.textureValue != null; materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, _colorPickerHDRConfig, false); // if texture was assigned and color was black set color to white if (_emissionMap.textureValue != null && !hadEmissionTexture) if (_emissionColor.colorValue.maxColorComponent <= 0) _emissionColor.colorValue = Color.white; EditorGUILayout.Space(); // backface properties EditorGUILayout.LabelField("Back-face properties", EditorStyles.boldLabel); EditorGUILayout.Space(); materialEditor.ShaderProperty(_backColor, "Color"); materialEditor.ShaderProperty(_backMetallic, "Matallic"); materialEditor.ShaderProperty(_backGlossiness, "Smoothness"); return EditorGUI.EndChangeCheck(); }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { if (m_FirstTimeApply) { foreach (var obj in materialEditor.targets) { MaterialChanged((Material)obj); } m_FirstTimeApply = false; } // Use default labelWidth EditorGUIUtility.labelWidth = 0.0f; EditorGUI.BeginChangeCheck(); { GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); // color var colorTexProp = ShaderGUI.FindProperty("_MainTex", properties); var colorProp = ShaderGUI.FindProperty("_Color", properties); materialEditor.TexturePropertySingleLine(Styles.colorText, colorTexProp, null, colorProp); // normal var normalTexProp = ShaderGUI.FindProperty("_BumpMap", properties); materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexProp); // extra var extraTexProp = ShaderGUI.FindProperty("_ExtraTex", properties); materialEditor.TexturePropertySingleLine(Styles.extraMapText, extraTexProp, null); if (extraTexProp.textureValue == null) { var glossProp = ShaderGUI.FindProperty("_Glossiness", properties); materialEditor.ShaderProperty(glossProp, Styles.smoothnessText, 2); var metallicProp = ShaderGUI.FindProperty("_Metallic", properties); materialEditor.ShaderProperty(metallicProp, Styles.metallicText, 2); } // subsurface var ssTexProp = ShaderGUI.FindProperty("_SubsurfaceTex", properties); var ssProp = ShaderGUI.FindProperty("_SubsurfaceColor", properties); materialEditor.TexturePropertySingleLine(Styles.subsurfaceMapText, ssTexProp, null, ssProp); // Emission emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", properties); emissionMap = ShaderGUI.FindProperty("_EmissionMap", properties); emissionMap.textureScaleAndOffset = colorTexProp.textureScaleAndOffset; // other options EditorGUILayout.Space(); GUILayout.Label(Styles.optionsText, EditorStyles.boldLabel); MakeAlignedProperty(FindProperty("_TwoSided", properties), Styles.twoSidedText, materialEditor, true); MakeAlignedProperty(FindProperty("_WindQuality", properties), Styles.windQualityText, materialEditor, true); MakeCheckedProperty(FindProperty("_HueVariationKwToggle", properties), FindProperty("_HueVariationColor", properties), Styles.hueVariationText, materialEditor); MakeAlignedProperty(FindProperty("_NormalMapKwToggle", properties), Styles.normalMappingText, materialEditor, true); // subsurface var subsurfaceToggle = FindProperty("_SubsurfaceKwToggle", properties); MakeAlignedProperty(subsurfaceToggle, Styles.subsurfaceText, materialEditor, true); if (subsurfaceToggle.floatValue > 0.0f) { var sssIndirectProp = ShaderGUI.FindProperty("_SubsurfaceIndirect", properties); materialEditor.ShaderProperty(sssIndirectProp, Styles.subsurfaceIndirectText, 2); } // billboard var billboardToggle = FindProperty("_BillboardKwToggle", properties); MakeAlignedProperty(billboardToggle, Styles.billboardText, materialEditor, true); if (billboardToggle.floatValue > 0.0f) { var prop = ShaderGUI.FindProperty("_BillboardShadowFade", properties); materialEditor.ShaderProperty(prop, Styles.billboardShadowFadeText, 2); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in materialEditor.targets) { Material mat = (Material)obj; MaterialChanged(mat); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); // Emission for GI? m_MaterialEditor = materialEditor; if (materialEditor.EmissionEnabledProperty()) { bool hadEmissionTexture = emissionMap.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false); // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering.colorValue.maxColorComponent; if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering.colorValue = Color.white; } // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); SetKeyword((Material)m_MaterialEditor.target, "EFFECT_EMISSION", true); } else { SetKeyword((Material)m_MaterialEditor.target, "EFFECT_EMISSION", false); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { // Blend mode BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); // Albedo _materialEditor.TexturePropertySingleLine(Styles.albedoText, _albedoMap); if (((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout)) { _materialEditor.ShaderProperty(_alphaCutoff, Styles.alphaCutoffText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); } // Normal _materialEditor.TexturePropertySingleLine(Styles.normalText, _normalMap); // Emission bool hadEmissionTexture = _emissionMap.textureValue != null; // Texture and HDR color controls _materialEditor.TexturePropertyWithHDRColor(Styles.emissionText, _emissionMap, _emissionColor, _ColorPickerHDRConfig, false); // If texture was assigned and color was black set color to white float brightness = _emissionColor.colorValue.maxColorComponent; if (_emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f) { _emissionColor.colorValue = Color.white; } // Draw the tiliding and offset panels of the albedo map (which we'll use for the other textures too) EditorGUI.BeginChangeCheck(); _materialEditor.TextureScaleOffsetProperty(_albedoMap); if (EditorGUI.EndChangeCheck()) { _emissionMap.textureScaleAndOffset = _normalMap.textureScaleAndOffset = _albedoMap.textureScaleAndOffset; } // HSV GUILayout.Label(Styles.hsvText, EditorStyles.boldLabel); _materialEditor.ShaderProperty(_hue, Styles.hueText.text); _materialEditor.ShaderProperty(_saturation, Styles.saturationText.text); _materialEditor.ShaderProperty(_value, Styles.valueText.text); } if (EditorGUI.EndChangeCheck()) { // Set again the rendering tags and keywords foreach (var obj in _blendMode.targets) { Material mat = (Material)obj; switch ((BlendMode)mat.GetFloat("_Mode")) { case BlendMode.Opaque: mat.SetOverrideTag("RenderType", "Opaque"); mat.DisableKeyword("_ALPHATEST_ON"); mat.renderQueue = -1; break; case BlendMode.Cutout: mat.SetOverrideTag("RenderType", "TransparentCutout"); mat.EnableKeyword("_ALPHATEST_ON"); mat.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest; break; } } } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { Material material = materialEditor.target as Material; FindProperties(properties); // Always needed vars bool surfaceModeChanged = false; var workflow = (WorkflowMode)workflowmodeProp.floatValue; var surface = (SurfaceType)surfaceTypeProp.floatValue; bool alphaclipChanged = false; var alphaclip = (alphaClipProp.floatValue == 1)? true : false; // ----------------------- // Help var txt = new GUIContent("Help"); var position = GUILayoutUtility.GetRect(txt, GUIStyle.none); var headerPos = new Rect(position.x + 1, position.y, position.width - 20, 20); var btnPos = new Rect(position.x + headerPos.width, position.y, 20, 20); GUI.Label(headerPos, new GUIContent("Help"), EditorStyles.boldLabel); if (GUI.Button(btnPos, helpbuttonGUIContent, EditorStyles.boldLabel)) { Help.BrowseURL(url); } GUILayout.Space(10); // ----------------------- // Surface Options openSurfaceOptions = (surfaceOptionsProps.floatValue == 1.0f) ? true : false; EditorGUI.BeginChangeCheck(); openSurfaceOptions = EditorGUILayout.BeginFoldoutHeaderGroup(openSurfaceOptions, "Surface Options"); if (EditorGUI.EndChangeCheck()) { surfaceOptionsProps.floatValue = openSurfaceOptions? 1.0f : 0.0f; } if (openSurfaceOptions) { // Workflow EditorGUI.BeginChangeCheck(); //var workflow = (WorkflowMode)workflowmodeProp.floatValue; workflow = (WorkflowMode)EditorGUILayout.EnumPopup("Workflow Mode", workflow); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Workflow Mode"); workflowmodeProp.floatValue = (float)workflow; if ((float)workflow == 0.0f) { material.EnableKeyword("_SPECULAR_SETUP"); } else { material.DisableKeyword("_SPECULAR_SETUP"); } } // Surface EditorGUI.BeginChangeCheck(); //var surface = (SurfaceType)surfaceTypeProp.floatValue; surface = (SurfaceType)EditorGUILayout.EnumPopup("Surface Type", surface); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Surface Type"); surfaceModeChanged = true; surfaceTypeProp.floatValue = (float)surface; if (surface == SurfaceType.Opaque) { material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); material.SetInt("_ZWrite", 1); material.SetOverrideTag("RenderType", "Opaque"); material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry + 50; material.SetShaderPassEnabled("ShadowCaster", true); } else { material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent + 50; // Make it match Standard Lit shader material.SetOverrideTag("RenderType", "Transparent"); material.SetShaderPassEnabled("ShadowCaster", false); } } // Culling EditorGUI.BeginChangeCheck(); var culling = (RenderFace)cullingProp.floatValue; culling = (RenderFace)EditorGUILayout.EnumPopup("Render Face", culling); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Cull"); cullingProp.floatValue = (float)culling; material.doubleSidedGI = (RenderFace)cullingProp.floatValue != RenderFace.Front; } // Alpha Clipping // Allow alpha clipping for transparents as well // if (surface == SurfaceType.Opaque) { EditorGUI.BeginChangeCheck(); alphaclip = EditorGUILayout.Toggle(new GUIContent("Alpha Clipping"), alphaClipProp.floatValue == 1); // Make sure we set alpha clip if surface type has changed only as well if (EditorGUI.EndChangeCheck() || surfaceModeChanged) { alphaclipChanged = true; if (alphaclip) { alphaClipProp.floatValue = 1; material.EnableKeyword("_ALPHATEST_ON"); material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest + 50; material.SetOverrideTag("RenderType", "TransparentCutout"); // We may have to re eanble camera fading if (cameraFadingEnabledProp.floatValue == 1) { material.EnableKeyword("_FADING_ON"); if (cameraFadeShadowsProp.floatValue == 1) { material.EnableKeyword("_FADING_SHADOWS_ON"); } else { material.DisableKeyword("_FADING_SHADOWS_ON"); } } else { material.DisableKeyword("_FADING_ON"); material.DisableKeyword("_FADING_SHADOWS_ON"); } } else { alphaClipProp.floatValue = 0; material.DisableKeyword("_ALPHATEST_ON"); material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry + 50; material.SetOverrideTag("RenderType", "Opaque"); material.DisableKeyword("_FADING_ON"); material.DisableKeyword("_FADING_SHADOWS_ON"); } } if (alphaclip) { materialEditor.ShaderProperty(alphaCutoffProp, "Threshold", 1); } // } // Camera Fading if (alphaclip) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(cameraFadingEnabledProp, "Camera Fading", 1); materialEditor.ShaderProperty(cameraFadeDistProp, "Fade Distance", 2); materialEditor.ShaderProperty(cameraFadeShadowsProp, "Fade Shadows", 2); materialEditor.ShaderProperty(cameraShadowFadeDistProp, "Shadow Fade Dist", 2); if (EditorGUI.EndChangeCheck()) { if (cameraFadingEnabledProp.floatValue == 1) { material.EnableKeyword("_FADING_ON"); if (cameraFadeShadowsProp.floatValue == 1) { material.EnableKeyword("_FADING_SHADOWS_ON"); } else { material.DisableKeyword("_FADING_SHADOWS_ON"); } } else { material.DisableKeyword("_FADING_ON"); material.DisableKeyword("_FADING_SHADOWS_ON"); } } } else { material.DisableKeyword("_FADING_ON"); material.DisableKeyword("_FADING_SHADOWS_ON"); } // Shadows EditorGUI.BeginChangeCheck(); var receiveShadows = EditorGUILayout.Toggle(new GUIContent("Receive Shadows"), receiveShadowsProp.floatValue == 1.0f); if (EditorGUI.EndChangeCheck()) { receiveShadowsProp.floatValue = receiveShadows ? 1.0f : 0.0f; if (receiveShadows) { material.DisableKeyword("_RECEIVE_SHADOWS_OFF"); } else { material.EnableKeyword("_RECEIVE_SHADOWS_OFF"); } } // Transparency if (surface == SurfaceType.Transparent) { EditorGUI.BeginChangeCheck(); //DoPopup(Styles.blendingMode, blendModeProp, Enum.GetNames(typeof(BlendMode))); var blendMode = (BlendMode)blendModeProp.floatValue; blendMode = (BlendMode)EditorGUILayout.EnumPopup("Blend Mode", blendMode); // Make sure we set blend mode if surface type has changed only as well if (EditorGUI.EndChangeCheck() || surfaceModeChanged) { blendModeProp.floatValue = (float)blendMode; material.DisableKeyword("_ALPHATEST_ON"); switch (blendMode) { case BlendMode.Alpha: material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); break; case BlendMode.Premultiply: material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); break; case BlendMode.Additive: material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); break; case BlendMode.Multiply: material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.EnableKeyword("_ALPHAMODULATE_ON"); break; } } } // ZTesting EditorGUI.BeginChangeCheck(); var ztest = (UnityEngine.Rendering.CompareFunction)ztestProp.floatValue; ztest = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("ZTest", ztest); if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("ZTest"); ztestProp.floatValue = (float)ztest; } // Spacing EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); // ----------------------- // Surface Inputs openSurfaceInputs = (surfaceInputsProps.floatValue == 1.0f) ? true : false; EditorGUI.BeginChangeCheck(); openSurfaceInputs = EditorGUILayout.BeginFoldoutHeaderGroup(openSurfaceInputs, "Surface Inputs"); if (EditorGUI.EndChangeCheck()) { surfaceInputsProps.floatValue = openSurfaceInputs? 1.0f : 0.0f; } if (openSurfaceInputs) { EditorGUILayout.Space(); // Basemap / Color materialEditor.TexturePropertySingleLine(new GUIContent("Base Map"), baseMapProp, baseColorProp); // Metallic string[] smoothnessChannelNames; bool hasGlossMap = false; if ((WorkflowMode)workflowmodeProp.floatValue == WorkflowMode.Metallic) { hasGlossMap = metallicGlossMapProp.textureValue != null; smoothnessChannelNames = Styles.metallicSmoothnessChannelNames; EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map"), metallicGlossMapProp, hasGlossMap ? null : metallicProp); if (EditorGUI.EndChangeCheck()) { if (metallicGlossMapProp.textureValue != null) { material.EnableKeyword("_METALLICSPECGLOSSMAP"); } else { material.DisableKeyword("_METALLICSPECGLOSSMAP"); } } } // Specular else { hasGlossMap = specGlossMapProp.textureValue != null; smoothnessChannelNames = Styles.specularSmoothnessChannelNames; EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Specular Map"), specGlossMapProp, hasGlossMap ? null : specColorProp); if (EditorGUI.EndChangeCheck()) { if (specGlossMapProp.textureValue != null) { material.EnableKeyword("_METALLICSPECGLOSSMAP"); } else { material.DisableKeyword("_METALLICSPECGLOSSMAP"); } } } // Smoothness EditorGUI.indentLevel++; EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = smoothnessProp.hasMixedValue; var smoothness = EditorGUILayout.Slider("Smoothness", smoothnessProp.floatValue, 0f, 1f); if (EditorGUI.EndChangeCheck()) { smoothnessProp.floatValue = smoothness; } EditorGUI.showMixedValue = false; EditorGUI.indentLevel--; // Chose Smoothness Cannel in case we have any GlossMap //if (hasGlossMap) { EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(surface != SurfaceType.Opaque); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = smoothnessMapChannelProp.hasMixedValue; var smoothnessSource = (int)smoothnessMapChannelProp.floatValue; // This is correct, but it does not allow fading if (surface == SurfaceType.Opaque && !alphaclip) { smoothnessSource = EditorGUILayout.Popup(new GUIContent("Source"), smoothnessSource, smoothnessChannelNames); } else { GUI.enabled = false; EditorGUILayout.Popup(new GUIContent("Source"), 0, smoothnessChannelNames); material.DisableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); GUI.enabled = true; } // Make sure we set the proper keyword even if only alphaclip has changed as well if (EditorGUI.EndChangeCheck() || alphaclipChanged) { smoothnessMapChannelProp.floatValue = smoothnessSource; if (smoothnessSource == 1) { material.EnableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); } else { material.DisableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); } } EditorGUI.showMixedValue = false; EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; //} // We may still sample from Albedo alpha /* else { * // We can not sample smoothness from albedo alpha of the shader is transparent * if (surface == SurfaceType.Opaque && !alphaclip) { * EditorGUI.indentLevel++; * EditorGUI.BeginChangeCheck(); * var smoothnessFromAlbedoAlpha = EditorGUILayout.Toggle(new GUIContent("Source Albedo Alpha"), smoothnessMapChannelProp.floatValue == 1); * if (EditorGUI.EndChangeCheck()) { * if (smoothnessFromAlbedoAlpha) { * smoothnessMapChannelProp.floatValue = 1; * material.EnableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); * } * else { * smoothnessMapChannelProp.floatValue = 0; * material.DisableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); * } * } * EditorGUI.indentLevel--; * } * else { * smoothnessMapChannelProp.floatValue = 0; * material.DisableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); * } * } */ EditorGUI.indentLevel--; // Normal // NOTE: _NORMALMAP is needed by Bent normal as well: see sh lighting. EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map"), bumpMapProp, bumpMapScaleProp); if (EditorGUI.EndChangeCheck() || bumpMapProp.textureValue == null) { if (bumpMapProp.textureValue != null && bumpMapScaleProp.floatValue != 0.0f) { material.EnableKeyword("_NORMALMAP"); material.EnableKeyword("_SAMPLENORMAL"); enableNormalProp.floatValue = 1.0f; } else { if (BentNormalMapProp.textureValue == null) { material.DisableKeyword("_NORMALMAP"); } material.DisableKeyword("_SAMPLENORMAL"); enableNormalProp.floatValue = 0.0f; } } // Occlusion EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent("Occlusion Map"), occlusionMapProp, occlusionMapProp.textureValue != null ? occlusionStrengthProp : null); if (EditorGUI.EndChangeCheck()) { if (occlusionMapProp.textureValue != null && occlusionStrengthProp.floatValue > 0) { material.EnableKeyword("_OCCLUSIONMAP"); enableOcclusionProp.floatValue = 1; } else { material.DisableKeyword("_OCCLUSIONMAP"); enableOcclusionProp.floatValue = 0; } } // Emission EditorGUI.BeginChangeCheck(); var emission = EditorGUILayout.Toggle(new GUIContent("Emission"), (emissionProp.floatValue == 1)? true : false); if (EditorGUI.EndChangeCheck()) { if (emission) { material.EnableKeyword("_EMISSION"); emissionProp.floatValue = 1; } else { material.DisableKeyword("_EMISSION"); emissionProp.floatValue = 0; } } if (emission) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertyWithHDRColor(new GUIContent("Emission Map"), emissionMapProp, emissionColorProp, false); if (EditorGUI.EndChangeCheck()) { var brightness = emissionColorProp.colorValue.maxColorComponent; material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive; if (brightness <= 0f) { material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack; } } } // Tiling EditorGUILayout.Space(); materialEditor.TextureScaleOffsetProperty(baseMapProp); // Spacing EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); // ----------------------- // Advanced Surface Inputs GUIContent labeltooltip; openAdvancedSurfaceInputs = (advancedSurfaceInputsProps.floatValue == 1.0f) ? true : false; EditorGUI.BeginChangeCheck(); openAdvancedSurfaceInputs = EditorGUILayout.BeginFoldoutHeaderGroup(openAdvancedSurfaceInputs, "Advanced Surface Inputs"); if (EditorGUI.EndChangeCheck()) { advancedSurfaceInputsProps.floatValue = openAdvancedSurfaceInputs? 1.0f : 0.0f; } if (openAdvancedSurfaceInputs) { EditorGUILayout.Space(); // Parallax EditorGUI.BeginChangeCheck(); labeltooltip = new GUIContent("Height Map (G)", "RGB texture which stores height in the green color channel used by parallax extrusion."); materialEditor.TexturePropertySingleLine(new GUIContent("Height Map (G)"), heightMapProp, heightMapProp.textureValue != null ? parallaxProp : null); if (EditorGUI.EndChangeCheck()) { if ((heightMapProp.textureValue != null) && (parallaxProp.floatValue > 0)) { material.EnableKeyword("_PARALLAX"); enableParallaxProp.floatValue = 1; } else { material.DisableKeyword("_PARALLAX"); enableParallaxProp.floatValue = 0; } } if (alphaclip && (heightMapProp.textureValue != null) && (parallaxProp.floatValue > 0)) { EditorGUI.BeginChangeCheck(); labeltooltip = new GUIContent("Parallax Shadows", "If checked the shader will apply parallax mapping even in the shadow caster pass. This is somehow correct for directional shadows where we can derive the view direction from the (shadow) camera’s forward vector but not in case we render spot lights. Furthermore even parallax directional shadow casters are quite unstable if you rotate the camera. So check if you really need this..."); var pShadows = EditorGUILayout.Toggle(labeltooltip, enableParallaxShadowsProp.floatValue == 1); if (EditorGUI.EndChangeCheck() || surfaceModeChanged) { if (pShadows) { enableParallaxShadowsProp.floatValue = 1; material.EnableKeyword("_PARALLAXSHADOWS"); } else { enableParallaxShadowsProp.floatValue = 0; material.DisableKeyword("_PARALLAXSHADOWS"); } } EditorGUILayout.Space(); } else { enableParallaxShadowsProp.floatValue = 0; material.DisableKeyword("_PARALLAXSHADOWS"); } // Bent Normals EditorGUI.BeginChangeCheck(); labeltooltip = new GUIContent("Bent Normal Map", "Cosine weighted Bent Normal Map in tangent space. If assigned the shader will tweak ambient diffuse lighting and ambient specular reflections."); materialEditor.TexturePropertySingleLine(labeltooltip, BentNormalMapProp); if (EditorGUI.EndChangeCheck()) { if (BentNormalMapProp.textureValue != null) { EnableBentNormalProp.floatValue = 1; material.EnableKeyword("_BENTNORMAL"); material.EnableKeyword("_NORMALMAP"); } else { EnableBentNormalProp.floatValue = 0; material.DisableKeyword("_BENTNORMAL"); if (bumpMapProp.textureValue == null) { material.DisableKeyword("_NORMALMAP"); } } } // Horizon Occlusion labeltooltip = new GUIContent("Horizon Occlusion", "Terminates light leaking caused by normal mapped ambient specular reflections where the reflection vector might end up pointing behind the surface being rendered."); materialEditor.ShaderProperty(HorizonOcclusionProp, labeltooltip, 0); // Specular AA EditorGUI.BeginChangeCheck(); labeltooltip = new GUIContent("Geometric Specular AA", "When enabled the shader reduces specular aliasing on high density meshes by reducing smoothness at grazing angles."); var specAA = EditorGUILayout.Toggle(labeltooltip, GeometricSpecularAAProp.floatValue == 1); if (EditorGUI.EndChangeCheck()) { if (specAA) { GeometricSpecularAAProp.floatValue = 1; material.EnableKeyword("_ENABLE_GEOMETRIC_SPECULAR_AA"); } else { GeometricSpecularAAProp.floatValue = 0; material.DisableKeyword("_ENABLE_GEOMETRIC_SPECULAR_AA"); } } if (specAA) { labeltooltip = new GUIContent("Screen Space Variance", "Controls the amount of Specular AA. Higher values give a more blurry result."); materialEditor.ShaderProperty(ScreenSpaceVarianceProp, labeltooltip, 1); labeltooltip = new GUIContent("Threshold", "Controls the amount of Specular AA. Higher values allow higher reduction."); materialEditor.ShaderProperty(SAAThresholdProp, labeltooltip, 1); } // GI TO AO EditorGUI.BeginChangeCheck(); labeltooltip = new GUIContent("GI to Specular Occlusion", "In case you use lightmaps you may activate this feature to derive some kind of specular occlusion just from the lightmap and its baked ambient occlusion."); var GIAO = EditorGUILayout.Toggle(labeltooltip, AOfromGIProp.floatValue == 1); if (EditorGUI.EndChangeCheck()) { if (GIAO) { AOfromGIProp.floatValue = 1; material.EnableKeyword("_ENABLE_AO_FROM_GI"); } else { AOfromGIProp.floatValue = 0; material.DisableKeyword("_ENABLE_AO_FROM_GI"); } } if (GIAO) { labeltooltip = new GUIContent("GI to AO Factor", "Controls the amount of specular occlusion. It acts as a factor to brighten the value sampled from the lightmap."); materialEditor.ShaderProperty(GItoAOProp, labeltooltip, 1); labeltooltip = new GUIContent("Bias", "Adds a constant value to brighten the value sampled from the lightmap."); materialEditor.ShaderProperty(GItoAOBiasProp, labeltooltip, 1); } // Spacing EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); // ----------------------- // Rim Lighting openRimLighingInputs = (RimLighingInputsProps.floatValue == 1.0f) ? true : false; EditorGUI.BeginChangeCheck(); openRimLighingInputs = EditorGUILayout.BeginFoldoutHeaderGroup(openRimLighingInputs, "Rim Lighting"); if (EditorGUI.EndChangeCheck()) { RimLighingInputsProps.floatValue = openRimLighingInputs? 1.0f : 0.0f; } if (openRimLighingInputs) { // Rim EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(RimProp, "Enable Rim Lighting", 0); materialEditor.ShaderProperty(RimColorProp, "Rim Color", 0); materialEditor.ShaderProperty(RimPowerProp, "Rim Power", 0); materialEditor.ShaderProperty(RimFrequencyProp, "Rim Frequency", 0); materialEditor.ShaderProperty(RimMinPowerProp, "Rim Min Power", 1); materialEditor.ShaderProperty(RimPerPositionFrequencyProp, "Rim Per Position Frequency", 1); if (EditorGUI.EndChangeCheck()) { if (RimProp.floatValue == 1) { material.EnableKeyword("_RIMLIGHTING"); } else { material.DisableKeyword("_RIMLIGHTING"); } } EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); // ----------------------- // Stencil Inputs openStencilOptions = (stencilOptionsProps.floatValue == 1.0f) ? true : false; EditorGUI.BeginChangeCheck(); openStencilOptions = EditorGUILayout.BeginFoldoutHeaderGroup(openStencilOptions, "Stencil Options"); if (EditorGUI.EndChangeCheck()) { stencilOptionsProps.floatValue = openStencilOptions? 1.0f : 0.0f; } if (openStencilOptions) { // Stencil materialEditor.ShaderProperty(stencilProp, "Stencil Reference", 0); materialEditor.ShaderProperty(readMaskProp, "Read Mask", 0); materialEditor.ShaderProperty(writeMaskProp, "Write Mask", 0); materialEditor.ShaderProperty(stencilCompProp, "Stencil Comparison", 0); materialEditor.ShaderProperty(stencilOpProp, "Stencil Operation", 0); materialEditor.ShaderProperty(stencilFailProp, "Stencil Fail Op", 0); materialEditor.ShaderProperty(stenciZfailProp, "Stencil ZFail Op", 0); EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); // ----------------------- // Advanced Settings openAdvancedOptions = (advancedOptionsProps.floatValue == 1.0f) ? true : false; EditorGUI.BeginChangeCheck(); openAdvancedOptions = EditorGUILayout.BeginFoldoutHeaderGroup(openAdvancedOptions, "Advanced"); if (EditorGUI.EndChangeCheck()) { advancedOptionsProps.floatValue = openAdvancedOptions? 1.0f : 0.0f; } if (openAdvancedOptions) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(SpecularHighlightsProps, "Specular Highlights", 0); materialEditor.ShaderProperty(EnvironmentReflectionsProps, "Environment Reflections", 0); materialEditor.EnableInstancingField(); materialEditor.RenderQueueField(); if (EditorGUI.EndChangeCheck()) { if (SpecularHighlightsProps.floatValue == 1) { material.DisableKeyword("_SPECULARHIGHLIGHTS_OFF"); } else { material.EnableKeyword("_SPECULARHIGHLIGHTS_OFF"); } if (EnvironmentReflectionsProps.floatValue == 1) { material.DisableKeyword("_ENVIRONMENTREFLECTIONS_OFF"); } else { material.EnableKeyword("_ENVIRONMENTREFLECTIONS_OFF"); } } EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); // Fix all the missing stuff // Needed to make the Selection Outline work // Lightmapper needs it for alpha testing?! if (material.HasProperty("_MainTex") && material.HasProperty("_BaseMap")) { if (material.GetTexture("_BaseMap") != null) { material.SetTexture("_MainTex", material.GetTexture("_BaseMap")); } } }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); // albedo materialEditor.TexturePropertySingleLine(_albedoText, _mainTex, _color); // metallic / smoothness if (_metallicGlossMap.textureValue == null) materialEditor.TexturePropertyTwoLines(_metallicText, _metallicGlossMap, _metallic, _smoothnessText, _glossiness); else materialEditor.TexturePropertySingleLine(_metallicText, _metallicGlossMap); // normal map materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null); // occlusion materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue != null ? _occlusionStrength : null); // emission bool hadEmissionTexture = _emissionMap.textureValue != null; materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, _colorPickerHDRConfig, false); // if texture was assigned and color was black set color to white if (_emissionMap.textureValue != null && !hadEmissionTexture) if (_emissionColor.colorValue.maxColorComponent <= 0) _emissionColor.colorValue = Color.white; return EditorGUI.EndChangeCheck(); }
void DoEmissionArea(Material material) { bool emissionEnabled = false; // Emission for GI? if (m_MaterialEditor.EmissionEnabledProperty()) { emissionEnabled = true; bool hadEmissionTexture = emissionMap0.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText0, emissionMap0, emissionColorForRendering0, false); // If texture was assigned and color was black set color to white float brightness = emissionColorForRendering0.colorValue.maxColorComponent; if (emissionMap0.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering0.colorValue = Color.white; } emissionEnabled = true; hadEmissionTexture = emissionMap1.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText1, emissionMap1, emissionColorForRendering1, false); // If texture was assigned and color was black set color to white brightness = emissionColorForRendering1.colorValue.maxColorComponent; if (emissionMap1.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering1.colorValue = Color.white; } emissionEnabled = true; hadEmissionTexture = emissionMap2.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText2, emissionMap2, emissionColorForRendering2, false); // If texture was assigned and color was black set color to white brightness = emissionColorForRendering2.colorValue.maxColorComponent; if (emissionMap2.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering2.colorValue = Color.white; } emissionEnabled = true; hadEmissionTexture = emissionMap3.textureValue != null; // Texture and HDR color controls m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText3, emissionMap3, emissionColorForRendering3, false); // If texture was assigned and color was black set color to white brightness = emissionColorForRendering3.colorValue.maxColorComponent; if (emissionMap3.textureValue != null && !hadEmissionTexture && brightness <= 0f) { emissionColorForRendering3.colorValue = Color.white; } } if (emissionEnabled) { // change the GI flag and fix it up with emissive as black if necessary m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true); } }