public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { mainTexture = FindProperty("_MainTex", properties); ambientColor = FindProperty("_AmbColor", properties); diffuseRate = FindProperty("_DiffuseRate", properties); specularRate = FindProperty("_SpecularRate", properties); rimThickness = FindProperty("_RimThick", properties); rimColor = FindProperty("_RimColor", properties); stencilMask = FindProperty("_Mask", properties); stencilCompareMode = FindProperty("_CompareMode", properties); EditorGUIUtility.labelWidth = 0f; EditorGUI.BeginChangeCheck(); { } EditorGUI.EndChangeCheck(); materialEditor.TexturePropertySingleLine(new GUIContent(mainTexture.displayName, "Main Color Texture (RGB)"), mainTexture); materialEditor.ColorProperty(ambientColor, ambientColor.displayName); materialEditor.RangeProperty(diffuseRate, diffuseRate.displayName); materialEditor.RangeProperty(specularRate, specularRate.displayName); materialEditor.RangeProperty(rimThickness, rimThickness.displayName); materialEditor.ColorProperty(rimColor, rimColor.displayName); materialEditor.FloatProperty(stencilMask, stencilMask.displayName); int currentCompareMode = (int)stencilCompareMode.floatValue; int newCompareMode = EditorGUILayout.Popup(stencilCompareMode.displayName, currentCompareMode, Enum.GetNames(typeof(UnityEngine.Rendering.CompareFunction))); if (currentCompareMode != newCompareMode) { stencilCompareMode.floatValue = (float)newCompareMode; } materialEditor.RenderQueueField(); }
private void DrawOutlineProperties(MaterialEditor materialEditor) { materialEditor.ShaderProperty(m_EnableOutlineProp, Styles.EnableOutline); if (m_EnableOutlineProp.floatValue == 1.0) { materialEditor.ShaderProperty(m_UseSmoothNormalProp, Styles.UseSmoothNormal); materialEditor.ColorProperty(m_OutlineColorProp, "OutlineColor"); EditorGUI.BeginChangeCheck(); var OutlineWidth = EditorGUILayout.Slider(Styles.OutlineWidth, m_OutlineWidthProp.floatValue, 0f, 5f); if (EditorGUI.EndChangeCheck()) { m_OutlineWidthProp.floatValue = OutlineWidth; } } }
private void GlowGUI( MaterialEditor materialEditor, Material[] materials) { if (this.CheckOption( materials, "Enable Glow", "ENABLE_GLOW")) { EditorGUI.indentLevel = 1; materialEditor.TextureProperty(this.glowTex, "Glow Texture"); materialEditor.VectorProperty(this.glowSpeed, "Glow Speed"); materialEditor.ColorProperty(this.glowColor, "Glow Color"); EditorGUI.indentLevel = 0; } }
private void CurvatureControl(MaterialEditor target) { Header("Curvature", "http://wiki.next-gen-sprites.com/doku.php?id=shaders:fx:lava#curvature"); target.TextureProperty(_curvatureMap, "Curvature Map"); target.RangeProperty(_curvatureDepth, "Depth"); target.ColorProperty(_curvatureHighlight, "Highlight Color"); target.RangeProperty(_curvatureGloss, "Gloss"); GUILayout.Space(10f); DrawWideBox(1f); if (!_shaderCompileKeywords.Contains(ShaderFeature.Curvature.GetString())) { EditorGUI.EndDisabledGroup(); } }
private void ColorGUI(MaterialEditor materialEditor, Material[] materials) { materialEditor.TextureProperty(this.splat0, "Layer 0"); materialEditor.TextureProperty(this.splat1, "Layer 1"); materialEditor.TextureProperty(this.control, "Control"); if (this.CheckOption(materials, "Enable Specular", "ENABLE_SEPCULAR")) { EditorGUI.indentLevel = 1; materialEditor.FloatProperty(this.specularPower, "Specular Power"); materialEditor.FloatProperty(this.specularIntensity, "Specular Intensity"); materialEditor.ColorProperty(this.specularColor, "Specular Color"); EditorGUI.indentLevel = 0; } }
private void DrawToonEmissionOptions(Material material, MaterialEditor materialEditor) { this.toonEmissionOptionsFodlout.SetValue(EditorGUILayout.BeginFoldoutHeaderGroup(this.toonEmissionOptionsFodlout.GetValue(), "Toon Emission Options")); if (this.toonEmissionOptionsFodlout.GetValue()) { materialEditor.TexturePropertySingleLine(ToonShaderEditorStatic.EmissionMapText, this.EmissionMap); if (material.IsKeywordEnabled(ToonShaderEditorStatic.TOON_EMISSION_ENABLED)) { EditorGUI.indentLevel += 1; materialEditor.ColorProperty(this.EmissionColor, ToonShaderEditorStatic.EmissionColorText); EditorGUI.indentLevel -= 1; } EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); }
public void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; EditorGUI.BeginChangeCheck(); { ModePopup(); ZwritePopup(); CullPopup(); m_MaterialEditor.ColorProperty(_TintColor, _TintColor.displayName); m_MaterialEditor.TextureProperty(_MainTex, _MainTex.displayName); m_MaterialEditor.FloatProperty(_InvFade, _InvFade.displayName); } if (EditorGUI.EndChangeCheck()) { MaterialChanged(material); } }
private void OnMainGui(MaterialEditor me) { using (new Section("Main")) { GUILayout.Label("Main Color & Texture", EditorStyles.boldLabel); // me.TexturePropertySingleLine(new GUIContent("Main Texture"), _MainTex); // me.TextureScaleOffsetProperty(_MainTex); me.ColorProperty(_Color, "Color"); if (_isTransparent) { me.ShaderProperty(_Alpha, "Alpha"); } me.ShaderProperty(_UseVertexColor, "Use Vertex Color"); } }
void DoXRayArea(Material material) { bool prevToggleState = (xRayColorForRendering.colorValue != Color.black); customXRayColor = EditorGUILayout.Toggle("Custom X-Ray Color", prevToggleState); if (customXRayColor) { if (!prevToggleState) { xRayColorForRendering.colorValue = Color.blue; } m_MaterialEditor.ColorProperty(xRayColorForRendering, Styles.xRayColorText.text); } else if (prevToggleState) { xRayColorForRendering.colorValue = Color.black; } }
public void ShaderPropertiesGUI(Material material) { EditorGUI.BeginChangeCheck(); { BlendModePopup(); if ((BlendMode)blendMode.floatValue == BlendMode.AlphaTest) { m_MaterialEditor.ShaderProperty(cutoff, "透贴强度", 1); } CullModePopup(); m_MaterialEditor.ShaderProperty(isParticle, "是否用于粒子发射器"); EditorGUILayout.Space(); m_MaterialEditor.ColorProperty(color, "颜色"); EditorGUILayout.Space(); DoAlbedoArea(material); GUILayout.Label("-------------------------------------------", EditorStyles.centeredGreyMiniLabel); DoSecondaryAlbedoArea(); GUILayout.Label("-------------------------------------------", EditorStyles.centeredGreyMiniLabel); DoDistortArea(material); GUILayout.Label("-------------------------------------------", EditorStyles.centeredGreyMiniLabel); DoMaskArea(material); GUILayout.Label("-------------------------------------------", EditorStyles.centeredGreyMiniLabel); DoRimArea(material); GUILayout.Label("-------------------------------------------", EditorStyles.centeredGreyMiniLabel); DoDissolveArea(material); } EditorGUILayout.Space(); //m_MaterialEditor.RenderQueueField(); //m_MaterialEditor.EnableInstancingField(); //m_MaterialEditor.DoubleSidedGIField(); }
private void DissolveControl(MaterialEditor target) { Header("Dissolve", "http://wiki.next-gen-sprites.com/doku.php?id=shaders:feature:dissolve"); target.TextureProperty(_dissolveMap, "Dissolve Pattern", scaleOffset: false); target.RangeProperty(_dissolveBlend, "Blend"); GUILayout.Space(5f); target.RangeProperty(_dissolveBorderWidth, "Border Width"); target.ColorProperty(_dissolveGlowColor, "Border Glow Tint"); target.RangeProperty(_dissolveGlowStrength, "Border Glow width"); GUILayout.Space(10f); DrawWideBox(1f); if (!_shaderCompileKeywords.Contains(ShaderFeature.Dissolve.GetString())) { EditorGUI.EndDisabledGroup(); } }
}//PropertyUI public void Head(Material material) { BlendModePopup(); PropertyUI(rQueue, "Render Queue"); material.renderQueue = (int)rQueue.floatValue; NumberOfTexturePopup(); if (numberTexture.floatValue > 0) { BlendTexturePopup(); BlendAlphaPopup(); } GUILayout.Space(7); m_MaterialEditor.ColorProperty(tintColor, "Tint Color (RGBA)"); PropertyUI (bri, "Brightness"); PropertyUI (con, "Contrast"); PropertyUI(softPart, "Soft Particles Factor"); }//Head
private void DrawRimProperties(MaterialEditor materialEditor) { //Rim materialEditor.ColorProperty(m_RimColorProp, Styles.RimColor.text); EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel += 2; var blendRim = EditorGUILayout.Slider(Styles.BlendRim, m_BlendRimProp.floatValue, 0f, 1f); var rimPow = EditorGUILayout.Slider(Styles.RimPow, m_RimPowProp.floatValue, 0f, 10f); var rimStep = EditorGUILayout.Slider(Styles.RimStep, m_RimStepProp.floatValue, 0f, 1f); var rimFeather = EditorGUILayout.Slider(Styles.RimFeather, m_RimFeatherProp.floatValue, 0f, 1f); EditorGUI.indentLevel -= 2; if (EditorGUI.EndChangeCheck()) { m_BlendRimProp.floatValue = blendRim; m_RimPowProp.floatValue = rimPow; m_RimStepProp.floatValue = rimStep; m_RimFeatherProp.floatValue = rimFeather; } }
private void DrawToonSpecularOptions(Material material, MaterialEditor materialEditor) { this.toonSpecularOptionsFoldout.SetValue(EditorGUILayout.BeginFoldoutHeaderGroup(this.toonSpecularOptionsFoldout.GetValue(), "Toon Specular Options")); if (this.toonSpecularOptionsFoldout.GetValue()) { materialEditor.TexturePropertySingleLine(ToonShaderEditorStatic.SpecularRampText, this.SpecularRamp); if (material.IsKeywordEnabled(ToonShaderEditorStatic.TOON_SPECULAR_ENABLED)) { EditorGUI.indentLevel += 1; materialEditor.TexturePropertySingleLine(ToonShaderEditorStatic.SpecularMapText, this.SpecularMap); materialEditor.FloatProperty(this.SpecularPower, ToonShaderEditorStatic.SpecularPowerText); materialEditor.ColorProperty(this.SpecularColor, ToonShaderEditorStatic.SpecularColorText); EditorGUI.indentLevel -= 1; } EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); }
private void DrawToonRimOptions(Material material, MaterialEditor materialEditor) { this.toonRimOptionsFoldout.SetValue(EditorGUILayout.BeginFoldoutHeaderGroup(this.toonRimOptionsFoldout.GetValue(), "Toon Rim Options")); if (this.toonRimOptionsFoldout.GetValue()) { materialEditor.RangeProperty(this.RimPower, ToonShaderEditorStatic.RimPowerText); if (material.IsKeywordEnabled(ToonShaderEditorStatic.RIM_LIGHTNING_ENABLED)) { EditorGUI.indentLevel += 1; materialEditor.FloatProperty(this.RimOffset, ToonShaderEditorStatic.RomOffsetText); materialEditor.TexturePropertySingleLine(ToonShaderEditorStatic.RimMapText, this.RimMap); materialEditor.ColorProperty(this.RimColor, ToonShaderEditorStatic.RimColorText); EditorGUI.indentLevel -= 1; } EditorGUILayout.Space(); } EditorGUILayout.EndFoldoutHeaderGroup(); }
private void DrawProperty(MaterialProperty prop) { string propName = prop.displayName; switch (prop.type) { case MaterialProperty.PropType.Color: { materialEditor.ColorProperty(prop, propName); break; } case MaterialProperty.PropType.Float: { materialEditor.FloatProperty(prop, propName); break; } case MaterialProperty.PropType.Range: { materialEditor.RangeProperty(prop, propName); break; } case MaterialProperty.PropType.Texture: { materialEditor.TexturePropertySingleLine(new GUIContent(propName), prop); if (!prop.flags.HasFlag((System.Enum)MaterialProperty.PropFlags.NoScaleOffset)) { materialEditor.TextureScaleOffsetProperty(prop); } break; } case MaterialProperty.PropType.Vector: { materialEditor.VectorProperty(prop, propName); break; } } }
void DrawRimProperties(MaterialEditor materialEditor) { //Rim materialEditor.ShaderProperty(m_EnableRimProp, GUIContents.EnableRim); if (m_EnableRimProp.floatValue == 1.0) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel += 2; materialEditor.ShaderProperty(m_BlendRimProp, GUIContents.BlendRim); materialEditor.ColorProperty(m_RimColorProp, GUIContents.RimColor.text); var rimPow = EditorGUILayout.Slider(GUIContents.RimPow, m_RimPowProp.floatValue, 0f, 10f); var rimStep = EditorGUILayout.Slider(GUIContents.RimStep, m_RimStepProp.floatValue, 0f, 1f); var rimFeather = EditorGUILayout.Slider(GUIContents.RimFeather, m_RimFeatherProp.floatValue, 0f, 1f); EditorGUI.indentLevel -= 2; if (EditorGUI.EndChangeCheck()) { m_RimPowProp.floatValue = rimPow; m_RimStepProp.floatValue = rimStep; m_RimFeatherProp.floatValue = rimFeather; } } }
public void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; EditorGUI.BeginChangeCheck(); { GUILayout.Space(8f); //Background Rect vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; //GUILayout.Space(4f); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.mainTexText, mainTex); m_MaterialEditor.TextureScaleOffsetProperty(mainTex); GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(lockRotation, Styles.lockRotationText.text, 0); if (material.GetFloat("_LockRotation") == 1) { m_MaterialEditor.ShaderProperty(lockAxis, Styles.lockAxisText.text, 1); } GUILayout.Space(9f); m_MaterialEditor.ColorProperty(color, Styles.colorText.text); m_MaterialEditor.ShaderProperty(cutoff, Styles.cutoffText.text, 0); m_MaterialEditor.ShaderProperty(scaleX, Styles.scaleXText.text, 0); m_MaterialEditor.ShaderProperty(scaleY, Styles.scaleYText.text, 0); // EditorGUILayout.EndVertical(); } }
void guiForRedChannel() { showRedChannel = targetMat.GetFloat("_showRed") == 1; showRedChannel = EditorGUILayout.Foldout(showRedChannel, "Red Channel Settings"); targetMat.SetFloat("_showRed", showRedChannel ? 1f : 0f); if (!showRedChannel) { return; } matEditor.TextureProperty(getProperty("_MainTex"), "Albedo Map"); //getProperty ("_MainTex").textureScaleAndOffset; matEditor.RangeProperty(getProperty("_Metallic"), "Metallic Strength"); matEditor.TextureProperty(getProperty("_BumpMap"), "Bump Map"); matEditor.TextureProperty(getProperty("_CombinedMap"), "Combined Map"); matEditor.RangeProperty(getProperty("_Smoothness"), "Smoothness Strength"); matEditor.RangeProperty(getProperty("_Occlusion"), "Occlusion Strength Strength"); matEditor.RangeProperty(getProperty("_Emission"), "Emission Strength"); matEditor.ColorProperty(getProperty("_EmissionColor"), "Emission Color"); if (useParallax) { matEditor.RangeProperty(getProperty("_Parallax"), "Parallax Strength"); } showWetnessRed = EditorGUILayout.Foldout(showWetnessRed, "Wetness Settings"); if (showWetnessRed) { matEditor.ColorProperty(getProperty("_wetnessAlbedoModifier"), "Albedo Modifier"); matEditor.RangeProperty(getProperty("_wetnessSmoothnessModifier"), "Smoothness Modifier"); matEditor.RangeProperty(getProperty("_wetnessNormalModifier"), "Normal Modifier"); } }
void guiForRedChannel() { showRedChannel = targetMat.GetFloat("_showRed") == 1; showRedChannel = EditorGUILayout.Foldout(showRedChannel, "Red Channel Settings"); targetMat.SetFloat("_showRed", showRedChannel ? 1f : 0f); if (!showRedChannel) { return; } matEditor.TexturePropertySingleLine(new GUIContent("Albedo Map"), getProperty("_MainTex"), getProperty("_TilingU"), getProperty("_TilingV")); matEditor.ColorProperty(getProperty("_AlbedoColor"), "Albedo Color"); matEditor.RangeProperty(getProperty("_Metallic"), "Metallic Strength"); matEditor.TexturePropertySingleLine(new GUIContent("Normal Map"), getProperty("_BumpMap"), getProperty("_NormalScale")); matEditor.TexturePropertySingleLine(new GUIContent("Combined Map"), getProperty("_CombinedMap")); matEditor.RangeProperty(getProperty("_TesselationStrength"), "Tesselation Strength"); matEditor.RangeProperty(getProperty("_Smoothness"), "Smoothness Strength"); matEditor.RangeProperty(getProperty("_Occlusion"), "Occlusion Strength Strength"); //matEditor.RangeProperty ( getProperty ("_Emission"), "Emission Strength"); matEditor.ColorProperty(getProperty("_EmissionColor"), "Emission Color"); showDetailRed = EditorGUILayout.Foldout(showDetailRed, "Detail Maps"); if (showDetailRed) { matEditor.TexturePropertySingleLine(new GUIContent("Detail Mask"), getProperty("_DetailMask")); matEditor.TexturePropertySingleLine(new GUIContent("Detail Albedo"), getProperty("_DetailTex"), getProperty("_DetailScaleU"), getProperty("_DetailScaleV")); matEditor.TexturePropertySingleLine(new GUIContent("Detail Normal"), getProperty("_DetailBumpMap"), getProperty("_DetailNormalScale")); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); GUILayout.Space(8f); //Background Rect vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", (GUIStyle)"RL Background"); GUILayout.Space(4f); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoReflectionArea(material); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); //m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, // heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); //m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; } // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake EditorGUILayout.Space(); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } GUILayout.Space(8f); //---------------------------------------------------------------- // additional properties GUILayout.Label("Base Properties", EditorStyles.boldLabel); m_MaterialEditor.ColorProperty(tcp2_highlightColor, Styles.tcp2_highlightColorText); m_MaterialEditor.ColorProperty(tcp2_shadowColor, Styles.tcp2_shadowColorText); // Wrapped Lighting m_MaterialEditor.ShaderProperty(tcp2_TCP2_DISABLE_WRAPPED_LIGHT, "Disable Wrapped Lighting"); // Ramp Texture / Threshold m_MaterialEditor.ShaderProperty(tcp2_TCP2_RAMPTEXT, "Use Ramp Texture"); if (tcp2_TCP2_RAMPTEXT.floatValue > 0) { EditorGUI.indentLevel++; m_MaterialEditor.ShaderProperty(tcp2_ramp, Styles.tcp2_rampText); //m_MaterialEditor.TexturePropertySingleLine(Styles.tcp2_rampText, tcp2_ramp); EditorGUI.indentLevel--; } else { m_MaterialEditor.ShaderProperty(tcp2_rampThreshold, Styles.tcp2_rampThresholdText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rampSmooth, Styles.tcp2_rampSmoothText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rampSmoothAdd, Styles.tcp2_rampSmoothAddText.text, 1); } // Stylized Specular m_MaterialEditor.ShaderProperty(tcp2_SPEC_TOON, "Stylized Specular"); if (tcp2_SPEC_TOON.floatValue > 0) { m_MaterialEditor.ShaderProperty(tcp2_specSmooth, Styles.tcp2_specSmoothText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_SpecBlend, Styles.tcp2_SpecBlendText.text, 1); EditorGUILayout.Space(); } //Stylized Fresnel m_MaterialEditor.ShaderProperty(rim, "Rim"); if (rim.floatValue > 0) { m_MaterialEditor.ShaderProperty(rimColor, Styles.rimColorText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rimStrength, Styles.tcp2_rimStrengthText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rimMin, Styles.tcp2_rimMinText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rimMax, Styles.tcp2_rimMaxText.text, 1); m_MaterialEditor.ShaderProperty(rimOffset, Styles.rimOffsetText.text, 1); if (rimOffset.floatValue > 0) { m_MaterialEditor.ShaderProperty(rimOffsetX, Styles.rimOffsetXText.text, 1); m_MaterialEditor.ShaderProperty(rimOffsetY, Styles.rimOffsetYText.text, 1); m_MaterialEditor.ShaderProperty(rimOffsetZ, Styles.rimOffsetZText.text, 1); } EditorGUILayout.Space(); } // Real Fresnel m_MaterialEditor.ShaderProperty(realFresnel, Styles.realFresnelText.text, 0); if (realFresnel.floatValue > 0 && (BlendMode)material.GetFloat("_Mode") == BlendMode.Fade || realFresnel.floatValue > 0 && (BlendMode)material.GetFloat("_Mode") == BlendMode.Transparent) { m_MaterialEditor.ShaderProperty(thickness, Styles.thicknessText.text, 1); m_MaterialEditor.ShaderProperty(gradient, Styles.gradientText.text, 1); } // layer system GUILayout.Label("Mask", EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.maskTexText, maskTex); GUILayout.Label("Layers", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(uv2, Styles.uv2Text.text, 0); m_MaterialEditor.ShaderProperty(uv3, Styles.uv3Text.text, 0); // layerBase m_MaterialEditor.TexturePropertySingleLine(Styles.layerBaseTexText, layerBaseTex); m_MaterialEditor.TexturePropertySingleLine(Styles.layerBaseNormalText, layerBaseNormal, layerBaseNormalScale); if (material.GetTexture("_LayerBaseTex")) { m_MaterialEditor.TextureScaleOffsetProperty(layerBaseTex); m_MaterialEditor.ShaderProperty(layerBaseColor, Styles.layerBaseColorText.text, 2); m_MaterialEditor.ShaderProperty(layerBaseSmoothness, Styles.layerBaseSmoothnessText.text, 2); m_MaterialEditor.ShaderProperty(layerBaseMetallic, Styles.layerBaseMetallicText.text, 2); m_MaterialEditor.ShaderProperty(layerBaseUVSet, Styles.layerBaseUVSetText.text, 2); m_MaterialEditor.ShaderProperty(layerBaseBlendMode, Styles.layerBaseBlendModeText.text, 2); if (material.GetTexture("_MaskTex")) { GUILayout.Label(" LayerBaseMask: MaskTex(R)"); } } else if (material.GetTexture("_LayerBaseNormal")) { m_MaterialEditor.TextureScaleOffsetProperty(layerBaseTex); m_MaterialEditor.ShaderProperty(layerBaseUVSet, Styles.layerBaseUVSetText.text, 2); if (material.GetTexture("_MaskTex")) { GUILayout.Label(" LayerBaseMask: MaskTex(R)"); } } //m_MaterialEditor.ShaderProperty(realFresnel, Styles.multiTranspText.text, 0); //GUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); GUILayout.Space(8f); expandStandardProperties = GUILayout.Toggle(expandStandardProperties, "STANDARD PROPERTIES", EditorStyles.toolbarButton); if (expandStandardProperties) { //Background Rect vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", (GUIStyle)"RL Background"); GUILayout.Space(4f); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; } // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); if (highlights != null) { m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); } if (reflections != null) { m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } GUILayout.Space(8f); EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); //---------------------------------------------------------------- // TOONY COLORS PRO 2 bool useOutline = (m_MaterialEditor.target as Material).shaderKeywords.Contains("OUTLINES"); bool useOutlineBlended = (m_MaterialEditor.target as Material).shaderKeywords.Contains("OUTLINE_BLENDING"); bool hasOutlineShader = tcp2_outlineWidth != null; bool hasOutlineBlendedShader = tcp2_srcBlendOutline != null; bool useOutlineNew = useOutline; bool useOutlineBlendedNew = useOutlineBlended; expandTCP2Properties = GUILayout.Toggle(expandTCP2Properties, "TOONY COLORS PRO 2", EditorStyles.toolbarButton); if (expandTCP2Properties) { //Background Rect vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", (GUIStyle)"RL Background"); GUILayout.Space(4f); GUILayout.Label("Base Properties", EditorStyles.boldLabel); m_MaterialEditor.ColorProperty(tcp2_highlightColor, Styles.tcp2_highlightColorText); m_MaterialEditor.ColorProperty(tcp2_shadowColor, Styles.tcp2_shadowColorText); // Wrapped Lighting m_MaterialEditor.ShaderProperty(tcp2_TCP2_DISABLE_WRAPPED_LIGHT, "Disable Wrapped Lighting"); // Ramp Texture / Threshold m_MaterialEditor.ShaderProperty(tcp2_TCP2_RAMPTEXT, "Use Ramp Texture"); if (tcp2_TCP2_RAMPTEXT.floatValue > 0) { EditorGUI.indentLevel++; m_MaterialEditor.ShaderProperty(tcp2_ramp, Styles.tcp2_rampText); //m_MaterialEditor.TexturePropertySingleLine(Styles.tcp2_rampText, tcp2_ramp); EditorGUI.indentLevel--; } else { m_MaterialEditor.ShaderProperty(tcp2_rampThreshold, Styles.tcp2_rampThresholdText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rampSmooth, Styles.tcp2_rampSmoothText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rampSmoothAdd, Styles.tcp2_rampSmoothAddText.text, 1); } EditorGUILayout.Space(); GUILayout.Label("Stylization Options", EditorStyles.boldLabel); // Stylized Specular m_MaterialEditor.ShaderProperty(tcp2_SPEC_TOON, "Stylized Specular"); if (tcp2_SPEC_TOON.floatValue > 0) { m_MaterialEditor.ShaderProperty(tcp2_specSmooth, Styles.tcp2_specSmoothText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_SpecBlend, Styles.tcp2_SpecBlendText.text, 1); EditorGUILayout.Space(); } //Stylized Fresnel m_MaterialEditor.ShaderProperty(tcp2_STYLIZED_FRESNEL, "Stylized Fresnel"); if (tcp2_STYLIZED_FRESNEL.floatValue > 0) { m_MaterialEditor.ShaderProperty(tcp2_rimStrength, Styles.tcp2_rimStrengthText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rimMin, Styles.tcp2_rimMinText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_rimMax, Styles.tcp2_rimMaxText.text, 1); EditorGUILayout.Space(); } //Outline useOutlineNew = EditorGUILayout.Toggle(new GUIContent("Outline", "Enable mesh-based outline"), useOutline); if (useOutline && hasOutlineShader) { //Outline base props m_MaterialEditor.ShaderProperty(tcp2_outlineColor, Styles.tcp2_outlineColorText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_outlineWidth, Styles.tcp2_outlineWidthText.text, 1); m_MaterialEditor.ShaderProperty(tcp2_TCP2_OUTLINE_TEXTURED, "Textured Outline", 1); if (tcp2_TCP2_OUTLINE_TEXTURED.floatValue > 0) { m_MaterialEditor.ShaderProperty(tcp2_TexLod, Styles.tcp2_TexLodText, 1); } m_MaterialEditor.ShaderProperty(tcp2_TCP2_OUTLINE_CONST_SIZE, "Constant Screen Size", 1); m_MaterialEditor.ShaderProperty(tcp2_TCP2_ZSMOOTH_ON, "Z Smooth", 1); if (tcp2_TCP2_ZSMOOTH_ON.floatValue > 0) { m_MaterialEditor.ShaderProperty(tcp2_ZSmooth, Styles.tcp2_ZSmoothText, 2); m_MaterialEditor.ShaderProperty(tcp2_Offset1, Styles.tcp2_Offset1Text, 2); m_MaterialEditor.ShaderProperty(tcp2_Offset2, Styles.tcp2_Offset2Text, 2); } //Blended Outline EditorGUI.indentLevel++; useOutlineBlendedNew = EditorGUILayout.Toggle(new GUIContent("Blended Outline", "Enable blended outline rather than opaque"), useOutlineBlended); if (useOutlineBlended && hasOutlineBlendedShader) { EditorGUI.indentLevel++; UnityEngine.Rendering.BlendMode blendSrc = (UnityEngine.Rendering.BlendMode)tcp2_srcBlendOutline.floatValue; UnityEngine.Rendering.BlendMode blendDst = (UnityEngine.Rendering.BlendMode)tcp2_dstBlendOutline.floatValue; EditorGUI.BeginChangeCheck(); blendSrc = (UnityEngine.Rendering.BlendMode)EditorGUILayout.EnumPopup(Styles.tcp2_srcBlendOutlineText, blendSrc); blendDst = (UnityEngine.Rendering.BlendMode)EditorGUILayout.EnumPopup(Styles.tcp2_dstBlendOutlineText, blendDst); if (EditorGUI.EndChangeCheck()) { tcp2_srcBlendOutline.floatValue = (float)blendSrc; tcp2_dstBlendOutline.floatValue = (float)blendDst; } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; //Outline Normals int onIndex = GetOutlineNormalsIndex(); int newIndex = onIndex; EditorGUI.indentLevel++; if (TCP2_Utils.ScreenWidthRetina < 390f) { newIndex = TCP2_Utils.ShaderKeywordRadioGeneric("Outline Normals", newIndex, new GUIContent[] { new GUIContent("R", "Use regular vertex normals"), new GUIContent("VC", "Use vertex colors as normals (with smoothed mesh)"), new GUIContent("T", "Use tangents as normals (with smoothed mesh)"), new GUIContent("UV2", "Use second texture coordinates as normals (with smoothed mesh)"), }); } else if (TCP2_Utils.ScreenWidthRetina < 560f) { newIndex = TCP2_Utils.ShaderKeywordRadioGeneric("Outline Normals", newIndex, new GUIContent[] { new GUIContent("Regular", "Use regular vertex normals"), new GUIContent("VColors", "Use vertex colors as normals (with smoothed mesh)"), new GUIContent("Tangents", "Use tangents as normals (with smoothed mesh)"), new GUIContent("UV2", "Use second texture coordinates as normals (with smoothed mesh)"), }); } else { newIndex = TCP2_Utils.ShaderKeywordRadioGeneric("Outline Normals", newIndex, new GUIContent[] { new GUIContent("Regular", "Use regular vertex normals"), new GUIContent("Vertex Colors", "Use vertex colors as normals (with smoothed mesh)"), new GUIContent("Tangents", "Use tangents as normals (with smoothed mesh)"), new GUIContent("UV2", "Use second texture coordinates as normals (with smoothed mesh)"), }); } EditorGUI.indentLevel--; if (newIndex != onIndex) { UpdateOutlineNormalsKeyword(newIndex); } } GUILayout.Space(8f); GUILayout.EndVertical(); // TCP2 End //---------------------------------------------------------------- } GUILayout.Space(10f); //TCP2: set correct shader based on outline properties if (useOutline != useOutlineNew || useOutlineBlended != useOutlineBlendedNew) { SetTCP2Shader(useOutlineNew, useOutlineBlendedNew); } else if (useOutline != hasOutlineShader || useOutlineBlended != hasOutlineBlendedShader) { SetTCP2Shader(useOutline, useOutlineBlended); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties) { GUILayout.BeginHorizontal(); GUILayout.Label(Resources.Load <Texture>("TOON_WATER_LOGO"), GUILayout.Width(308), GUILayout.Height(244)); GUILayout.EndHorizontal(); //WATER COLORS colorsFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(colorsFoldout, "Water Colors"); if (colorsFoldout) { MaterialProperty waterDepth = FindProperty(WATER_DEPTH_ID, properties); editor.FloatProperty(waterDepth, "Water Depth"); MaterialProperty shallowColor = FindProperty(SHALLOW_WATER_COLOR_ID, properties); editor.ColorProperty(shallowColor, "Shallow Water Color"); MaterialProperty deepColor = FindProperty(DEEP_WATER_COLOR_ID, properties); editor.ColorProperty(deepColor, "Deep Water Color"); } EditorGUILayout.EndFoldoutHeaderGroup(); //LIGHTNING lightningFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(lightningFoldout, "Light settings"); if (lightningFoldout) { MaterialProperty specularPower = FindProperty(SPECULAR_ID, properties); editor.RangeProperty(specularPower, "Specular Power"); MaterialProperty specularCutoff = FindProperty(SPECULAR_CUTOFF_ID, properties); editor.RangeProperty(specularCutoff, "Specular Cutoff"); MaterialProperty specularEdgesSmoothnessFactor = FindProperty(SPECULAR_EDGES_SMOOTHNESS_FACTOR_ID, properties); editor.RangeProperty(specularEdgesSmoothnessFactor, "Specular Edges Smoothness Factor"); MaterialProperty specularColor = FindProperty(SPECULAR_COLOR_ID, properties); editor.ColorProperty(specularColor, "Specular Color"); MaterialProperty normalsStrenght = FindProperty(NORMALS_STRENGTH_ID, properties); editor.FloatProperty(normalsStrenght, "Normals Strength"); } EditorGUILayout.EndFoldoutHeaderGroup(); //FRESNEL fresnelFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(fresnelFoldout, "Fresnel"); if (fresnelFoldout) { MaterialProperty fresnelPower = FindProperty(FRESNEL_POWER_ID, properties); editor.RangeProperty(fresnelPower, "Fresnel Power"); if (fresnelPower.floatValue <= 0) { EditorGUILayout.HelpBox("When Fresnel Power is set to 0 effect is disabled and Planar Reflections will not be visible!", MessageType.Info); } } EditorGUILayout.EndFoldoutHeaderGroup(); //REFRACTION refractionFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(refractionFoldout, "Refraction"); if (refractionFoldout) { MaterialProperty refractionStrenght = FindProperty(REFRACTION_STRENGTH_ID, properties); editor.RangeProperty(refractionStrenght, "Refraction Strength"); MaterialProperty useRefraction = FindProperty(USE_REFRACTION_IN_DEPTH_BASED_WATER_COLOR, properties); useRefraction.floatValue = EditorGUILayout.Toggle("Use Refraction In Depth Based Water Color", useRefraction.floatValue > 0) ? 1 : 0; } EditorGUILayout.EndFoldoutHeaderGroup(); //REFLECTION reflectionFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(reflectionFoldout, "Planar Reflections"); if (reflectionFoldout) { MaterialProperty reflectionVisiblity = FindProperty(REFLECTION_VISIBILITY_ID, properties); editor.RangeProperty(reflectionVisiblity, "Reflection Visibility"); MaterialProperty reflectionDistortion = FindProperty(REFLECTION_DISTORTION_STRENGHT, properties); editor.RangeProperty(reflectionDistortion, "Reflection Distortion Strenght"); } EditorGUILayout.EndFoldoutHeaderGroup(); //FOAM foamFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(foamFoldout, "Foam"); if (foamFoldout) { MaterialProperty foamColor = FindProperty(FOAM_COLOR_ID, properties); editor.ColorProperty(foamColor, "Foam Color"); MaterialProperty foamAmount = FindProperty(FOAM_AMOUNT_ID, properties); editor.FloatProperty(foamAmount, "Foam Amount"); MaterialProperty foamCutoff = FindProperty(FOAM_CUTOFF_ID, properties); editor.FloatProperty(foamCutoff, "Foam Cutoff"); MaterialProperty foamDirection = FindProperty(FOAM_DIRECTION_ID, properties); editor.VectorProperty(foamDirection, "Foam Direction"); MaterialProperty foamScale = FindProperty(FOAM_SCALE_ID, properties); editor.VectorProperty(foamScale, "Foam Scale"); } EditorGUILayout.EndFoldoutHeaderGroup(); //WAVES wavesFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(wavesFoldout, "Waves"); if (wavesFoldout) { MaterialProperty waveDir = FindProperty(WAVE_DIRECTION_ID, properties); editor.VectorProperty(waveDir, "Wave Direction"); MaterialProperty waveSize = FindProperty(WAVE_SIZE_ID, properties); editor.VectorProperty(waveSize, "Wave Size"); } EditorGUILayout.EndFoldoutHeaderGroup(); }
public override void DrawShaderGUI(MicroSplatShaderGUI shaderGUI, MicroSplatKeywords keywords, Material mat, MaterialEditor materialEditor, MaterialProperty[] props) { if (snow != SnowMode.None && mat.HasProperty("_SnowParams") && MicroSplatUtilities.DrawRollup("Snow")) { var snowDiff = shaderGUI.FindProp("_SnowDiff", props); var snowNorm = shaderGUI.FindProp("_SnowNormal", props); materialEditor.TexturePropertySingleLine(CDiffTex, snowDiff); materialEditor.TexturePropertySingleLine(CNormTex, snowNorm); MicroSplatUtilities.EnforceDefaultTexture(snowDiff, "microsplat_def_snow_diff"); MicroSplatUtilities.EnforceDefaultTexture(snowNorm, "microsplat_def_snow_normsao"); if (mat.HasProperty("_SnowTint")) { materialEditor.ColorProperty(shaderGUI.FindProp("_SnowTint", props), "Snow Tint"); } if (mat.HasProperty("_SnowMask")) { var maskTex = shaderGUI.FindProp("_SnowMask", props); materialEditor.TexturePropertySingleLine(CSnowTex, maskTex); } if (mat.HasProperty("_SnowUVScales")) { Vector4 snowUV = shaderGUI.FindProp("_SnowUVScales", props).vectorValue; EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("UV Scale"); snowUV.x = EditorGUILayout.FloatField(snowUV.x); snowUV.y = EditorGUILayout.FloatField(snowUV.y); EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { shaderGUI.FindProp("_SnowUVScales", props).vectorValue = snowUV; EditorUtility.SetDirty(mat); } } if (mat.HasProperty("_SnowSSSTint")) { var prop = shaderGUI.FindProp("_SnowSSSTint", props); EditorGUI.BeginChangeCheck(); Color c = prop.colorValue; c = EditorGUILayout.ColorField(CSSSTint, c); c.a = EditorGUILayout.Slider(CSSSThickness, c.a, 0, 1); if (EditorGUI.EndChangeCheck()) { prop.colorValue = c; EditorUtility.SetDirty(mat); } } // influence, erosion, crystal, melt Vector4 p1 = shaderGUI.FindProp("_SnowParams", props).vectorValue; Vector4 hr = shaderGUI.FindProp("_SnowHeightAngleRange", props).vectorValue; EditorGUILayout.BeginHorizontal(); bool oldEnabled = GUI.enabled; if (globalLevel) { GUI.enabled = false; } materialEditor.ShaderProperty(shaderGUI.FindProp("_SnowAmount", props), "Amount"); GUI.enabled = oldEnabled; globalLevel = DrawGlobalToggle(GetFeatureName(SnowDefineFeature._USEGLOBALSNOWLEVEL), keywords); EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); if (snow == SnowMode.Rich) { p1.x = EditorGUILayout.Slider(CHeightClear, p1.x, 0, 1); } p1.y = EditorGUILayout.Slider(CErosionClearing, p1.y, 0, 1); EditorGUILayout.BeginHorizontal(); oldEnabled = GUI.enabled; if (globalHeight) { GUI.enabled = false; } EditorGUILayout.PrefixLabel(CHeightRange); hr.x = EditorGUILayout.FloatField(hr.x); hr.y = EditorGUILayout.FloatField(hr.y); GUI.enabled = oldEnabled; globalHeight = DrawGlobalToggle(GetFeatureName(SnowDefineFeature._USEGLOBALSNOWHEIGHT), keywords); EditorGUILayout.EndHorizontal(); hr.z = 1.0f - hr.z; hr.w = 1.0f - hr.w; EditorGUILayout.MinMaxSlider(CAngleRange, ref hr.w, ref hr.z, 0.0f, 1.0f); hr.z = 1.0f - hr.z; hr.w = 1.0f - hr.w; p1.z = EditorGUILayout.FloatField(CCrystals, p1.z); p1.w = EditorGUILayout.Slider(CMelt, p1.w, 0, 0.6f); if (EditorGUI.EndChangeCheck()) { shaderGUI.FindProp("_SnowParams", props).vectorValue = p1; shaderGUI.FindProp("_SnowHeightAngleRange", props).vectorValue = hr; } Vector4 up = mat.GetVector("_SnowUpVector"); EditorGUI.BeginChangeCheck(); Vector3 newUp = EditorGUILayout.Vector3Field(CUpVector, new Vector3(up.x, up.y, up.z)); if (EditorGUI.EndChangeCheck()) { newUp.Normalize(); mat.SetVector("_SnowUpVector", new Vector4(newUp.x, newUp.y, newUp.z, 0)); EditorUtility.SetDirty(mat); } if (snowRim && mat.HasProperty("_SnowRimPower")) { materialEditor.ColorProperty(shaderGUI.FindProp("_SnowRimColor", props), "Rim Light Color"); materialEditor.RangeProperty(shaderGUI.FindProp("_SnowRimPower", props), "Rim Light Power"); } if (snowSparkle && mat.HasProperty("_SnowSparkleNoise")) { var texProp = shaderGUI.FindProp("_SnowSparkleNoise", props); materialEditor.TexturePropertySingleLine(CSparkleNoise, texProp); MicroSplatUtilities.EnforceDefaultTexture(texProp, "microsplat_def_perlin4"); materialEditor.ColorProperty(shaderGUI.FindProp("_SnowSparkleTint", props), "Sparkle Tint"); materialEditor.RangeProperty(shaderGUI.FindProp("_SnowSparkleStrength", props), "Sparkle Strength"); materialEditor.RangeProperty(shaderGUI.FindProp("_SnowSparkleEmission", props), "Sparkle Emission Strength"); materialEditor.FloatProperty(shaderGUI.FindProp("_SnowSparkleSize", props), "Sparkle Size"); materialEditor.FloatProperty(shaderGUI.FindProp("_SnowSparkleDensity", props), "Sparkle Density"); materialEditor.FloatProperty(shaderGUI.FindProp("_SnowSparkleViewDependency", props), "Sparkle View Dependency"); materialEditor.FloatProperty(shaderGUI.FindProp("_SnowSparkleNoiseDensity", props), "Sparkle Noise Density"); materialEditor.FloatProperty(shaderGUI.FindProp("_SnowSparkleNoiseAmplitude", props), "Sparkle Noise Amplitude"); } if (snowNormalNoise) { if (mat.HasProperty("_SnowNormalNoise")) { var texProp = shaderGUI.FindProp("_SnowNormalNoise", props); materialEditor.TexturePropertySingleLine(CDistanceNoise, texProp); MicroSplatUtilities.EnforceDefaultTexture(texProp, "microsplat_def_snow_normalnoise"); Vector4 scaleStr = shaderGUI.FindProp("_SnowNormalNoiseScaleStrength", props).vectorValue; Vector4 newScaleStr = scaleStr; newScaleStr.x = EditorGUILayout.FloatField("Noise UV Scale", scaleStr.x); newScaleStr.y = EditorGUILayout.FloatField("Noise Strength", scaleStr.y); if (newScaleStr != scaleStr) { shaderGUI.FindProp("_SnowNormalNoiseScaleStrength", props).vectorValue = newScaleStr; } } } if (snowDistanceResample) { if (mat.HasProperty("_SnowDistanceResampleScaleStrengthFade")) { Vector4 scaleStr = shaderGUI.FindProp("_SnowDistanceResampleScaleStrengthFade", props).vectorValue; Vector4 newScaleStr = scaleStr; newScaleStr.x = EditorGUILayout.FloatField("Resample UV Scale", scaleStr.x); newScaleStr.y = EditorGUILayout.FloatField("Resample Strength", scaleStr.y); newScaleStr.z = EditorGUILayout.FloatField("Resample Fade Start", scaleStr.z); newScaleStr.w = EditorGUILayout.FloatField("Resample Fade End", scaleStr.w); if (newScaleStr != scaleStr) { shaderGUI.FindProp("_SnowDistanceResampleScaleStrengthFade", props).vectorValue = newScaleStr; } } } #if __MICROSPLAT_TEXTURECLUSTERS__ if (snowStochastic) { if (mat.HasProperty("_SnowStochasticScale")) { materialEditor.RangeProperty(shaderGUI.FindProp("_SnowStochasticScale", props), "Stochastic Scale"); materialEditor.RangeProperty(shaderGUI.FindProp("_SnowStochasticContrast", props), "Stochastic Contrast"); } } #endif if (mat.HasProperty("_TessDisplaceSnowMultiplier")) { materialEditor.RangeProperty(shaderGUI.FindProp("_TessDisplaceSnowMultiplier", props), "Displacement Multiplier"); } } }
public override void OnGUI(MaterialEditor m, MaterialProperty[] properties) { var _MainTex = ShaderGUI.FindProperty("_MainTex", properties); var _TintColor = ShaderGUI.FindProperty("_TintColor", properties); var _UseSoft = ShaderGUI.FindProperty("_UseSoft", properties); var _InvFade = ShaderGUI.FindProperty("_InvFade", properties); var _UseSoftInverted = ShaderGUI.FindProperty("_UseSoftInverted", properties); var _UseFresnelFading = ShaderGUI.FindProperty("_UseFresnelFading", properties); var _FresnelFadeFactor = ShaderGUI.FindProperty("_FresnelFadeFactor", properties); //var _UseLighting = ShaderGUI.FindProperty("_UseLighting", properties); //var _LightTranslucent = ShaderGUI.FindProperty("_LightTranslucent", properties); var _UseNoiseDistortion = ShaderGUI.FindProperty("_UseNoiseDistortion", properties); var _NoiseTex = ShaderGUI.FindProperty("_NoiseTex", properties); var _DistortionSpeedScale = ShaderGUI.FindProperty("_DistortionSpeedScale", properties); var _UseVertexStreamRandom = ShaderGUI.FindProperty("_UseVertexStreamRandom", properties); //var _UseAlphaMask = ShaderGUI.FindProperty("_UseAlphaMask", properties); var _UseFresnel = ShaderGUI.FindProperty("_UseFresnel", properties); var _FresnelColor = ShaderGUI.FindProperty("_FresnelColor", properties); var _FresnelPow = ShaderGUI.FindProperty("_FresnelPow", properties); var _FresnelR0 = ShaderGUI.FindProperty("_FresnelR0", properties); var _UseCutout = ShaderGUI.FindProperty("_UseCutout", properties); var _UseSoftCutout = ShaderGUI.FindProperty("_UseSoftCutout", properties); var _UseParticlesAlphaCutout = ShaderGUI.FindProperty("_UseParticlesAlphaCutout", properties); var _Cutout = ShaderGUI.FindProperty("_Cutout", properties); var _UseCutoutTex = ShaderGUI.FindProperty("_UseCutoutTex", properties); var _CutoutTex = ShaderGUI.FindProperty("_CutoutTex", properties); var _UseCutoutThreshold = ShaderGUI.FindProperty("_UseCutoutThreshold", properties); var _CutoutColor = ShaderGUI.FindProperty("_CutoutColor", properties); var _CutoutThreshold = ShaderGUI.FindProperty("_CutoutThreshold", properties); var _IsDecalProjector = ShaderGUI.FindProperty("_IsDecalProjector", properties); var _ClipTex = ShaderGUI.FindProperty("_ClipTex", properties); var _UseFrameBlending = ShaderGUI.FindProperty("_UseFrameBlending", properties); var _ZWriteMode = ShaderGUI.FindProperty("_ZWriteMode", properties); var _CullMode = ShaderGUI.FindProperty("_CullMode", properties); var _BlendMode = ShaderGUI.FindProperty("_BlendMode", properties); var _SrcMode = ShaderGUI.FindProperty("_SrcMode", properties); var _DstMode = ShaderGUI.FindProperty("_DstMode", properties); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// m.TextureProperty(_MainTex, _MainTex.displayName); m.ColorProperty(_TintColor, _TintColor.displayName); m.ShaderProperty(_UseSoft, _UseSoft.displayName); if (Mathf.Abs(_UseSoft.floatValue - 1) < TOLERANCE) { m.ShaderProperty(_InvFade, _InvFade.displayName); m.ShaderProperty(_UseSoftInverted, _UseSoftInverted.displayName); } m.ShaderProperty(_UseFresnelFading, _UseFresnelFading.displayName); if (Mathf.Abs(_UseFresnelFading.floatValue - 1) < TOLERANCE) { m.ShaderProperty(_FresnelFadeFactor, _FresnelFadeFactor.displayName); } //m.ShaderProperty(_UseLighting, _UseLighting.displayName); //if (Mathf.Abs(_UseLighting.floatValue - 1) < TOLERANCE) // m.ShaderProperty(_LightTranslucent, _LightTranslucent.displayName); m.ShaderProperty(_UseNoiseDistortion, _UseNoiseDistortion.displayName); if (Mathf.Abs(_UseNoiseDistortion.floatValue - 1) < TOLERANCE) { m.TextureProperty(_NoiseTex, _NoiseTex.displayName); m.ShaderProperty(_DistortionSpeedScale, _DistortionSpeedScale.displayName); m.ShaderProperty(_UseVertexStreamRandom, _UseVertexStreamRandom.displayName); //m.ShaderProperty(_UseAlphaMask, _UseAlphaMask.displayName); } m.ShaderProperty(_UseFresnel, _UseFresnel.displayName); if (Mathf.Abs(_UseFresnel.floatValue - 1) < TOLERANCE) { m.ColorProperty(_FresnelColor, _FresnelColor.displayName); m.ShaderProperty(_FresnelPow, _FresnelPow.name); m.ShaderProperty(_FresnelR0, _FresnelR0.displayName); } m.ShaderProperty(_UseCutout, _UseCutout.displayName); if (Mathf.Abs(_UseCutout.floatValue - 1) < TOLERANCE) { m.ShaderProperty(_Cutout, _Cutout.displayName); m.ShaderProperty(_UseSoftCutout, _UseSoftCutout.name); m.ShaderProperty(_UseParticlesAlphaCutout, _UseParticlesAlphaCutout.displayName); m.ShaderProperty(_UseCutoutTex, _UseCutoutTex.displayName); if (Mathf.Abs(_UseCutoutTex.floatValue - 1) < TOLERANCE) { m.TextureProperty(_CutoutTex, _CutoutTex.displayName); } m.ShaderProperty(_UseCutoutThreshold, _UseCutoutThreshold.displayName); if (Mathf.Abs(_UseCutoutThreshold.floatValue - 1) < TOLERANCE) { m.ColorProperty(_CutoutColor, _CutoutColor.displayName); m.ShaderProperty(_CutoutThreshold, _CutoutThreshold.displayName); } } m.ShaderProperty(_UseFrameBlending, _UseFrameBlending.displayName); m.ShaderProperty(_IsDecalProjector, _IsDecalProjector.displayName); if (Mathf.Abs(_IsDecalProjector.floatValue - 1) < TOLERANCE) { m.TexturePropertySingleLine(new GUIContent(_ClipTex.displayName), _ClipTex); } m.ShaderProperty(_ZWriteMode, _ZWriteMode.displayName); m.ShaderProperty(_CullMode, _CullMode.displayName); m.ShaderProperty(_BlendMode, _BlendMode.displayName); if (Math.Abs(_BlendMode.floatValue) < TOLERANCE) { _SrcMode.floatValue = (int)UnityEngine.Rendering.BlendMode.SrcAlpha; _DstMode.floatValue = (int)UnityEngine.Rendering.BlendMode.One; } if (Math.Abs(_BlendMode.floatValue - 1) < TOLERANCE) { _SrcMode.floatValue = (int)UnityEngine.Rendering.BlendMode.SrcAlpha; _DstMode.floatValue = (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha; } if (Math.Abs(_BlendMode.floatValue - 2) < TOLERANCE) { _SrcMode.floatValue = (int)UnityEngine.Rendering.BlendMode.Zero; _DstMode.floatValue = (int)UnityEngine.Rendering.BlendMode.SrcColor; } m.RenderQueueField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); GUILayout.Space(8f); expandStandardProperties = GUILayout.Toggle(expandStandardProperties, "STANDARD PROPERTIES", EditorStyles.toolbarButton); if (expandStandardProperties) { //Background var vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", "RL Background"); GUILayout.Space(4f); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; } // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties /* * if (reflections != null) * GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); * //if (highlights != null) * //m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); * if (reflections != null) * m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); */ GUILayout.Space(8f); EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); //---------------------------------------------------------------- // TOONY COLORS PRO 2 expandTCP2Properties = GUILayout.Toggle(expandTCP2Properties, "TOONY COLORS PRO 2", EditorStyles.toolbarButton); if (expandTCP2Properties) { //Background var vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", "RL Background"); GUILayout.Space(4f); GUILayout.Label("Base Properties", EditorStyles.boldLabel); m_MaterialEditor.ColorProperty(tcp2_highlightColor, Styles.tcp2_highlightColorText); m_MaterialEditor.ColorProperty(tcp2_shadowColor, Styles.tcp2_shadowColorText); EditorGUILayout.Space(); //Shader Generator Properties for (var i = 0; i < SGProperties.Count; i++) { if (SGProperties[i].type == MaterialProperty.PropType.Texture) { //Compensate margins so that texture slot looks square var fw = EditorGUIUtility.fieldWidth; EditorGUIUtility.fieldWidth = 64f; m_MaterialEditor.ShaderProperty(SGProperties[i], SGProperties[i].displayName); EditorGUIUtility.fieldWidth = fw; } else { m_MaterialEditor.ShaderProperty(SGProperties[i], SGProperties[i].displayName); } } GUILayout.Space(8f); GUILayout.EndVertical(); // TCP2 End //---------------------------------------------------------------- } GUILayout.Space(10f); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; bool maskEnabled = material.IsKeywordEnabled("_PATTERN_MASK"); // Detect any changes to the material EditorGUI.BeginChangeCheck(); { //BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); DoAlbedoArea(material); if (detailMask.textureValue != null) { DoSpecularMetallicArea(); } if (specularColor != null) { m_MaterialEditor.ColorProperty(specularColor, Styles.specularColorText.text); } m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); maskEnabled = EditorGUILayout.Toggle(Styles.maskEnabledText, maskEnabled); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); m_MaterialEditor.TextureScaleOffsetProperty(dfTextureMap); m_MaterialEditor.ShaderProperty(pushAmount, "Push Amount"); //// Third properties //GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); //if (highlights != null) // m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); //if (reflections != null) // m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } if (maskEnabled) { material.EnableKeyword("_PATTERN_MASK"); } else { material.DisableKeyword("_PATTERN_MASK"); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
private bool ShaderMaterialPropertyImpl(MaterialProperty property, string filter = null) { //Filter string displayName = property.displayName; if (filter != null) { if (!displayName.Contains(filter)) { return(false); } displayName = displayName.Remove(displayName.IndexOf(filter), filter.Length + 1); } else if (displayName.Contains("#")) { return(false); } //GUI switch (property.type) { case MaterialProperty.PropType.Color: mMaterialEditor.ColorProperty(property, displayName); break; case MaterialProperty.PropType.Float: mMaterialEditor.FloatProperty(property, displayName); break; case MaterialProperty.PropType.Range: EditorGUILayout.BeginHorizontal(); //Add float field to Range parameters #if UNITY_4 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 float value = RangeProperty(property, displayName); Rect r = GUILayoutUtility.GetLastRect(); r.x = r.width - 160f; r.width = 65f; value = EditorGUI.FloatField(r, value); if (property.floatValue != value) { property.floatValue = value; } #else mMaterialEditor.RangeProperty(property, displayName); #endif EditorGUILayout.EndHorizontal(); break; case MaterialProperty.PropType.Texture: string nameLower = displayName.ToLower(); bool showOffset = !nameLower.Contains("mask"); showOffset &= !nameLower.Contains("matcap"); if (!showOffset) { if (nameLower.Contains("mask 1")) { showOffset = mShaderFeatures.Contains("UVMASK1"); } else if (nameLower.Contains("mask 2")) { showOffset = mShaderFeatures.Contains("UVMASK2"); } else if (nameLower.Contains("mask 3")) { showOffset = mShaderFeatures.Contains("UVMASK3"); } } if (!isGeneratedShader) { showOffset = !nameLower.Contains("cubemap") && !nameLower.Contains("matcap (rgb)"); } mMaterialEditor.TextureProperty(property, displayName, showOffset); break; case MaterialProperty.PropType.Vector: mMaterialEditor.VectorProperty(property, displayName); break; default: EditorGUILayout.LabelField("Unknown Material Property Type: " + property.type.ToString()); break; } return(true); }
public override void OnGUI(MaterialEditor m, MaterialProperty[] properties) { var _MainTex = ShaderGUI.FindProperty("_MainTex", properties); var _TintColor = ShaderGUI.FindProperty("_TintColor", properties); var _UseAlphaPow = ShaderGUI.FindProperty("_UseAlphaPow", properties); var _AlphaPow = ShaderGUI.FindProperty("_AlphaPow", properties); //var _UseLighting = ShaderGUI.FindProperty("_UseLighting", properties); //var _LightTranslucent = ShaderGUI.FindProperty("_LightTranslucent", properties); var _UseNoiseDistortion = ShaderGUI.FindProperty("_UseNoiseDistortion", properties); var _UseSimpleDistortion = ShaderGUI.FindProperty("_UseSimpleDistortion", properties); var _NoiseTex = ShaderGUI.FindProperty("_NoiseTex", properties); //var _DistortionSpeedScale = ShaderGUI.FindProperty("_DistortionSpeedScale", properties); var _DistortSpeed = ShaderGUI.FindProperty("_DistortSpeed", properties); var _DistortScale = ShaderGUI.FindProperty("_DistortScale", properties); //var _UseAlphaMask = ShaderGUI.FindProperty("_UseAlphaMask", properties); var _UseCutout = ShaderGUI.FindProperty("_UseCutout", properties); var _CutoutAlphaMul = ShaderGUI.FindProperty("_CutoutAlphaMul", properties); var _Cutout = ShaderGUI.FindProperty("_Cutout", properties); var _UseCutoutTex = ShaderGUI.FindProperty("_UseCutoutTex", properties); var _CutoutTex = ShaderGUI.FindProperty("_CutoutTex", properties); //var _UseCutoutThreshold = ShaderGUI.FindProperty("_UseCutoutThreshold", properties); //var _CutoutColor = ShaderGUI.FindProperty("_CutoutColor", properties); // var _CutoutRamp = ShaderGUI.FindProperty("_CutoutRamp", properties); //var _CutoutThreshold = ShaderGUI.FindProperty("_CutoutThreshold", properties); var _UseWorldSpaceUV = ShaderGUI.FindProperty("_UseWorldSpaceUV", properties); var _UseFrameBlending = ShaderGUI.FindProperty("_UseFrameBlending", properties); var _BlendMode = ShaderGUI.FindProperty("_BlendMode", properties); var _SrcMode = ShaderGUI.FindProperty("_SrcMode", properties); var _DstMode = ShaderGUI.FindProperty("_DstMode", properties); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// m.TextureProperty(_MainTex, _MainTex.displayName); m.ColorProperty(_TintColor, _TintColor.displayName); m.ShaderProperty(_UseAlphaPow, _UseAlphaPow.displayName); if (Mathf.Abs(_UseAlphaPow.floatValue - 1) < TOLERANCE) { m.ShaderProperty(_AlphaPow, _AlphaPow.displayName); } //m.ShaderProperty(_UseLighting, _UseLighting.displayName); //if (Mathf.Abs(_UseLighting.floatValue - 1) < TOLERANCE) // m.ShaderProperty(_LightTranslucent, _LightTranslucent.displayName); m.ShaderProperty(_UseNoiseDistortion, _UseNoiseDistortion.displayName); if (Mathf.Abs(_UseNoiseDistortion.floatValue - 1) < TOLERANCE) { m.ShaderProperty(_UseSimpleDistortion, _UseSimpleDistortion.displayName); m.TextureProperty(_NoiseTex, _NoiseTex.displayName); m.ShaderProperty(_DistortSpeed, _DistortSpeed.displayName); m.ShaderProperty(_DistortScale, _DistortScale.displayName); //m.ShaderProperty(_UseAlphaMask, _UseAlphaMask.displayName); } m.ShaderProperty(_UseCutout, _UseCutout.displayName); if (Mathf.Abs(_UseCutout.floatValue - 1) < TOLERANCE) { m.ShaderProperty(_Cutout, _Cutout.displayName); m.ShaderProperty(_CutoutAlphaMul, _CutoutAlphaMul.name); m.ShaderProperty(_UseCutoutTex, _UseCutoutTex.displayName); if (Mathf.Abs(_UseCutoutTex.floatValue - 1) < TOLERANCE) { m.TextureProperty(_CutoutTex, _CutoutTex.displayName); } //m.ShaderProperty(_UseCutoutThreshold, _UseCutoutThreshold.displayName); //if (Mathf.Abs(_UseCutoutThreshold.floatValue - 1) < TOLERANCE) //{ // m.ColorProperty(_CutoutColor, _CutoutColor.displayName); // //m.TextureProperty(_CutoutRamp, _CutoutRamp.displayName); // // m.ShaderProperty(_CutoutThreshold, _CutoutThreshold.displayName); //} } m.ShaderProperty(_UseWorldSpaceUV, _UseWorldSpaceUV.displayName); m.ShaderProperty(_UseFrameBlending, _UseFrameBlending.displayName); m.ShaderProperty(_BlendMode, _BlendMode.displayName); if (Math.Abs(_BlendMode.floatValue) < TOLERANCE) { _SrcMode.floatValue = (int)UnityEngine.Rendering.BlendMode.SrcAlpha; _DstMode.floatValue = (int)UnityEngine.Rendering.BlendMode.One; } if (Math.Abs(_BlendMode.floatValue - 1) < TOLERANCE) { _SrcMode.floatValue = (int)UnityEngine.Rendering.BlendMode.SrcAlpha; _DstMode.floatValue = (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha; } if (Math.Abs(_BlendMode.floatValue - 2) < TOLERANCE) { _SrcMode.floatValue = (int)UnityEngine.Rendering.BlendMode.Zero; _DstMode.floatValue = (int)UnityEngine.Rendering.BlendMode.SrcColor; } m.RenderQueueField(); #if UNITY_5_6_OR_NEWER m.EnableInstancingField(); Material material = (Material)m.target; material.enableInstancing = true; #endif }
void ColorProperty(string prop) { MaterialProperty col = FindProperty(prop); editor.ColorProperty(col, col.displayName); }