void DrawLayer(MaterialEditor editor, int i, MaterialProperty[] props, string[] keyWords, Workflow workflow, bool hasGloss, bool hasSpec, bool isParallax, bool hasEmis, bool hasDistBlend) { EditorGUIUtility.labelWidth = 0f; var albedoMap = FindProperty ("_Tex" + i, props); var tint = FindProperty("_Tint" + i, props); var normalMap = FindProperty ("_Normal" + i, props); var smoothness = FindProperty("_Glossiness" + i, props); var glossinessMap = FindProperty("_GlossinessTex" + i, props, false); var metallic = FindProperty("_Metallic" + i, props, false); var emissionTex = FindProperty("_Emissive" + i, props); var emissionMult = FindProperty("_EmissiveMult" + i, props); var parallax = FindProperty("_Parallax" + i, props); var texScale = FindProperty("_TexScale" + i, props); var specMap = FindProperty("_SpecGlossMap" + i, props, false); var specColor = FindProperty("_SpecColor" + i, props, false); var distUVScale = FindProperty("_DistUVScale" + i, props, false); editor.TexturePropertySingleLine(new GUIContent("Albedo/Height"), albedoMap); editor.ShaderProperty(tint, "Tint"); editor.TexturePropertySingleLine(new GUIContent("Normal"), normalMap); if (workflow == Workflow.Metallic) { editor.TexturePropertySingleLine(new GUIContent("Metal(R)/Smoothness(A)"), glossinessMap); } else { editor.TexturePropertySingleLine(new GUIContent("Specular(RGB)/Gloss(A)"), specMap); } if (workflow == Workflow.Metallic && !hasGloss) { editor.ShaderProperty(smoothness, "Smoothness"); editor.ShaderProperty(metallic, "Metallic"); } else if (workflow == Workflow.Specular && !hasSpec) { editor.ShaderProperty(smoothness, "Smoothness"); editor.ShaderProperty(specColor, "Specular Color"); } editor.TexturePropertySingleLine(new GUIContent("Emission"), emissionTex); editor.ShaderProperty(emissionMult, "Emissive Multiplier"); editor.ShaderProperty(texScale, "Texture Scale"); if (hasDistBlend) { editor.ShaderProperty(distUVScale, "Distance UV Scale"); } if (isParallax) { editor.ShaderProperty(parallax, "Parallax Height"); } if (i != 1) { editor.ShaderProperty(FindProperty("_Contrast"+i, props), "Interpolation Contrast"); } }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(_textCubemap, _cubemap, _tint); Vector3Property(materialEditor, _euler, "Rotation"); materialEditor.ShaderProperty(_exposure, "Exposure"); materialEditor.ShaderProperty(_saturation, "Saturation"); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_colorMode, "Color Mode"); if (_colorMode.floatValue > 0) { var rect = EditorGUILayout.GetControlRect(); rect.x += EditorGUIUtility.labelWidth; rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2; materialEditor.ShaderProperty(rect, _color, ""); rect.x += rect.width + 4; materialEditor.ShaderProperty(rect, _color2, ""); } else { materialEditor.ShaderProperty(_color, " "); } EditorGUILayout.Space(); materialEditor.ShaderProperty(_metallic, "Metallic"); materialEditor.ShaderProperty(_smoothness, "Smoothness"); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, null); materialEditor.TexturePropertySingleLine(_normalMapText, _normalMap, _normalMap.textureValue ? _normalScale : null); materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue ? _occlusionStr : null); materialEditor.TextureScaleOffsetProperty(_albedoMap); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(_textCubemap, _cubemap, _tint); Vector3Property(materialEditor, _euler, "Rotation"); materialEditor.ShaderProperty(_exposure, "Exposure"); materialEditor.ShaderProperty(_saturation, "Saturation"); materialEditor.ShaderProperty(_lod, "Specify MIP Level"); if (_lod.hasMixedValue || _lod.floatValue > 0) { EditorGUI.indentLevel++; materialEditor.ShaderProperty(_lodLevel, "Level"); EditorGUI.indentLevel--; } return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_blendMode, "Blend Mode"); materialEditor.ShaderProperty(_colorMode, "Color Mode"); if (_colorMode.floatValue > 0) { var rect = EditorGUILayout.GetControlRect(); rect.x += EditorGUIUtility.labelWidth; rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2; materialEditor.ShaderProperty(rect, _color, ""); rect.x += rect.width + 4; materialEditor.ShaderProperty(rect, _color2, ""); } else { materialEditor.ShaderProperty(_color, " "); } materialEditor.ShaderProperty(_mainTex, "Texture"); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, _albedoColor); materialEditor.ShaderProperty(_metallic, "Metallic"); materialEditor.ShaderProperty(_smoothness, "Smoothness"); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, null); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue ? _occlusionStrength : null); EditorGUILayout.Space(); materialEditor.ShaderProperty(_mapScale, "Mapping Scale"); return EditorGUI.EndChangeCheck(); }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_color, "Color"); materialEditor.ShaderProperty(_metallic, "Metallic"); materialEditor.ShaderProperty(_smoothness, "Smoothness"); EditorGUILayout.Space(); materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, null); var scale = _normalMap.textureValue ? _normalScale : null; materialEditor.TexturePropertySingleLine(_normalMapText, _normalMap, scale); var str = _occlusionMap.textureValue ? _occlusionStr : null; materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, str); if (_albedoMap.textureValue || _normalMap.textureValue || _occlusionMap.textureValue) materialEditor.ShaderProperty(_mapScale, "Scale"); return EditorGUI.EndChangeCheck(); }
protected bool DoKeyword(MaterialEditor _editor, MaterialProperty _prop, string _desc) { string _keyword; if (!m_Keywords.TryGetValue (_prop.name, out _keyword)) return false; _editor.ShaderProperty(_prop, _desc); bool _on = _prop.floatValue > 0; var _mtl = _editor.target as Material; if (_on) _mtl.EnableKeyword(_keyword); else _mtl.DisableKeyword(_keyword); return _on; }
bool ShaderPropertiesGUI(MaterialEditor materialEditor) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_baseColor, "Base Color"); materialEditor.ShaderProperty(_exposure, "Exposure"); EditorGUILayout.Space(); EditorGUILayout.LabelField("Gradient 1"); Vector3Property(materialEditor, _direction1, "Direction"); materialEditor.ShaderProperty(_color1, "Color"); materialEditor.ShaderProperty(_exponent1, "Exponent"); EditorGUILayout.Space(); materialEditor.ShaderProperty(_switch2, "Gradient 2"); if (_switch2.floatValue > 0) { Vector3Property(materialEditor, _direction2, "Direction"); materialEditor.ShaderProperty(_color2, "Color"); materialEditor.ShaderProperty(_exponent2, "Exponent"); EditorGUILayout.Space(); } materialEditor.ShaderProperty(_switch3, "Gradient 3"); if (_switch3.floatValue > 0) { Vector3Property(materialEditor, _direction3, "Direction"); materialEditor.ShaderProperty(_color3, "Color"); materialEditor.ShaderProperty(_exponent3, "Exponent"); EditorGUILayout.Space(); } materialEditor.ShaderProperty(_switch4, "Gradient 4"); if (_switch4.floatValue > 0) { Vector3Property(materialEditor, _direction4, "Direction"); materialEditor.ShaderProperty(_color4, "Color"); materialEditor.ShaderProperty(_exponent4, "Exponent"); } return EditorGUI.EndChangeCheck(); }
private void DoGeneral(MaterialEditor _materialEditor) { if (!BeginGroup("General")) return; _materialEditor.ShaderProperty(m_FadeOut, "Fade Out"); _materialEditor.TextureProperty(m_BayerTex, "Differ Matrix"); _materialEditor.TextureProperty(m_MainTex, "Main Texture (RGBA)"); if (DoKeyword(_materialEditor, m_DimOn, "Use Dim Texture")) { _materialEditor.TextureProperty(m_DimTex, "Dim Texture (RGB)"); } _materialEditor.TextureProperty(m_DiffuseLUTTex, "Diffuse LUT"); _materialEditor.TextureProperty(m_SpecularLUTTex, "Specular LUT"); EndGroup(); }
void DrawLayer(MaterialEditor editor, int i, MaterialProperty[] props, string[] keyWords, bool hasGloss, bool isParallax, bool hasEmis) { EditorGUIUtility.labelWidth = 0f; var albedoMap = FindProperty ("_Tex" + i, props); var normalMap = FindProperty ("_Normal" + i, props); var smoothness = FindProperty("_Glossiness" + i, props); var glossinessMap = FindProperty("_GlossinessTex" + i, props); var metallic = FindProperty("_Metallic" + i, props); var emissionTex = FindProperty("_Emissive" + i, props); var emissionMult = FindProperty("_EmissiveMult" + i, props); var parallax = FindProperty("_Parallax" + i, props); var texScale = FindProperty("_TexScale" + i, props); //editor.TexturePropertySingleLine("Albedo (RGB) Height (A)", albedoMap); editor.TexturePropertySingleLine(new GUIContent("Albedo/Height"), albedoMap); editor.TexturePropertySingleLine(new GUIContent("Normal"), normalMap); editor.TexturePropertySingleLine(new GUIContent("Metal(R)/Smoothness(A)"), glossinessMap); if (!hasGloss) { editor.ShaderProperty(smoothness, "Smoothness"); editor.ShaderProperty(metallic, "Metallic"); } editor.TexturePropertySingleLine(new GUIContent("Emission"), emissionTex); editor.ShaderProperty(emissionMult, "Emissive Multiplier"); editor.ShaderProperty(texScale, "Texture Scale"); if (isParallax) { editor.ShaderProperty(parallax, "Parallax Height"); } if (i != 1) { editor.ShaderProperty(FindProperty("_Contrast"+i, props), "Interpolation Contrast"); } }
void ImmediateProperty(string name, MaterialEditor materialEditor, MaterialProperty[] props) { var p = FindProperty(name, props); if (p.type == MaterialProperty.PropType.Texture) materialEditor.TexturePropertySingleLine(new GUIContent(p.displayName), p); else materialEditor.ShaderProperty(p, p.displayName); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; EditorGUIUtility.fieldWidth = 64f; Texture2D tex = Resources.Load("CalmWaterLogo") as Texture2D; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(tex); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // Detect any changes to the material EditorGUI.BeginChangeCheck(); { // Color GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Color", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(shallowColor, "Shallow Color"); m_MaterialEditor.ShaderProperty(depthColor, "Depth Color"); m_MaterialEditor.ShaderProperty(depth, "Depth"); m_MaterialEditor.ShaderProperty(enableDepthFog, "Enable Depth Fog"); m_MaterialEditor.ShaderProperty(edgeFade, "Edge Fade"); GUILayout.EndVertical(); // Spec GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Specular", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(specColor, "Specular Color"); m_MaterialEditor.ShaderProperty(smoothness, "Smoothness"); GUILayout.EndVertical(); // NormalMap GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Bump", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(bumpMap, "NormalMap"); m_MaterialEditor.ShaderProperty(bumpStrength, "Bump Strength"); GUILayout.Label("Scroll Animation", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(speedX, "Scroll Speed [X]"); m_MaterialEditor.ShaderProperty(speedY, "Scroll Speed [Y]"); //Distortion GUILayout.Label("Distortion", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(distortion, "Distortion"); m_MaterialEditor.ShaderProperty(distortionQuality, "Distortion Quality"); GUILayout.EndVertical(); // Reflections GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Reflections", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(reflectionType, "Reflection Type"); switch ((int)reflectionType.floatValue) { // Mixed Mode Reflections case 0: EditorGUILayout.HelpBox("You need to add MirrorReflection script to your object.", MessageType.Info); m_MaterialEditor.ShaderProperty(cubeColor, "Cube Color"); m_MaterialEditor.ShaderProperty(cubeMap, "Cube Map"); m_MaterialEditor.ShaderProperty(reflection, "Reflection"); break; // RealTime Mode Reflections case 1: EditorGUILayout.HelpBox("You need to add MirrorReflection script to your object.", MessageType.Info); m_MaterialEditor.ShaderProperty(reflection, "Reflection"); break; // CubeMap Reflections case 2: m_MaterialEditor.ShaderProperty(cubeColor, "Cube Color"); m_MaterialEditor.ShaderProperty(cubeMap, "Cube Map"); m_MaterialEditor.ShaderProperty(reflection, "Reflection"); break; } m_MaterialEditor.ShaderProperty(fresnel, "Fresnel"); GUILayout.EndVertical(); // Foam GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Foam", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(foamToggle, "Enable Foam"); if (foamToggle.floatValue == 1) { m_MaterialEditor.ShaderProperty(foamColor, "Foam Color"); m_MaterialEditor.ShaderProperty(foamTex, "Foam Texture"); m_MaterialEditor.ShaderProperty(foamSize, "Foam Size"); } GUILayout.EndVertical(); // Displacement GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Displacement", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(displacementMode, "Mode"); if (displacementMode.floatValue != 0f) { EditorGUILayout.HelpBox("You need enough subdivisions in your Geometry.", MessageType.Info); EditorGUILayout.HelpBox("To get correct displaced normals, your model needs to be scaled [1,1,1].", MessageType.Info); } if (displacementMode.floatValue == 1f) { m_MaterialEditor.ShaderProperty(amplitude, "Amplitude"); m_MaterialEditor.ShaderProperty(frequency, "Frequency"); m_MaterialEditor.ShaderProperty(speed, "Waves Speed"); m_MaterialEditor.ShaderProperty(smoothing, "Smoothing"); } if (displacementMode.floatValue == 2f) { m_MaterialEditor.ShaderProperty(amplitude, "Amplitude"); m_MaterialEditor.ShaderProperty(frequency, "Frequency"); m_MaterialEditor.ShaderProperty(steepness, "Steepness"); m_MaterialEditor.ShaderProperty(waveSpeed, "Waves Speed"); m_MaterialEditor.ShaderProperty(waveDirectionXY, "Waves Directions 1"); m_MaterialEditor.ShaderProperty(waveDirectionZW, "Waves Directions 2"); m_MaterialEditor.ShaderProperty(smoothing, "Smoothing"); } // if(displacementMode.floatValue == 1) // { // EditorGUILayout.HelpBox("You need enough subdivisions in your Geometry.",MessageType.Info); // if(_hasTess){ // EditorGUILayout.HelpBox("To get correct displaced normals, your model needs to be scaled [1,1,1].",MessageType.Info); // m_MaterialEditor.ShaderProperty(amplitude,"Amplitude"); // m_MaterialEditor.ShaderProperty(frequency,"Frequency"); // m_MaterialEditor.ShaderProperty(steepness,"Steepness"); // m_MaterialEditor.ShaderProperty(waveSpeed,"Waves Speed"); // m_MaterialEditor.ShaderProperty(waveDirectionXY,"Waves Directions 1"); // m_MaterialEditor.ShaderProperty(waveDirectionZW,"Waves Directions 2"); // // m_MaterialEditor.ShaderProperty(smoothing,"Smoothing"); // }else{ // m_MaterialEditor.ShaderProperty(amplitude,"Amplitude"); // m_MaterialEditor.ShaderProperty(frequency,"Frequency"); // m_MaterialEditor.ShaderProperty(waveSpeed,"Waves Speed"); // } // } GUILayout.EndVertical(); if (_hasTess) { GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Tessellation", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(tess, "Tessellation Level"); GUILayout.EndVertical(); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } } EditorGUI.BeginChangeCheck(); { EditorGUILayout.Space(); if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Opaque || (BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout) { m_MaterialEditor.ShaderProperty(player, Styles.playerText.text); } TwoSidedPopup(material); if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Opaque || (BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout) { m_MaterialEditor.ShaderProperty(vertexColorEnable, Styles.vertexColorEnableText.text); if (vertexColorEnable.floatValue == 1) { m_MaterialEditor.ShaderProperty(vertexColor, Styles.vertexColorText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel); } } if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Fade || (BlendMode)material.GetFloat("_Mode") == BlendMode.Transparent) { m_MaterialEditor.ShaderProperty(vertexAlpha, Styles.vertexAlphaText.text); if (vertexAlpha.floatValue == 1) { m_MaterialEditor.ShaderProperty(vertexAlphaValue, Styles.vertexAlphaValueText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel); } m_MaterialEditor.ShaderProperty(extendAlpha, Styles.extendAlphaText.text); ZWritePopup(material); } m_MaterialEditor.ShaderProperty(receiveFog, Styles.receiveFogText.text); DoVertexAnimation(); DoRimArea(material); EditorGUILayout.Space(); EditorGUILayout.Space(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); m_MaterialEditor.ShaderProperty(uvAnimation, Styles.uvAnimationText.text); EditorGUILayout.Space(); DoSpecularMetallicArea(); EditorGUILayout.Space(); DoNormalArea(); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); EditorGUILayout.Space(); DoEmissionArea(material); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); 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.ShaderProperty(detailBlendMode, Styles.detailBlendModeText.text); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); m_MaterialEditor.TextureScaleOffsetProperty(detailMask); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); EditorGUILayout.Space(); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); m_MaterialEditor.RenderQueueField(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { // MaterialChanged((Material)obj, m_WorkflowMode); SetMaterialKeywords((Material)obj); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); //m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(outLineWidth, "OutLineWidth"); m_MaterialEditor.ShaderProperty(outLineColor, "OutLineColor"); DoAlbedoArea(material); DoSpecularMetallicArea(); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); 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); 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); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { GUILayout.Label(Styles.tessellationText, EditorStyles.boldLabel); if (m_WorkflowMode == WorkflowMode.Distance) { m_MaterialEditor.ShaderProperty(tessellation, Styles.tessFacText.text); m_MaterialEditor.ShaderProperty(maxdist, Styles.tessMaxText.text); } else { m_MaterialEditor.ShaderProperty(tessellation, Styles.edgelenText.text); } m_MaterialEditor.ShaderProperty(tessphong, Styles.tessPhongText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); if (!hasDispTexture) { m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText2, albedoMap, albedoColor); } else { m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText, albedoMap, albedoColor); } m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.dispmapText, dispMap); m_MaterialEditor.TextureScaleOffsetProperty(dispMap); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TextureScaleOffsetProperty(bumpMap); EditorGUILayout.Space(); GUILayout.Label(Styles.displacementText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(displacement, Styles.dispScaleText.text); m_MaterialEditor.ShaderProperty(dispoffset, Styles.dispOffsetText.text); if (!hasDispTexture) { m_MaterialEditor.ShaderProperty(displacementto, Styles.dispTileText.text); } else { GUILayout.Label(Styles.displacementText, EditorStyles.boldLabel); } EditorGUILayout.Space(); GUILayout.Label(Styles.matParamsText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(metallic, Styles.metallicText.text); m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText.text); m_MaterialEditor.ShaderProperty(specburn, Styles.specBurnText.text); m_MaterialEditor.ShaderProperty(specao, Styles.specularAOText.text); m_MaterialEditor.ShaderProperty(diffuseao, Styles.diffuseAOText.text); m_MaterialEditor.ShaderProperty(giao, Styles.giAOText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.ShaderProperty(detailao, Styles.detailAOText.text); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); //m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); SetKeywords(material); } }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { // Use default labelWidth EditorGUIUtility.labelWidth = 0.0f; { 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); // 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); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; EditorGUIUtility.fieldWidth = 64f; Texture2D tex = Resources.Load("CalmWaterLogo") as Texture2D; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(tex); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // Detect any changes to the material EditorGUI.BeginChangeCheck(); { // Color GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Color", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(shallowColor, "Shallow Color"); m_MaterialEditor.ShaderProperty(depthColor, "Depth Color"); m_MaterialEditor.ShaderProperty(depth, "Depth"); m_MaterialEditor.ShaderProperty(enableDepthFog, "Enable Depth Fog"); m_MaterialEditor.ShaderProperty(edgeFade, "Edge Fade"); GUILayout.EndVertical(); // Spec GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Specular", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(specColor, "Specular Color"); m_MaterialEditor.ShaderProperty(smoothness, "Smoothness"); GUILayout.EndVertical(); // NormalMap GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Bump", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(enableLargeBump, "Enable Large Bump"); m_MaterialEditor.ShaderProperty(bumpMap, "Micro Bump"); m_MaterialEditor.ShaderProperty(bumpStrength, "Bump Strength"); if (enableLargeBump.floatValue == 1) { m_MaterialEditor.ShaderProperty(largeBump, "Large Bump"); m_MaterialEditor.ShaderProperty(bumpLargeStrength, "Bump Strength"); } GUILayout.Label("Scroll Animation", EditorStyles.boldLabel); // Animation speeds Vector2 speeds1 = EditorGUILayout.Vector2Field("Micro Speed 1", new Vector2(speeds.vectorValue.x, speeds.vectorValue.y)); Vector2 speeds2 = EditorGUILayout.Vector2Field("Micro Speed 2", new Vector2(speeds.vectorValue.z, speeds.vectorValue.w)); speeds.vectorValue = new Vector4(speeds1.x, speeds1.y, speeds2.x, speeds2.y); if (enableLargeBump.floatValue == 1) { GUILayout.BeginHorizontal(); Vector4 LargeSpeed = speedsLarge.vectorValue; Vector2 GUILargeSpeed = EditorGUILayout.Vector2Field("Large Speed", new Vector2(LargeSpeed.x, LargeSpeed.y)); speedsLarge.vectorValue = new Vector4(GUILargeSpeed.x, GUILargeSpeed.y, LargeSpeed.z, LargeSpeed.w); GUILayout.EndHorizontal(); } //Distortion GUILayout.Label("Distortion", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(distortion, "Distortion"); m_MaterialEditor.ShaderProperty(distortionQuality, "Distortion Quality"); GUILayout.EndVertical(); // Reflections GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Reflections", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(reflectionType, "Reflection Type"); switch ((int)reflectionType.floatValue) { // Mixed Mode Reflections case 1: EditorGUILayout.HelpBox("You need to add MirrorReflection script to your object.", MessageType.Info); m_MaterialEditor.ShaderProperty(cubeColor, "Cube Color"); m_MaterialEditor.ShaderProperty(cubeMap, "Cube Map"); m_MaterialEditor.ShaderProperty(reflection, "Reflection"); m_MaterialEditor.ShaderProperty(fresnel, "Fresnel"); break; // RealTime Mode Reflections case 2: EditorGUILayout.HelpBox("You need to add MirrorReflection script to your object.", MessageType.Info); m_MaterialEditor.ShaderProperty(reflection, "Reflection"); m_MaterialEditor.ShaderProperty(fresnel, "Fresnel"); break; // CubeMap Reflections case 3: m_MaterialEditor.ShaderProperty(cubeColor, "Cube Color"); m_MaterialEditor.ShaderProperty(cubeMap, "Cube Map"); m_MaterialEditor.ShaderProperty(reflection, "Reflection"); m_MaterialEditor.ShaderProperty(fresnel, "Fresnel"); break; case 4: break; } GUILayout.EndVertical(); // Foam GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Foam", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(foamToggle, "Enable Foam"); if (foamToggle.floatValue == 1) { m_MaterialEditor.ShaderProperty(foamColor, "Foam Color"); m_MaterialEditor.ShaderProperty(foamTex, "Foam Texture"); m_MaterialEditor.ShaderProperty(foamSize, "Foam Size"); } GUILayout.EndVertical(); // Displacement GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Displacement", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(displacementMode, "Mode"); if (displacementMode.floatValue != 0f) { EditorGUILayout.HelpBox("You need enough subdivisions in your Geometry.", MessageType.Info); EditorGUILayout.HelpBox("To get correct displaced normals, your model needs to be scaled [1,1,1].", MessageType.Info); } if (displacementMode.floatValue == 1f) { m_MaterialEditor.ShaderProperty(amplitude, "Amplitude"); m_MaterialEditor.ShaderProperty(frequency, "Frequency"); m_MaterialEditor.ShaderProperty(speed, "Waves Speed"); m_MaterialEditor.ShaderProperty(smoothing, "Smoothing"); } if (displacementMode.floatValue == 2f) { m_MaterialEditor.ShaderProperty(amplitude, "Amplitude"); m_MaterialEditor.ShaderProperty(frequency, "Frequency"); m_MaterialEditor.ShaderProperty(steepness, "Steepness"); m_MaterialEditor.ShaderProperty(waveSpeed, "Waves Speed"); m_MaterialEditor.ShaderProperty(waveDirectionXY, "Waves Directions 1"); m_MaterialEditor.ShaderProperty(waveDirectionZW, "Waves Directions 2"); m_MaterialEditor.ShaderProperty(smoothing, "Smoothing"); } // if(displacementMode.floatValue == 1) // { // EditorGUILayout.HelpBox("You need enough subdivisions in your Geometry.",MessageType.Info); // if(_hasTess){ // EditorGUILayout.HelpBox("To get correct displaced normals, your model needs to be scaled [1,1,1].",MessageType.Info); // m_MaterialEditor.ShaderProperty(amplitude,"Amplitude"); // m_MaterialEditor.ShaderProperty(frequency,"Frequency"); // m_MaterialEditor.ShaderProperty(steepness,"Steepness"); // m_MaterialEditor.ShaderProperty(waveSpeed,"Waves Speed"); // m_MaterialEditor.ShaderProperty(waveDirectionXY,"Waves Directions 1"); // m_MaterialEditor.ShaderProperty(waveDirectionZW,"Waves Directions 2"); // // m_MaterialEditor.ShaderProperty(smoothing,"Smoothing"); // }else{ // m_MaterialEditor.ShaderProperty(amplitude,"Amplitude"); // m_MaterialEditor.ShaderProperty(frequency,"Frequency"); // m_MaterialEditor.ShaderProperty(waveSpeed,"Waves Speed"); // } // } GUILayout.EndVertical(); if (_hasTess) { GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Tessellation", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(tess, "Tessellation Level"); GUILayout.EndVertical(); } // Options GUILayout.BeginVertical("", GUI.skin.box); GUILayout.Label("Options", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(worldSpace, "WorldSpace UV"); GUILayout.EndVertical(); // Version GUIStyle boldRight = new GUIStyle(); boldRight.alignment = TextAnchor.MiddleRight; boldRight.fontStyle = FontStyle.Bold; GUILayout.Label("Version " + _cVersion, boldRight); GUILayout.Space(3f); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { // Color m_MaterialEditor.ShaderProperty(m_LineColor, Styles.colorText.text); EditorGUILayout.Space(); // World space flag if (m_LineDataSpace != null) { bool inWorldSpace = (m_LineDataSpace.floatValue != 0.0f); var newWorldSpace = EditorGUILayout.Toggle(Styles.lineDataSpaceText, inWorldSpace); if (newWorldSpace != inWorldSpace) { if (newWorldSpace == true) { m_LineDataSpace.floatValue = 1.0f; } else { m_LineDataSpace.floatValue = 0.0f; } } } EditorGUILayout.Space(); // Line thickness curve settings GUILayout.Label(Styles.lineSettingsText, EditorStyles.boldLabel); var lineLevels = m_LineSettings.vectorValue; var newLineMin = EditorGUILayout.Slider(Styles.lineCurveMinText, lineLevels.x, 0.0f, 1.0f); var newLineMax = EditorGUILayout.Slider(Styles.lineCurveMaxText, lineLevels.y, 0.0f, 1.0f); var newLineBend = EditorGUILayout.Slider(Styles.lineCurveBendText, lineLevels.z, 0.0f, 1.0f); if (newLineMin != lineLevels.x || newLineMax != lineLevels.y || newLineBend != lineLevels.z) { lineLevels.x = newLineMin; lineLevels.y = newLineMax; lineLevels.z = newLineBend; m_LineSettings.vectorValue = lineLevels; } EditorGUILayout.Space(); // Maximum line radius GUILayout.Label(Styles.lineRadiusText, EditorStyles.boldLabel); var radiusSettings = m_LineRadius.vectorValue; var depthScaleMode = true; if (m_LineDepthScaleMode != null) { depthScaleMode = (m_LineDepthScaleMode.floatValue != 0.0f); var newDepthScaleMode = EditorGUILayout.Toggle(Styles.lineRadiusDepthText, depthScaleMode); if (newDepthScaleMode != depthScaleMode) { if (newDepthScaleMode == true) { m_LineDepthScaleMode.floatValue = 1.0f; } else { m_LineDepthScaleMode.floatValue = 0.0f; } } } var newRadiusScale = EditorGUILayout.FloatField(Styles.lineRadiusScaleText, radiusSettings.x); var newRadiusMin = radiusSettings.y; var newRadiusMax = radiusSettings.z; if (depthScaleMode == false) { newRadiusMin = Mathf.Max(EditorGUILayout.FloatField(Styles.lineRadiusMinText, radiusSettings.y), 0.0f); newRadiusMax = Mathf.Max(EditorGUILayout.FloatField(Styles.lineRadiusMaxText, radiusSettings.z), newRadiusMin); } if (newRadiusScale != radiusSettings.x || newRadiusMin != radiusSettings.y || newRadiusMax != radiusSettings.z) { radiusSettings.x = newRadiusScale; radiusSettings.y = newRadiusMin; radiusSettings.z = newRadiusMax; m_LineRadius.vectorValue = radiusSettings; } } if (EditorGUI.EndChangeCheck()) { MaterialChanged(material); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // 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.Label(Styles.bakeryText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(enableDoubleSidedOn, Styles.doubleSidedLabel); enableDoubleSided.floatValue = enableDoubleSidedOn.floatValue > 0 ? 0 : 2; m_MaterialEditor.ShaderProperty(enableVertexLM, Styles.vertexLMLabel); if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMdir, Styles.vertexLMdirLabel); //if (enableVertexLMdir.floatValue > 0) enableVertexLMSH.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMSH, Styles.vertexLMSHLabel); //if (enableVertexLMSH.floatValue > 0) enableVertexLMdir.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMmask, Styles.vertexLMMaskLabel); } m_MaterialEditor.ShaderProperty(enableRNM, Styles.rnmLabel); m_MaterialEditor.ShaderProperty(enableSH, Styles.shLabel); if (enableSH.floatValue > 0 || enableVertexLMSH.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableSHN, Styles.shnLabel); } m_MaterialEditor.ShaderProperty(enableSpec, Styles.specLabel); m_MaterialEditor.ShaderProperty(enableBicubic, Styles.bicubicLabel); m_MaterialEditor.ShaderProperty(enablePSHN, Styles.pshnLabel); EditorGUILayout.Space(); } 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(); m_MaterialEditor.ShaderProperty(cullMode, Styles.cullText); if (outlineEnabled.floatValue == 0) { stencilRef.floatValue = 0; } GUILayout.BeginHorizontal(); ButtonToggle(ref stylizeRamp, "Custom Ramp"); ButtonToggle(ref stylizeSpec, "Custom Specular"); ButtonToggle(ref stylizeRim, "Custom Rim"); ButtonToggle(ref outlineEnabled, "Outlines"); GUILayout.EndHorizontal(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); if (advancedChannels.floatValue == 1) { ProperPopup(ref heightEnum, 100); } m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); if (advancedChannels.floatValue == 1) { ProperPopup(ref occlusionEnum, 90); } m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); if (advancedChannels.floatValue == 1) { ProperPopup(ref maskEnum, 100); } if (advancedChannels.floatValue != 1) { heightEnum.floatValue = 1; occlusionEnum.floatValue = 1; maskEnum.floatValue = 3; } 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); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap, detailColor); 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); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(advancedChannels, Styles.advancedChannelsText); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(material); if (brightness != null) { m_MaterialEditor.ShaderProperty(brightness, Styles.brightnessText, 0); } 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.babylonText, EditorStyles.boldLabel); if (wireframe != null) { m_MaterialEditor.ShaderProperty(wireframe, Styles.wireframeText); } if (cameraContrast != null) { m_MaterialEditor.ShaderProperty(cameraContrast, Styles.cameraContrastText); } if (cameraExposure != null) { m_MaterialEditor.ShaderProperty(cameraExposure, Styles.cameraExposureText); } if (directIntensity != null) { m_MaterialEditor.ShaderProperty(directIntensity, Styles.directIntensityText); } if (emissiveIntensity != null) { m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); } if (specularIntensity != null) { m_MaterialEditor.ShaderProperty(specularIntensity, Styles.specularIntensityText); } if (backFaceCulling != null) { m_MaterialEditor.ShaderProperty(backFaceCulling, Styles.backFaceCullingText); } if (twoSidedLighting != null) { m_MaterialEditor.ShaderProperty(twoSidedLighting, Styles.twoSidedLightingText); } if (alphaMode != null) { m_MaterialEditor.ShaderProperty(alphaMode, Styles.alphaModeText); } if (refractionTexture != null) { m_MaterialEditor.ShaderProperty(refractionTexture, Styles.refractionTextureText); } if (indexOfRefraction != null) { m_MaterialEditor.ShaderProperty(indexOfRefraction, Styles.indexOfRefractionText); } if (linkRefractionWithTransparency != null) { m_MaterialEditor.ShaderProperty(linkRefractionWithTransparency, Styles.linkRefractionWithTransparencyText); } if (disableLighting != null) { m_MaterialEditor.ShaderProperty(disableLighting, Styles.disableLightingText); } if (maxSimultaneousLights != null) { m_MaterialEditor.ShaderProperty(maxSimultaneousLights, Styles.maxSimultaneousLightsText); } if (useEmissiveAsIllumination != null) { m_MaterialEditor.ShaderProperty(useEmissiveAsIllumination, Styles.useEmissiveAsIlluminationText); } if (useSpecularOverAlpha != null) { m_MaterialEditor.ShaderProperty(useSpecularOverAlpha, Styles.useSpecularOverAlphaText); } if (useRadianceOverAlpha != null) { m_MaterialEditor.ShaderProperty(useRadianceOverAlpha, Styles.useRadianceOverAlphaText); } if (usePhysicalLightFalloff != null) { m_MaterialEditor.ShaderProperty(usePhysicalLightFalloff, Styles.usePhysicalLightFalloffText); } // Forth 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 (reflectionScale != null) { m_MaterialEditor.ShaderProperty(reflectionScale, Styles.reflectionScaleText); } if (lightmapScale != null) { m_MaterialEditor.ShaderProperty(lightmapScale, Styles.lightmapScaleText); } if (environmentScale != null) { m_MaterialEditor.ShaderProperty(environmentScale, Styles.environmentScaleText); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
public void ShaderPropertiesGUI(Material material) { EditorGUI.BeginChangeCheck(); { EditorGUIUtility.fieldWidth = 64f; EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Surface"), EditorStyles.boldLabel); GUILayout.Space(5); matEditor.TexturePropertySingleLine(new GUIContent("Albedo"), mainTex); GUILayout.Space(5); matEditor.ShaderProperty(metallic, "Metallic"); matEditor.ShaderProperty(smoothness, "Smoothness"); }); EditorGUILayout.Separator(); InspectorBox(10, () => { //EditorGUILayout.LabelField(new GUIContent("Main Bending"), EditorStyles.boldLabel); //GUILayout.Space(5); matEditor.ShaderProperty(mbDefaultBending, new GUIContent("Default Bending", "The base bending applied to the model.")); GUILayout.Space(5); matEditor.ShaderProperty(mbAmplitude, new GUIContent("Amplitude", "The amplitude of the main bending.")); matEditor.ShaderProperty(mbAmplitudeOffset, new GUIContent("Amplitude Offset", "The amplitude offset of the main bending. The value of this field is multiplied with a static noise value and added to the main bending amplitude.")); GUILayout.Space(5); matEditor.ShaderProperty(mbFrequency, new GUIContent("Frequency", "The frequency of the main bending.")); matEditor.ShaderProperty(mbFrequencyOffset, new GUIContent("Frequency Offset", "The frequency offset of the main bending. The value of this field is multiplied with a static noise value and added to the main bending frequency.")); GUILayout.Space(5); matEditor.ShaderProperty(mbPhase, new GUIContent("Phase", "The phase of the main bending. A phase shift is applied based on the position the game object has on the XZ axis. " + "If the main bending of the models that are close to each other is synchronous, try to increase the value of this field.")); GUILayout.Space(5); matEditor.ShaderProperty(mbWindDirection, new GUIContent("Wind Dir", "The direction of the wind.")); matEditor.ShaderProperty(mbWindDirectionOffset, new GUIContent("Wind Dir Offset", "The wind direction offset. " + "This value is multiplied with an animated noise value and added to the wind direction to create wind direction variation over time.")); GUILayout.Space(5); matEditor.ShaderProperty(mbMaxHeight, new GUIContent("Max Height", "The height of the tallest model that uses this material. " + "This value is used to calculate the final main bending amplitude of a vertex.")); }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("World Space Noise"), EditorStyles.boldLabel); GUILayout.Space(5); matEditor.TexturePropertySingleLine(new GUIContent("Noise Texture"), noiseTexture); matEditor.ShaderProperty(noiseTextureTiling, new GUIContent("Noise Tiling: Static (XY), Animated (ZW)", "Noise texture tiling. " + "The XY values are used for static noise tiling and ZW for animated noise tiling.")); matEditor.ShaderProperty(noisePannerSpeed, new GUIContent("Noise Panning Speed", "The panning speed of the noise texture.")); }); EditorGUILayout.Separator(); InspectorBox(10, () => { GUILayout.Label("Advanced Options", EditorStyles.boldLabel); matEditor.EnableInstancingField(); }); } }
public void ShaderPropertiesGUI(Material material) { EditorGUI.BeginChangeCheck(); { EditorGUIUtility.fieldWidth = 64f; InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Color"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(shallowWaterColor, "Shallow Water Color"); mMatEditor.ShaderProperty(deepWaterColor, "Deep Water Color"); mMatEditor.ShaderProperty(opacity, "Opacity"); mMatEditor.ShaderProperty(edgeBlend, "Edge Blend"); mMatEditor.ShaderProperty(waterDepth, "Water Depth"); mMatEditor.ShaderProperty(depthFogToggle, "Fog"); if (depthFogToggle.floatValue == 1) { mMatEditor.ShaderProperty(fogDepth, "Fog Depth"); mMatEditor.ShaderProperty(fogFalloff, "Fog Falloff"); mMatEditor.ShaderProperty(fogDensityCap, "Fog Density Cap"); } }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Distortion"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(distortion, "Distortion"); mMatEditor.ShaderProperty(bumpWaves, "Bump Waves"); mMatEditor.ShaderProperty(bumpTiling, "Bump Tiling"); mMatEditor.ShaderProperty(bumpDirection, "Bump Direction"); mMatEditor.TexturePropertySingleLine(new GUIContent("Bump Map"), bumpMap); }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Water Line"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(waterLineColor, "Water Line Color"); mMatEditor.TexturePropertySingleLine(new GUIContent("Water Line Texture"), waterLineTexture); mMatEditor.ShaderProperty(pixelsPerUnits, "Pixels Per Units"); }); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } } EditorGUI.BeginChangeCheck(); { m_MaterialEditor.ShaderProperty(gpuAnim, Styles.gpuAnimText); if ((int)gpuAnim.floatValue == 1) { m_MaterialEditor.TexturePropertySingleLine(Styles.animPosTexText, animPosTex); m_MaterialEditor.TexturePropertySingleLine(Styles.animNormalTexText, animNormalTex); m_MaterialEditor.TexturePropertySingleLine(Styles.animTangentTexText, animTangentTex); } // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap); m_MaterialEditor.ShaderProperty(unmetalSmoothness, Styles.unmetalSmoothnessText); m_MaterialEditor.ShaderProperty(metalSmoothness, Styles.metalSmoothnessText); m_MaterialEditor.ShaderProperty(skinColor, Styles.skinColorText); m_MaterialEditor.ShaderProperty(capSheildColor, Styles.capSheildColorText); m_MaterialEditor.ShaderProperty(rimPower, Styles.rimPowerText); m_MaterialEditor.ShaderProperty(rimRange, Styles.rimRangeText); m_MaterialEditor.ShaderProperty(rimColor, Styles.rimColorText); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : 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(); // m_MaterialEditor.ShaderProperty(startEndFrame, Styles.startEndFrameText); // m_MaterialEditor.ShaderProperty(animParam0, Styles.animParam0Text); //m_MaterialEditor.ShaderProperty(animParam1, Styles.animParam1Text); EditorGUILayout.Space(); // Secondary properties m_MaterialEditor.RenderQueueField(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { // MaterialChanged((Material)obj, m_WorkflowMode); SetMaterialKeywords((Material)obj); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] props) { // get the current keywords from the material Material targetMat = materialEditor.target as Material; string[] keyWords = targetMat.shaderKeywords; int layerCount = 1; Workflow workflow = Workflow.Metallic; if (targetMat.shader.name == "VertexPainter/SplatBlend_1Layer") { layerCount = 1; } else if (targetMat.shader.name == "VertexPainter/SplatBlend_2Layer") { layerCount = 2; } else if (targetMat.shader.name == "VertexPainter/SplatBlend_3Layer") { layerCount = 3; } else if (targetMat.shader.name == "VertexPainter/SplatBlend_4Layer") { layerCount = 4; } else if (targetMat.shader.name == "VertexPainter/SplatBlend_5Layer") { layerCount = 5; } else if (targetMat.shader.name == "VertexPainter/SplatBlendSpecular_1Layer") { workflow = Workflow.Specular; layerCount = 1; } else if (targetMat.shader.name == "VertexPainter/SplatBlendSpecular_2Layer") { workflow = Workflow.Specular; layerCount = 2; } else if (targetMat.shader.name == "VertexPainter/SplatBlendSpecular_3Layer") { workflow = Workflow.Specular; layerCount = 3; } else if (targetMat.shader.name == "VertexPainter/SplatBlendSpecular_4Layer") { workflow = Workflow.Specular; layerCount = 4; } else if (targetMat.shader.name == "VertexPainter/SplatBlendSpecular_5Layer") { workflow = Workflow.Specular; layerCount = 5; } FlowChannel fchannel = FlowChannel.None; if (keyWords.Contains("_FLOW1")) fchannel = FlowChannel.One; if (keyWords.Contains("_FLOW2")) fchannel = FlowChannel.Two; if (keyWords.Contains("_FLOW3")) fchannel = FlowChannel.Three; if (keyWords.Contains("_FLOW4")) fchannel = FlowChannel.Four; if (keyWords.Contains("_FLOW5")) fchannel = FlowChannel.Five; bool flowDrift = keyWords.Contains("_FLOWDRIFT"); bool flowRefraction = keyWords.Contains("_FLOWREFRACTION"); bool parallax = keyWords.Contains ("_PARALLAXMAP"); bool hasGloss = (HasTexture(layerCount, targetMat, "_GlossinessTex")); bool hasSpec = (HasTexture(layerCount, targetMat, "_SpecGlossMap")); bool hasEmis = (HasTexture(layerCount, targetMat, "_Emissive")); bool hasDistBlend = keyWords.Contains("_DISTBLEND"); EditorGUI.BeginChangeCheck(); Workflow oldWorkflow = workflow; workflow = (Workflow)EditorGUILayout.EnumPopup("Workflow", workflow); int oldLayerCount = layerCount; layerCount = EditorGUILayout.IntField("Layer Count", layerCount); if (oldLayerCount != layerCount || workflow != oldWorkflow) { if (layerCount < 1) layerCount = 1; if (layerCount > 5) layerCount = 5; if (workflow == Workflow.Metallic) { targetMat.shader = Shader.Find("VertexPainter/SplatBlend_" + layerCount + "Layer"); } else { targetMat.shader = Shader.Find("VertexPainter/SplatBlendSpecular_" + layerCount + "Layer"); } return; } parallax = EditorGUILayout.Toggle ("Parallax Offset", parallax); hasDistBlend = EditorGUILayout.Toggle("UV Scale in distance", hasDistBlend); var distBlendMin = FindProperty("_DistBlendMin", props); var distBlendMax = FindProperty("_DistBlendMax", props); if (hasDistBlend) { materialEditor.ShaderProperty(distBlendMin, "Distance Blend Min"); materialEditor.ShaderProperty(distBlendMax, "Distance Blend Max"); // make sure max is at least min if (distBlendMin.floatValue > distBlendMax.floatValue) { distBlendMax.floatValue = distBlendMin.floatValue; } // make sure max is at least 1 if (distBlendMax.floatValue <= 1) { distBlendMax.floatValue = 1; } } for (int i = 0; i < layerCount; ++i) { DrawLayer(materialEditor, i+1, props, keyWords, workflow, hasGloss, hasSpec, parallax, hasEmis, hasDistBlend); EditorGUILayout.Space(); } EditorGUILayout.Space(); fchannel = (FlowChannel)EditorGUILayout.Popup((int)fchannel, flowChannelNames); if (fchannel != FlowChannel.None) { var flowSpeed = FindProperty("_FlowSpeed", props); var flowIntensity = FindProperty("_FlowIntensity", props); var flowAlpha = FindProperty("_FlowAlpha", props); var flowRefract = FindProperty("_FlowRefraction", props); materialEditor.ShaderProperty(flowSpeed, "Flow Speed"); materialEditor.ShaderProperty(flowIntensity, "Flow Intensity"); materialEditor.ShaderProperty(flowAlpha, "Flow Alpha"); if (layerCount > 1) { flowRefraction = EditorGUILayout.Toggle("Flow Refraction", flowRefraction); if (flowRefraction) { materialEditor.ShaderProperty(flowRefract, "Refraction Amount"); } } flowDrift = EditorGUILayout.Toggle("Flow Drift", flowDrift); } if (EditorGUI.EndChangeCheck()) { var newKeywords = new List<string>(); newKeywords.Add("_LAYERS" + layerCount.ToString()); if (hasDistBlend) { newKeywords.Add("_DISTBLEND"); } if (parallax) { newKeywords.Add("_PARALLAXMAP"); } if (HasTexture(layerCount, targetMat, "_Normal")) { newKeywords.Add("_NORMALMAP"); } if (hasGloss && workflow == Workflow.Metallic) { newKeywords.Add("_METALLICGLOSSMAP"); } if (hasSpec && workflow == Workflow.Specular) { newKeywords.Add("_SPECGLOSSMAP"); } if (hasEmis) { newKeywords.Add("_EMISSION"); } if (fchannel != FlowChannel.None) { newKeywords.Add("_FLOW" + (int)fchannel); } if (flowDrift) { newKeywords.Add("_FLOWDRIFT"); } if (flowRefraction && layerCount > 1) { newKeywords.Add("_FLOWREFRACTION"); } targetMat.shaderKeywords = newKeywords.ToArray (); EditorUtility.SetDirty (targetMat); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Main Maps 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); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); 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 Maps 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); // Forward Rendering Options 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); } } EditorGUILayout.Space(); // Advanced Options GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); EditorGUILayout.Space(); // Scan Properties *** // GUILayout.Label(Styles.rimTitle, EditorStyles.boldLabel); // m_MaterialEditor.ShaderProperty(rimColor, Styles.rimColorText); // m_MaterialEditor.ShaderProperty(rimPower, Styles.rimPowerText); // ******************* }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { //$$$-------------------------------------- GUILayout.BeginHorizontal(); GUILayout.Label("Render queue: ", GUILayout.Width(100)); EditorGUI.BeginChangeCheck(); Styles.renderQueue = material.renderQueue - (int)RenderQueue.AlphaTest; Styles.renderQueue = (int)GUILayout.HorizontalSlider(Styles.renderQueue, 0, 50); int.TryParse(GUILayout.TextField(Styles.renderQueue.ToString(), GUILayout.Width(30)), out Styles.renderQueue); if (EditorGUI.EndChangeCheck()) { material.renderQueue = (int)RenderQueue.AlphaTest + Styles.renderQueue; } GUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); Styles.zWrite = GUILayout.Toggle(Styles.zWrite, "Write into ZBuffer "); if (EditorGUI.EndChangeCheck()) { if (Styles.zWrite) { material.SetInt("_ZWrite", 1); } else { material.SetInt("_ZWrite", 0); } } //BlendModePopup(); //$$$-------------------------------------- // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(overalAlpha, Styles.overalAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); m_MaterialEditor.ShaderProperty(diffuseAlpha, Styles.diffuseAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- DoSpecularMetallicArea(); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(specularAlpha, Styles.specularAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); m_MaterialEditor.ShaderProperty(smoothnessAlpha, Styles.smoothnessAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(normalAlpha, Styles.normalAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); //$$$-------------------------------------- m_MaterialEditor.ShaderProperty(occlusionAlpha, Styles.occlusionAlphaText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel - 1); //$$$-------------------------------------- m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); 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); 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); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } EditorGUILayout.Space(); // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
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 void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; GUILayout.Label("Primary Textures", EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.tex, tex, color); m_MaterialEditor.TexturePropertySingleLine(Styles.norm, norm); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNorm, detailNorm, detailNormIntensity); m_MaterialEditor.TextureScaleOffsetProperty(detailNorm); m_MaterialEditor.ShaderProperty(lodBiasDiff, Styles.lodBiasDiff); m_MaterialEditor.ShaderProperty(detailNormIntensitySpec, Styles.detailNormIntensitySpec); GUILayout.Label("Material Properties", EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.s_ao_sss, s_ao_sss); m_MaterialEditor.ShaderProperty(aoStr, Styles.aoStr); m_MaterialEditor.ShaderProperty(smoothRemapBlackBase, Styles.smoothRemapBlackBase); m_MaterialEditor.ShaderProperty(smoothRemapWhiteBase, Styles.smoothRemapWhiteBase); m_MaterialEditor.ShaderProperty(smoothRemapBlack, Styles.smoothRemapBlack); m_MaterialEditor.ShaderProperty(smoothRemapWhite, Styles.smoothRemapWhite); m_MaterialEditor.ShaderProperty(sssRemapBlack, Styles.sssRemapBlack); m_MaterialEditor.ShaderProperty(sssRemapWhite, Styles.sssRemapWhite); GUILayout.Label("Subsurface Scattering", EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(sssColor, Styles.sssColor); m_MaterialEditor.ShaderProperty(sssPower, Styles.sssPower); m_MaterialEditor.ShaderProperty(sssAmb, Styles.sssAmb); m_MaterialEditor.ShaderProperty(sssDist, Styles.sssDist); m_MaterialEditor.ShaderProperty(sssEdgeValue, Styles.sssEdgeValue); m_MaterialEditor.ShaderProperty(sssEdgePowerMin, Styles.sssEdgePowerMin); m_MaterialEditor.ShaderProperty(sssEdgePowerMax, Styles.sssEdgePowerMax); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); GUILayout.Label(Styles.tessellationText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(tessmode, Styles.tessModeText.text); CheckTessMode(); if (m_TessWorkflowMode == TessWorkflowMode.Distance) { m_MaterialEditor.ShaderProperty(tessellation, Styles.tessFacText.text); m_MaterialEditor.ShaderProperty(maxdist, Styles.tessMaxText.text); } else { m_MaterialEditor.ShaderProperty(tessellation, Styles.edgelenText.text); } m_MaterialEditor.ShaderProperty(shadowgen, Styles.shoadowGenText.text); EditorGUILayout.Space(); GUILayout.Label(Styles.displacementText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(phong, Styles.phongText.text); m_MaterialEditor.ShaderProperty(displacement, Styles.dispScaleText.text); m_MaterialEditor.ShaderProperty(dispoffset, Styles.dispOffsetText.text); EditorGUILayout.Space(); // 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); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); 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); 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); } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode, m_TessWorkflowMode); } } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); }
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")); } } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // 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.Label(Styles.bakeryText, EditorStyles.boldLabel); m_MaterialEditor.ShaderProperty(enableDoubleSidedOn, Styles.doubleSidedLabel); enableDoubleSided.floatValue = enableDoubleSidedOn.floatValue > 0 ? 0 : 2; m_MaterialEditor.ShaderProperty(enableVertexLM, Styles.vertexLMLabel); if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMdir, Styles.vertexLMdirLabel); //if (enableVertexLMdir.floatValue > 0) enableVertexLMSH.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMSH, Styles.vertexLMSHLabel); //if (enableVertexLMSH.floatValue > 0) enableVertexLMdir.floatValue = 0; } if (enableVertexLM.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableVertexLMmask, Styles.vertexLMMaskLabel); } m_MaterialEditor.ShaderProperty(enableRNM, Styles.rnmLabel); m_MaterialEditor.ShaderProperty(enableSH, Styles.shLabel); if (enableSH.floatValue > 0 || enableVertexLMSH.floatValue > 0) { m_MaterialEditor.ShaderProperty(enableSHN, Styles.shnLabel); } m_MaterialEditor.ShaderProperty(enableSpec, Styles.specLabel); m_MaterialEditor.ShaderProperty(enableBicubic, Styles.bicubicLabel); m_MaterialEditor.ShaderProperty(enablePSHN, Styles.pshnLabel); m_MaterialEditor.ShaderProperty(enableVolumes, Styles.volLabel); if (enableVolumes.floatValue > 0) { var prevAssignedVolume = assignedVolume; assignedVolume = EditorGUILayout.ObjectField(volume0.textureValue == null ? "Assign volume" : "Assign different volume", assignedVolume, typeof(BakeryVolume), true) as BakeryVolume; if (prevAssignedVolume != assignedVolume) { volume0.textureValue = assignedVolume.bakedTexture0; volume1.textureValue = assignedVolume.bakedTexture1; volume2.textureValue = assignedVolume.bakedTexture2; volumeMask.textureValue = assignedVolume.bakedMask; var b = assignedVolume.bounds; volumeMin.vectorValue = b.min; volumeInvSize.vectorValue = new Vector3(1.0f / b.size.x, 1.0f / b.size.y, 1.0f / b.size.z); assignedVolume = null; } if (volume0.textureValue != null) { if (GUILayout.Button("Unset volume")) { volume0.textureValue = null; volume1.textureValue = null; volume2.textureValue = null; volumeMask.textureValue = null; volumeMin.vectorValue = Vector3.zero; volumeInvSize.vectorValue = Vector3.one * 1000001; } } EditorGUILayout.LabelField("Current Volume: " + (volume0.textureValue == null ? "<none or global>" : volume0.textureValue.name.Substring(0, volume0.textureValue.name.Length - 1))); EditorGUI.BeginDisabledGroup(true); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel0, volume0); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel1, volume1); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel2, volume2); m_MaterialEditor.TexturePropertySingleLine(Styles.volLabelMask, volumeMask); var bmin4 = volumeMin.vectorValue; var bmin = new Vector3(bmin4.x, bmin4.y, bmin4.z); var invSize = volumeInvSize.vectorValue; var bmax = new Vector3(1.0f / invSize.x + bmin.x, 1.0f / invSize.y + bmin.y, 1.0f / invSize.z + bmin.z); EditorGUILayout.LabelField("Min: " + bmin); EditorGUILayout.LabelField("Max: " + bmax); EditorGUI.EndDisabledGroup(); } EditorGUILayout.Space(); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
//GUI update public void ShaderPropertiesGUI(Material material) { EditorGUIUtility.labelWidth = 0f; int indentation = 0; m_MaterialEditor.RenderQueueField(); m_MaterialEditor.EnableInstancingField(); indentation = 1; if (imageType.floatValue == 0) { //Mask EditorGUI.BeginChangeCheck(); m_MaterialEditor.ShaderProperty(imageType, Styles.imageTypeText); m_MaterialEditor.ShaderProperty(maskBlendMode, Styles.maskBlendModeText, indentation); m_MaterialEditor.ShaderProperty(showMaskImage, Styles.showMaskImageText, indentation); if (EditorGUI.EndChangeCheck()) { UpdateAlphaBlendMode(material); if (maskBlendMode.floatValue == (int)MaskBlend.Customize) { _isBlendOpen = true; } } } else { //Image EditorGUI.BeginChangeCheck(); m_MaterialEditor.ShaderProperty(imageType, Styles.imageTypeText); m_MaterialEditor.ShaderProperty(imageBlendMode, Styles.imageBlendModeText, indentation); if (EditorGUI.EndChangeCheck()) { UpdateColorBlendMode(material); if (imageBlendMode.floatValue == (int)ImageBlend.Customize) { _isBlendOpen = true; } } } m_MaterialEditor.ShaderProperty(multiplyAlpha, Styles.multiplyAlphaText, indentation); //BlendMode bool isBlendFoldoutOpne = EditorGUILayout.Foldout(_isBlendOpen, "BlendMode"); if (_isBlendOpen != isBlendFoldoutOpne) { _isBlendOpen = isBlendFoldoutOpne; } if (isBlendFoldoutOpne) { EditorGUI.BeginChangeCheck(); m_MaterialEditor.ShaderProperty(blendSrc, Styles.blendSrcText, indentation); m_MaterialEditor.ShaderProperty(blendDst, Styles.blendDstText, indentation); m_MaterialEditor.ShaderProperty(blendAlphaSrc, Styles.blendAlphaSrcText, indentation); m_MaterialEditor.ShaderProperty(blendAlphaDst, Styles.blendAlphaDstText, indentation); m_MaterialEditor.ShaderProperty(blendColorOp, Styles.blendColorOpText, indentation); m_MaterialEditor.ShaderProperty(blendAlphaOp, Styles.blendAlphaOpText, indentation); if (EditorGUI.EndChangeCheck()) { material.SetFloat("_ImageBlendMode", (float)ImageBlend.Customize); material.SetFloat("_MaskBlendMode", (float)MaskBlend.Customize); } } indentation = 0; m_MaterialEditor.ShaderProperty(useAlphaMaskMap, Styles.useAlphaMaskMapText, indentation); if (useAlphaMaskMap.floatValue != 0) { m_MaterialEditor.TexturePropertySingleLine(Styles.alphaMaskMapText, alphaMaskMap); m_MaterialEditor.TextureScaleOffsetProperty(alphaMaskMap); } //MaskSetting m_MaterialEditor.ShaderProperty(useMaskChannel, Styles.useMaskChannelText, indentation); m_MaterialEditor.ShaderProperty(alphaMaskTransiton, Styles.alphaMaskTransitonText, indentation); m_MaterialEditor.ShaderProperty(alphaMaskEdge, Styles.alphaMaskEdgeText, indentation); //エッジ m_MaterialEditor.ShaderProperty(alphaMaskInverse, Styles.alphaMaskInverseText, indentation); //Alpha反転 m_MaterialEditor.ShaderProperty(imageIntensity, Styles.imageIntensityText, indentation); //Alpha反転 m_MaterialEditor.ShaderProperty(mainSpeedU, Styles.mainSpeedUText, indentation); m_MaterialEditor.ShaderProperty(mainSpeedV, Styles.mainSpeedVText, indentation); m_MaterialEditor.ShaderProperty(scale, Styles.scaleText, indentation); m_MaterialEditor.ShaderProperty(pixelSnap, Styles.pixelSnapText, indentation); //AlphaClip m_MaterialEditor.ShaderProperty(useUIAlphaClip, Styles.useUIAlphaClipText, indentation); m_MaterialEditor.ShaderProperty(cutoff, Styles.cutoffText, indentation); m_MaterialEditor.ShaderProperty(clipInverse, Styles.clipInverseText, indentation); m_MaterialEditor.ShaderProperty(alphaToMask, Styles.alphaToMaskText, indentation); //CullOff m_MaterialEditor.ShaderProperty(cullMode, Styles.cullModeText, indentation); //ColorMask m_MaterialEditor.ShaderProperty(colorMask, Styles.colorMaskText, indentation); //Stencil m_MaterialEditor.ShaderProperty(stencilComp, Styles.stencilCompText, indentation); m_MaterialEditor.ShaderProperty(stencilRef, Styles.stencilRefText, indentation); m_MaterialEditor.ShaderProperty(stencilPass, Styles.stencilPassText, indentation); //depth m_MaterialEditor.ShaderProperty(zWriteParam, Styles.zWriteParamText, indentation); m_MaterialEditor.ShaderProperty(zTestMode, Styles.zTestModeText, indentation); }
private float ShowProp(MaterialEditor materialEditor, MaterialProperty prop) { materialEditor.ShaderProperty(prop, prop.displayName); return(prop.floatValue); }
private void DoRim(MaterialEditor _materialEditor) { if (!BeginGroup("Rim")) return; if (DoKeyword(_materialEditor, m_RimOn, "Use Rim")) { _materialEditor.ShaderProperty(m_RimLUTTex, "Rim LUT (Grayscale)"); _materialEditor.ShaderProperty(m_RimIntensity, "Rim Intensity"); } EndGroup(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; bool blendModeChanged = false; { blendModeChanged = BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); DoNormalArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); 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); 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); } EditorGUILayout.Space(); GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); m_MaterialEditor.RenderQueueField(); } if (blendModeChanged) { foreach (var obj in blendMode.targets) { SetupMaterialWithBlendMode((Material)obj, (BlendMode)((Material)obj).GetFloat("_Mode"), true); } } m_MaterialEditor.EnableInstancingField(); m_MaterialEditor.DoubleSidedGIField(); }
void DoStencilArea(Material material) { m_MaterialEditor.ShaderProperty(ReferenceValue, Styles.ReferenceValueText); m_MaterialEditor.ShaderProperty(ReadMask, Styles.ReadMaskText); m_MaterialEditor.ShaderProperty(WriteMask, Styles.WriteMaskText); m_MaterialEditor.ShaderProperty(stComp, Styles.stCompText); m_MaterialEditor.ShaderProperty(stPass, Styles.stPassText); m_MaterialEditor.ShaderProperty(stFail, Styles.stFailText); m_MaterialEditor.ShaderProperty(stZFail, Styles.stZFailText); stComp_c.floatValue = stComp.floatValue; stPass_c.floatValue = stPass.floatValue; stFail_c.floatValue = stFail.floatValue; stZFail_c.floatValue = stZFail.floatValue; if (IsStencilFade) { keyModes.stencilMode = 1; GUILayout.Space(4); GUILayout.Label(Styles.FadeSttingsText, EditorStyles.boldLabel); int rmf = (int)ReadMaskF.floatValue; { EditorGUI.BeginChangeCheck(); { rmf = EditorGUILayout.IntField(Styles.ReadMaskFText, rmf); if (rmf < 0) { rmf = 0; } else if (rmf > 255) { rmf = 255; } } if (EditorGUI.EndChangeCheck()) { ReadMaskF.floatValue = rmf; } m_MaterialEditor.ShaderProperty(stFade, Styles.stFadeText); } } else { keyModes.stencilMode = 0; } }
private void DoMatCap(MaterialEditor _materialEditor) { if (!BeginGroup("MatCap")) return; if (DoKeyword(_materialEditor, m_MatCapOn, "Use MatCap")) { _materialEditor.TextureProperty(m_MatCapTex, "MatCap"); _materialEditor.ShaderProperty(m_MapCapIntensity, "MatCap Intensity"); DoKeyword(_materialEditor, m_MatCapPlanarOn, "MatCap Planar"); DoKeyword(_materialEditor, m_MatCapAlbedoOn, "MatCap Albedo"); } EndGroup(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.ShaderProperty(startTime, "Start Time"); m_MaterialEditor.ShaderProperty(disSpeed, "Dissolve Speed"); m_MaterialEditor.ShaderProperty(duration, "Duration"); 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); } EditorGUILayout.Space(); m_MaterialEditor.ShaderProperty(vertexColor, "Vertex Color"); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
private void DoGeneral(MaterialEditor _materialEditor) { if (!BeginGroup("General")) return; _materialEditor.TextureProperty(m_MainTex, "Main Texture (RGB)"); _materialEditor.TextureProperty(m_BayerTex, "Differ Matrix"); _materialEditor.ShaderProperty(m_FadeOut, "Fade Out"); DoKeyword(_materialEditor, m_TextureFadeOutOn, "Fade Out (Tex Alpha)"); if (DoKeyword(_materialEditor, m_IrradianceOn, "Use Irradiance")) { _materialEditor.ShaderProperty(m_IrradianceBoost, "Irradiance Boost"); } DoKeyword(_materialEditor, m_DarkenBackfacesOn, "Use Darken Backfaces"); if (DoKeyword (_materialEditor, m_DimOn, "Use Dim Texture")) { _materialEditor.TextureProperty (m_DimTex, "Dim Texture (RGB)"); } EndGroup(); }
} //end onGUI public void ShaderPropertiesGUI(Material material, MaterialProperty[] props) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { Color bCol = GUI.backgroundColor; GUI.backgroundColor = new Color(0.9f, 1.0f, 0.9f, 0.9f); GUI.backgroundColor = bCol; //=============================================================================================== EditorGUILayout.BeginVertical("Button"); /////////////////////////////////////////////////// MAIN GUILayout.Label(Titles.mainMapsText, EditorStyles.boldLabel); // show/hide block if (true) //_MainShown.floatValue==1) { { Color col = GUI.color; GUI.color = new Color(1.0f, 0.0f, 0.0f, 1f); Rect rect = GUILayoutUtility.GetLastRect(); rect.x += EditorGUIUtility.currentViewWidth - 50; EditorGUI.BeginChangeCheck(); float nval = EditorGUI.Foldout(rect, _MainShown.floatValue == 1, "") ? 1 : 0; if (EditorGUI.EndChangeCheck()) { _MainShown.floatValue = nval; } GUI.color = col; } if (_MainShown.floatValue == 1) //------------------------------ready to reveal parameters { GUILayout.Label(Titles.globalHeaderText, EditorStyles.boldLabel); m_MaterialEditor.RangeProperty(overallIntensity, "Fade Out Effects on Material"); m_MaterialEditor.TexturePropertySingleLine(Titles.maskText, maskMap); m_MaterialEditor.TextureScaleOffsetProperty(maskMap); GUILayout.Space(25); GUILayout.Label(Titles.mainHeaderText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Titles.baseMapText, baseMap, baseMapColor); m_MaterialEditor.TexturePropertySingleLine(Titles.baseNormal1Text, normalMain1, normalMainPOW); m_MaterialEditor.TexturePropertySingleLine(Titles.specMapText, baseGlossMap, baseGlossColor); if (baseGlossMap.textureValue == null) { m_MaterialEditor.ShaderProperty(mainGloss, "Smoothness", 2); } m_MaterialEditor.ShaderProperty(mainNormalBlendChoice, "Choose Normal Channel", 2); m_MaterialEditor.ShaderProperty(mainNormalMultiplier, "Blend Tile Multiplier", 2); m_MaterialEditor.ShaderProperty(mainNormalDetailBlend, "Blend Normals Amount", 2); m_MaterialEditor.TextureScaleOffsetProperty(baseMap); //m_MaterialEditor.RangeProperty (mainGloss, "Main Smoothness"); //albedoMap2.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake } EditorGUILayout.EndVertical(); ///////////////////////////////////////////////////////////////// //=============================================================================================== EditorGUILayout.Space(); //=============================================================================================== EditorGUILayout.BeginVertical("Button"); ////////////////////////////////////////////////// TOP GUI.backgroundColor = bCol; GUILayout.Label(Titles.topMapsText, EditorStyles.boldLabel); // show/hide block if (true) { Color col = GUI.color; GUI.color = new Color(1.0f, 1.0f, 0f, 1f); Rect rect = GUILayoutUtility.GetLastRect(); rect.x += EditorGUIUtility.currentViewWidth - 47; EditorGUI.BeginChangeCheck(); float nval = EditorGUI.Foldout(rect, _TopShown.floatValue == 1, "") ? 1 : 0; if (EditorGUI.EndChangeCheck()) { _TopShown.floatValue = nval; } GUI.color = col; } if (_TopShown.floatValue == 1) { //====================================================================Actual properties to dislay EditorGUILayout.BeginVertical("box"); m_MaterialEditor.ShaderProperty(topDirection, "Top direction"); m_MaterialEditor.RangeProperty(topGlossAmount, "Top Smoothness"); m_MaterialEditor.RangeProperty(topLevel, "Top Level"); m_MaterialEditor.RangeProperty(topDepth, "Top Depth"); EditorGUILayout.EndVertical(); GUILayout.Space(10); m_MaterialEditor.TexturePropertySingleLine(Titles.topMapText, topBase, topColor); m_MaterialEditor.RangeProperty(topBlendAlbedo, "Top Albedo Multiply"); m_MaterialEditor.TexturePropertySingleLine(Titles.topNormal1Text, topNorm, topNormPOW); m_MaterialEditor.ShaderProperty(topNormBlendChoice, "Normal Blend Channel"); m_MaterialEditor.ShaderProperty(topDetailMultiplier, "Tile Normal Channel"); m_MaterialEditor.RangeProperty(topBlendNorm, "Blend Top Normals"); m_MaterialEditor.TextureScaleOffsetProperty(topBase); GUILayout.Space(10); //=============================================================================================== EditorGUILayout.BeginVertical("Button"); /////////////////////////////////////////////////// TOP MASK GUILayout.Label(Titles.topMapMaskText, EditorStyles.boldLabel); // show/hide block if (true) { Color col = GUI.color; GUI.color = new Color(1.0f, 0.0f, 0.0f, 1f); Rect rect = GUILayoutUtility.GetLastRect(); rect.x += EditorGUIUtility.currentViewWidth - 57; EditorGUI.BeginChangeCheck(); float nval = EditorGUI.Foldout(rect, _Mask1Shown.floatValue == 1, "") ? 1 : 0; if (EditorGUI.EndChangeCheck()) { _Mask1Shown.floatValue = nval; } GUI.color = col; } if (_Mask1Shown.floatValue == 1) { m_MaterialEditor.ShaderProperty(topMaskChoice, "Top Mask Channel 1"); m_MaterialEditor.ShaderProperty(showTopMask, "Visualize Mask"); m_MaterialEditor.ShaderProperty(topMaskDepth, "Mask Depth"); m_MaterialEditor.ShaderProperty(topMaskIntensityDepth, "Intensity Depth"); m_MaterialEditor.ShaderProperty(topMaskTiling, "Mask 1 Tiling"); GUILayout.Space(10); m_MaterialEditor.ShaderProperty(topMaskChoice2, "Top Mask Channel 2"); m_MaterialEditor.ShaderProperty(topMaskTiling2, "Mask 2 Tiling"); m_MaterialEditor.ShaderProperty(topMaskBlendStyle, "Blend Style"); m_MaterialEditor.ShaderProperty(topMask2BlendAmount, "Blend Amount"); m_MaterialEditor.ShaderProperty(topMaskDepth2, "2nd Mask Depth"); m_MaterialEditor.ShaderProperty(topMaskIntensityDepth2, "2nd Intensity Depth"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); ///////////////////////////////////////////////////////////////// END TOP MASK } EditorGUILayout.EndVertical(); /////////////////////////////////////////////////////// END TOP //=============================================================================================== EditorGUILayout.Space(); //=============================================================================================== EditorGUILayout.BeginVertical("Button"); ////////////////////////////////////////////////// SNOW GUI.backgroundColor = bCol; GUILayout.Label(Titles.snowMapsText, EditorStyles.boldLabel); // show/hide block if (true) { Color col = GUI.color; GUI.color = new Color(1.0f, 1.0f, 0f, 1f); Rect rect = GUILayoutUtility.GetLastRect(); rect.x += EditorGUIUtility.currentViewWidth - 47; EditorGUI.BeginChangeCheck(); float nval = EditorGUI.Foldout(rect, _SnowShown.floatValue == 1, "") ? 1 : 0; //float nval =EditorGUILayout.ToggleLeft (Titles.snowMapsText, _SnowShown.floatValue == 1, EditorStyles.boldLabel) ? 1 : 0; if (EditorGUI.EndChangeCheck()) { _SnowShown.floatValue = nval; } GUI.color = col; } if (_SnowShown.floatValue == 1) { //====================================================================Actual properties to dislay EditorGUILayout.BeginVertical("box"); m_MaterialEditor.ShaderProperty(snowDisplace, "Vertex Snow Displacement?"); m_MaterialEditor.ShaderProperty(snowDirection, "Snow direction"); m_MaterialEditor.RangeProperty(snowGlossAmount, "Smoothness"); m_MaterialEditor.RangeProperty(snowLevel, "Snow Level"); m_MaterialEditor.RangeProperty(snowDepth, "Snow Depth"); EditorGUILayout.EndVertical(); GUILayout.Space(10); m_MaterialEditor.TexturePropertySingleLine(Titles.snowMapText, snowBase, snowColor); m_MaterialEditor.TexturePropertySingleLine(Titles.snowNormal1Text, snowNorm, snowNormPOW); m_MaterialEditor.TexturePropertySingleLine(Titles.snowNormal2Text, snowNorm2); m_MaterialEditor.RangeProperty(snowBlendNorm, "Blend Normals"); m_MaterialEditor.TexturePropertySingleLine(Titles.snowspecMapText, snowGlossMap, snowGlossTiling); m_MaterialEditor.TextureScaleOffsetProperty(snowBase); GUILayout.Space(10); //=============================================================================================== EditorGUILayout.BeginVertical("Button"); /////////////////////////////////////////////////// SNOW MASK GUILayout.Label(Titles.snowMapMaskText, EditorStyles.boldLabel); // show/hide block if (true) { Color col = GUI.color; GUI.color = new Color(1.0f, 0.0f, 0.0f, 1f); Rect rect = GUILayoutUtility.GetLastRect(); rect.x += EditorGUIUtility.currentViewWidth - 57; EditorGUI.BeginChangeCheck(); float nval = EditorGUI.Foldout(rect, _SnowMaskShown.floatValue == 1, "") ? 1 : 0; if (EditorGUI.EndChangeCheck()) { _SnowMaskShown.floatValue = nval; } GUI.color = col; } if (_SnowMaskShown.floatValue == 1) { //====================================================== Now show parameters m_MaterialEditor.ShaderProperty(snowMaskChoice, "Snow Mask Channel 1"); m_MaterialEditor.ShaderProperty(showSnowMask, "Visualize Snow Mask"); m_MaterialEditor.ShaderProperty(snowMaskDepth, "Main Mask Depth"); m_MaterialEditor.ShaderProperty(snowMaskIntensityDepth, "Intensity Depth"); m_MaterialEditor.ShaderProperty(snowMaskTiling, "1st Mask Tiling"); GUILayout.Space(10); m_MaterialEditor.ShaderProperty(snowMaskChoice2, "Snow Mask Channel 2"); m_MaterialEditor.ShaderProperty(snowMaskTiling2, "2nd Mask Tiling"); m_MaterialEditor.ShaderProperty(snowMaskBlendStyle, "Blend Style"); m_MaterialEditor.ShaderProperty(snowMask2BlendAmount, "Blend Amount"); m_MaterialEditor.ShaderProperty(snowMaskDepth2, "2nd Mask Depth"); m_MaterialEditor.ShaderProperty(snowMaskIntensityDepth2, "2nd Intensity Depth"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); ///////////////////////////////////////////////////////////////// END SNOW MASK } EditorGUILayout.EndVertical(); /////////////////////////////////////////////////////// END SNOW //=============================================================================================== } ///END BeginChangeCheck if (EditorGUI.EndChangeCheck()) { // } } //end ShaderPropertiesGUI
public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] props) { // get the current keywords from the material Material targetMat = materialEditor.target as Material; string[] keyWords = targetMat.shaderKeywords; bool parallax = keyWords.Contains ("_PARALLAXMAP"); int layerCount = 1; if (targetMat.shader.name == "VertexPainter/SplatBlend_2Layer") layerCount = 2; else if (targetMat.shader.name == "VertexPainter/SplatBlend_3Layer") layerCount = 3; else if (targetMat.shader.name == "VertexPainter/SplatBlend_4Layer") layerCount = 4; else if (targetMat.shader.name == "VertexPainter/SplatBlend_5Layer") layerCount = 5; FlowChannel fchannel = FlowChannel.None; if (keyWords.Contains("_FLOW1")) fchannel = FlowChannel.One; if (keyWords.Contains("_FLOW2")) fchannel = FlowChannel.Two; if (keyWords.Contains("_FLOW3")) fchannel = FlowChannel.Three; if (keyWords.Contains("_FLOW4")) fchannel = FlowChannel.Four; if (keyWords.Contains("_FLOW5")) fchannel = FlowChannel.Five; bool flowDrift = keyWords.Contains("_FLOWDRIFT"); bool hasGloss = (HasTexture(layerCount, targetMat, "_GlossinessTex")); bool hasEmis = (HasTexture(layerCount, targetMat, "_Emissive")); EditorGUI.BeginChangeCheck(); int oldLayerCount = layerCount; layerCount = EditorGUILayout.IntField("Layer Count", layerCount); if (oldLayerCount != layerCount) { if (layerCount < 1) layerCount = 1; if (layerCount > 5) layerCount = 5; targetMat.shader = Shader.Find("VertexPainter/SplatBlend_" + layerCount + "Layer"); return; } parallax = EditorGUILayout.Toggle ("Parallax Offset", parallax); for (int i = 0; i < layerCount; ++i) { DrawLayer(materialEditor, i+1, props, keyWords, hasGloss, parallax, hasEmis); EditorGUILayout.Space(); } EditorGUILayout.Space(); fchannel = (FlowChannel)EditorGUILayout.Popup((int)fchannel, flowChannelNames); if (fchannel != FlowChannel.None) { var flowSpeed = FindProperty("_FlowSpeed", props); var flowIntensity = FindProperty("_FlowIntensity", props); materialEditor.ShaderProperty(flowSpeed, "Flow Speed"); materialEditor.ShaderProperty(flowIntensity, "Flow Intensity"); flowDrift = EditorGUILayout.Toggle("Flow Drift", flowDrift); } if (EditorGUI.EndChangeCheck()) { var newKeywords = new List<string>(); newKeywords.Add("_LAYERS" + layerCount.ToString()); if (parallax) { newKeywords.Add("_PARALLAXMAP"); } if (HasTexture(layerCount, targetMat, "_Normal")) { newKeywords.Add("_NORMALMAP"); } if (hasGloss) { newKeywords.Add("_METALLICGLOSSMAP"); } if (hasEmis) { newKeywords.Add("_EMISSION"); } if (fchannel != FlowChannel.None) { newKeywords.Add("_FLOW" + (int)fchannel); } if (flowDrift) { newKeywords.Add("_FLOWDRIFT"); } targetMat.shaderKeywords = newKeywords.ToArray (); EditorUtility.SetDirty (targetMat); } }
public void ShaderPropertiesGUI(Material material) { EditorGUI.BeginChangeCheck(); { EditorGUIUtility.fieldWidth = 64f; InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Color"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(shallowWaterColor, "Shallow Water Color"); mMatEditor.ShaderProperty(deepWaterColor, "Deep Water Color"); mMatEditor.ShaderProperty(edgeBlend, "Edge Blend"); mMatEditor.ShaderProperty(waterDepth, "Water Depth"); mMatEditor.ShaderProperty(underWaterOpacity, "Surface Opacity Under Water "); mMatEditor.ShaderProperty(smoothness, "Smoothness"); mMatEditor.ShaderProperty(cubeMapLevel, "Cube Map Color Tint"); mMatEditor.TexturePropertySingleLine(new GUIContent("Cube Map"), cube); }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Fresnel"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(fresnelPower, "Fresnel Power"); mMatEditor.ShaderProperty(fresnelBias, "Fresnel Bias"); }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Specular"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(specularToggle, "Enable Specular Reflection"); if (specularToggle.floatValue == 1) { mMatEditor.ShaderProperty(specularColor, "Specular Color"); mMatEditor.ShaderProperty(shininess, "Shininess"); mMatEditor.ShaderProperty(worldLightDir, "World Light Dir"); } }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Distortion"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(distortion, "Distortion"); mMatEditor.ShaderProperty(bumpTiling, "Bump Tiling"); mMatEditor.ShaderProperty(bumpDirection, "Bump Direction"); mMatEditor.TexturePropertySingleLine(new GUIContent("Bump Map"), bumpMap); }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Foam"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(foamToggle, "Enable Foam"); if (foamToggle.floatValue == 1) { mMatEditor.ShaderProperty(foamColor, "Foam Color"); mMatEditor.TexturePropertySingleLine(new GUIContent("Foam Texture"), foamTex); mMatEditor.TexturePropertySingleLine(new GUIContent("Foam Gradient"), foamGradient); mMatEditor.ShaderProperty(foamStrength, "Foam Strength"); } }); EditorGUILayout.Separator(); InspectorBox(10, () => { EditorGUILayout.LabelField(new GUIContent("Normals"), EditorStyles.boldLabel); mMatEditor.ShaderProperty(normals, "Normals"); mMatEditor.ShaderProperty(normalsStrength, "Bump Strength"); }); } }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { m_MaterialEditor.ShaderProperty(unlit, Styles.unlitText.text); bool bUnlit = (unlit.floatValue != 0.0f); BlendModePopup(); if (!bUnlit) { SpecularModePopup(); } EditorGUILayout.Space(); //GUILayout.Label( Styles.primaryMapsText, EditorStyles.boldLabel ); DoAlbedoArea(material); if (!bUnlit) { m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); DoSpecularMetallicArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); if (occlusionMap.textureValue != null) { m_MaterialEditor.ShaderProperty(occlusionStrengthDirectDiffuse, Styles.occlusionStrengthDirectDiffuseText.text, 2); m_MaterialEditor.ShaderProperty(occlusionStrengthDirectSpecular, Styles.occlusionStrengthDirectSpecularText.text, 2); m_MaterialEditor.ShaderProperty(occlusionStrengthIndirectDiffuse, Styles.occlusionStrengthIndirectDiffuseText.text, 2); m_MaterialEditor.ShaderProperty(occlusionStrengthIndirectSpecular, Styles.occlusionStrengthIndirectSpecularText.text, 2); } m_MaterialEditor.ShaderProperty(cubeMapScalar, Styles.cubeMapScalarText.text, 0); } //m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); if (!bUnlit) { m_MaterialEditor.TexturePropertySingleLine(Styles.overrideLightmapText, overrideLightmap); } EditorGUI.BeginChangeCheck(); // !!! AV - This is from Unity's script. Can these Begin/End calls be nested like this? 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 } if (worldAlignedTexture != null) { m_MaterialEditor.ShaderProperty(worldAlignedTexture, Styles.worldAlignedTextureText.text); if (worldAlignedTexture.floatValue != 0.0f) { EditorGUI.indentLevel = 2; Vector3GUI(Styles.worldAlignedTextureSizeText, worldAlignedTextureSize); Vector3GUI(Styles.worldAlignedTextureNormalText, worldAlignedTextureNormal); Vector3GUI(Styles.worldAlignedTexturePositionText, worldAlignedTexturePosition); EditorGUI.indentLevel = 0; } } EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); if (!bUnlit) { m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); } m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj); } foreach (var obj in specularMode.targets) { MaterialChanged((Material)obj); } } }
bool ImmediateProperty(string name, MaterialEditor materialEditor, MaterialProperty[] props) { EditorGUI.BeginChangeCheck(); var p = FindProperty(name, props); if(p.type == MaterialProperty.PropType.Texture) materialEditor.TexturePropertySingleLine(new GUIContent(p.displayName), p); else materialEditor.ShaderProperty(p, p.displayName); return EditorGUI.EndChangeCheck(); }