public static void DoClearCoat(LitProperties properties, MaterialEditor materialEditor, Material material) { var coatEnabled = ClearCoatEnabled(material); EditorGUI.BeginChangeCheck(); EditorGUI.Toggle(EditorGUILayout.GetControlRect(), Styles.clearCoatText, coatEnabled); if (EditorGUI.EndChangeCheck()) { if (coatEnabled) { material.SetFloat("_ClearCoat", 0); // Toggle off } else { material.SetFloat("_ClearCoat", 1); } coatEnabled = !coatEnabled; } EditorGUI.BeginDisabledGroup(!coatEnabled); { materialEditor.TexturePropertySingleLine(Styles.clearCoatMaskText, properties.clearCoatMap, properties.clearCoatMask); EditorGUI.indentLevel += 2; // Texture and HDR color controls materialEditor.ShaderProperty(properties.clearCoatSmoothness, Styles.clearCoatSmoothnessText); EditorGUI.indentLevel -= 2; } EditorGUI.EndDisabledGroup(); }
public static void Inputs(LitProperties properties, MaterialEditor materialEditor, Material material) { DoMetallicSpecularArea(properties, materialEditor, material); BaseShaderGUI.DrawNormalArea(materialEditor, properties.bumpMapProp, properties.bumpScaleProp); if (properties.occlusionMap != null) { materialEditor.TexturePropertySingleLine(Styles.occlusionText, properties.occlusionMap, properties.occlusionMap.textureValue != null ? properties.occlusionStrength : null); } }
public static void DoDetailArea(LitProperties properties, MaterialEditor materialEditor) { materialEditor.TexturePropertySingleLine(Styles.detailMaskText, properties.detailMask); materialEditor.TexturePropertySingleLine(Styles.detailAlbedoMapText, properties.detailAlbedoMap, properties.detailAlbedoMap.textureValue != null ? properties.detailAlbedoMapScale : null); if (properties.detailAlbedoMapScale.floatValue != 1.0f) { EditorGUILayout.HelpBox(Styles.detailAlbedoMapScaleInfo.text, MessageType.Info, true); } materialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, properties.detailNormalMap, properties.detailNormalMap.textureValue != null ? properties.detailNormalMapScale : null); materialEditor.TextureScaleOffsetProperty(properties.detailAlbedoMap); }
internal static void DoClearCoat(LitProperties properties, MaterialEditor materialEditor, Material material) { materialEditor.ShaderProperty(properties.clearCoat, Styles.clearCoatText); var coatEnabled = material.GetFloat("_ClearCoat") > 0.0; EditorGUI.BeginDisabledGroup(!coatEnabled); { EditorGUI.indentLevel += 2; materialEditor.TexturePropertySingleLine(Styles.clearCoatMaskText, properties.clearCoatMap, properties.clearCoatMask); // Texture and HDR color controls materialEditor.ShaderProperty(properties.clearCoatSmoothness, Styles.clearCoatSmoothnessText); EditorGUI.indentLevel -= 2; } EditorGUI.EndDisabledGroup(); }
public static void DoClearCoat(LitProperties properties, MaterialEditor materialEditor, Material material) { materialEditor.ShaderProperty(properties.enableClearCoat, Styles.enableClearCoatText); if (properties.enableClearCoat.floatValue == 1.0) { EditorGUI.indentLevel++; bool hadClearCoatTexture = properties.clearCoatMap.textureValue != null; // Texture and HDR color controls materialEditor.TexturePropertySingleLine(Styles.clearCoatText, properties.clearCoatMap, properties.clearCoatMap.textureValue == null ? properties.clearCoat : null); bool showSmoothnessScale = hadClearCoatTexture; int indentation = 2; // align with labels of texture properties materialEditor.ShaderProperty(showSmoothnessScale ? properties.clearCoatSmoothnessScale : properties.clearCoatSmoothness, showSmoothnessScale ? Styles.clearCoatSmoothnessScaleText : Styles.clearCoatSmoothnessText, indentation); EditorGUI.indentLevel--; } }
public static void DoDetailArea(LitProperties properties, MaterialEditor materialEditor) { materialEditor.TexturePropertySingleLine(Styles.detailMaskText, properties.detailMask); materialEditor.TexturePropertySingleLine(Styles.detailAlbedoMapText, properties.detailAlbedoMap, properties.detailAlbedoMap.textureValue != null ? properties.detailAlbedoMapScale : null); if (properties.detailAlbedoMapScale.floatValue != 1.0f) { EditorGUILayout.HelpBox(Styles.detailAlbedoMapScaleInfo.text, MessageType.Info, true); } var detailAlbedoTexture = properties.detailAlbedoMap.textureValue as Texture2D; if (detailAlbedoTexture != null && GraphicsFormatUtility.IsSRGBFormat(detailAlbedoTexture.graphicsFormat)) { EditorGUILayout.HelpBox(Styles.detailAlbedoMapFormatError.text, MessageType.Warning, true); } materialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, properties.detailNormalMap, properties.detailNormalMap.textureValue != null ? properties.detailNormalMapScale : null); materialEditor.TextureScaleOffsetProperty(properties.detailAlbedoMap); }
public static void Inputs(LitProperties properties, MaterialEditor materialEditor, Material material) { DoMetallicSpecularArea(properties, materialEditor, material); BaseShaderGUI.DrawNormalArea(materialEditor, properties.bumpMapProp, properties.bumpScaleProp); if (HeightmapAvailable(material)) DoHeightmapArea(properties, materialEditor); if (properties.occlusionMap != null) { materialEditor.TexturePropertySingleLine(Styles.occlusionText, properties.occlusionMap, properties.occlusionMap.textureValue != null ? properties.occlusionStrength : null); } // Check that we have all the required properties for clear coat, // otherwise we will get null ref exception from MaterialEditor GUI helpers. if (ClearCoatAvailable(material)) DoClearCoat(properties, materialEditor, material); }
public static void DoSmoothness(LitProperties properties, Material material, string[] smoothnessChannelNames) { var opaque = ((BaseShaderGUI.SurfaceType)material.GetFloat("_Surface") == BaseShaderGUI.SurfaceType.Opaque); EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = properties.smoothness.hasMixedValue; var smoothness = EditorGUILayout.Slider(Styles.smoothnessText, properties.smoothness.floatValue, 0f, 1f); if (EditorGUI.EndChangeCheck()) { properties.smoothness.floatValue = smoothness; } EditorGUI.showMixedValue = false; if (properties.smoothnessMapChannel != null) // smoothness channel { EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(!opaque); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = properties.smoothnessMapChannel.hasMixedValue; var smoothnessSource = (int)properties.smoothnessMapChannel.floatValue; if (opaque) { smoothnessSource = EditorGUILayout.Popup(Styles.smoothnessMapChannelText, smoothnessSource, smoothnessChannelNames); } else { EditorGUILayout.Popup(Styles.smoothnessMapChannelText, 0, smoothnessChannelNames); } if (EditorGUI.EndChangeCheck()) { properties.smoothnessMapChannel.floatValue = smoothnessSource; } EditorGUI.showMixedValue = false; EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; }
public static void Inputs(LitProperties properties, MaterialEditor materialEditor, Material material) { DoMetallicSpecularArea(properties, materialEditor, material); BaseShaderGUI.DrawNormalArea(materialEditor, properties.bumpMapProp, properties.bumpScaleProp); if (properties.occlusionMap != null) { materialEditor.TexturePropertySingleLine(Styles.occlusionText, properties.occlusionMap, properties.occlusionMap.textureValue != null ? properties.occlusionStrength : null); } // Check that we have all the required properties for clear coat, // otherwise we will get null ref exception from MaterialEditor GUI helpers. if (material.HasProperty("_ClearCoat") && material.HasProperty("_ClearCoatMap") && material.HasProperty("_ClearCoatMask")) //&& material.HasProperty("_ClearCoatSmoothness")) //TODO: enable { //DoClearCoat(properties, materialEditor, material); } }
public static void DoMetallicSpecularArea(LitProperties properties, MaterialEditor materialEditor, Material material) { string[] smoothnessChannelNames; bool hasGlossMap = false; if (properties.workflowMode == null || (WorkflowMode)properties.workflowMode.floatValue == WorkflowMode.Metallic) { hasGlossMap = properties.metallicGlossMap.textureValue != null; smoothnessChannelNames = Styles.metallicSmoothnessChannelNames; materialEditor.TexturePropertySingleLine(Styles.metallicMapText, properties.metallicGlossMap, hasGlossMap ? null : properties.metallic); } else { hasGlossMap = properties.specGlossMap.textureValue != null; smoothnessChannelNames = Styles.specularSmoothnessChannelNames; BaseShaderGUI.TextureColorProps(materialEditor, Styles.specularMapText, properties.specGlossMap, hasGlossMap ? null : properties.specColor); } DoSmoothness(materialEditor, material, properties.smoothness, properties.smoothnessMapChannel, smoothnessChannelNames); }
public static void DoMRAArea(LitProperties properties, MaterialEditor materialEditor, Material material) { // show MRA (metallic, roughness, AO) materialEditor.TexturePropertySingleLine(Styles.mraMapText, properties.mraMap); bool enableMRAMap = properties.mraMap.textureValue != null; int indentLevel = MaterialEditor.kMiniTextureFieldLabelIndentLevel; EditorGUI.indentLevel += indentLevel; { if (enableMRAMap) { materialEditor.ShaderProperty(properties.metallicMapScale, Styles.metallicMapScaleText); materialEditor.ShaderProperty(properties.roughnessMapScale, Styles.roughnessMapScaleText); } else { materialEditor.ShaderProperty(properties.metallic, Styles.metallicText); materialEditor.ShaderProperty(properties.roughness, Styles.roughnessText); } materialEditor.ShaderProperty(properties.occlusionStrength, Styles.occlusionStrengthText); } EditorGUI.indentLevel -= indentLevel; }
private static void DoHeightmapArea(LitProperties properties, MaterialEditor materialEditor) { materialEditor.TexturePropertySingleLine(Styles.heightMapText, properties.parallaxMapProp, properties.parallaxMapProp.textureValue != null ? properties.parallaxScaleProp : null); }
// 自定义布局 static void DoLayerArea(LitProperties properties, MaterialEditor materialEditor, Material material) { materialEditor.TexturePropertySingleLine(Styles.layer0NormalText, properties.layer0Normal, properties.layer0NormalScale); if (material.GetTexture("_Layer0Normal")) { materialEditor.TextureScaleOffsetProperty(properties.layer0Normal); } materialEditor.TexturePropertySingleLine(Styles.layer1TexText, properties.layer1Tex); if (material.GetTexture("_Layer1Tex")) { TextureLayout(materialEditor, Styles.layer1NormalText, properties.layer1Normal, properties.layer1NormalScale); TextureLayout(materialEditor, Styles.layer1MaskText, properties.layer1Mask); materialEditor.TextureScaleOffsetProperty(properties.layer1Tex); materialEditor.ShaderProperty(properties.layer1Color, Styles.layer1ColorText.text, 2); materialEditor.ShaderProperty(properties.layer1Smoothness, Styles.layer1SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer1Metallic, Styles.layer1MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer1UVSet, Styles.layer1UVSetText.text, 2); } else { material.SetTexture("_Layer1Normal", null); material.SetTexture("_Layer1Mask", null); } materialEditor.TexturePropertySingleLine(Styles.layer2TexText, properties.layer2Tex); if (material.GetTexture("_Layer2Tex")) { TextureLayout(materialEditor, Styles.layer2NormalText, properties.layer2Normal, properties.layer2NormalScale); TextureLayout(materialEditor, Styles.layer2MaskText, properties.layer2Mask); materialEditor.TextureScaleOffsetProperty(properties.layer2Tex); materialEditor.ShaderProperty(properties.layer2Color, Styles.layer2ColorText.text, 2); materialEditor.ShaderProperty(properties.layer2Smoothness, Styles.layer2SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer2Metallic, Styles.layer2MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer2UVSet, Styles.layer2UVSetText.text, 2); } else { material.SetTexture("_Layer2Normal", null); material.SetTexture("_Layer2Mask", null); } materialEditor.TexturePropertySingleLine(Styles.layer3TexText, properties.layer3Tex); if (material.GetTexture("_Layer3Tex")) { TextureLayout(materialEditor, Styles.layer3NormalText, properties.layer3Normal, properties.layer3NormalScale); TextureLayout(materialEditor, Styles.layer3MaskText, properties.layer3Mask); materialEditor.TextureScaleOffsetProperty(properties.layer3Tex); materialEditor.ShaderProperty(properties.layer3Color, Styles.layer3ColorText.text, 2); materialEditor.ShaderProperty(properties.layer3Smoothness, Styles.layer3SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer3Metallic, Styles.layer3MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer3UVSet, Styles.layer3UVSetText.text, 2); } else { material.SetTexture("_Layer3Normal", null); material.SetTexture("_Layer3Mask", null); } materialEditor.TexturePropertySingleLine(Styles.layer4TexText, properties.layer4Tex); if (material.GetTexture("_Layer4Tex")) { TextureLayout(materialEditor, Styles.layer4NormalText, properties.layer4Normal, properties.layer4NormalScale); TextureLayout(materialEditor, Styles.layer4MaskText, properties.layer4Mask); materialEditor.TextureScaleOffsetProperty(properties.layer4Tex); materialEditor.ShaderProperty(properties.layer4Color, Styles.layer4ColorText.text, 2); materialEditor.ShaderProperty(properties.layer4Smoothness, Styles.layer4SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer4Metallic, Styles.layer4MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer4UVSet, Styles.layer4UVSetText.text, 2); } else { material.SetTexture("_Layer4Normal", null); material.SetTexture("_Layer4Mask", null); } materialEditor.TexturePropertySingleLine(Styles.layer5TexText, properties.layer5Tex); if (material.GetTexture("_Layer5Tex")) { TextureLayout(materialEditor, Styles.layer5NormalText, properties.layer5Normal, properties.layer5NormalScale); TextureLayout(materialEditor, Styles.layer5MaskText, properties.layer5Mask); materialEditor.TextureScaleOffsetProperty(properties.layer5Tex); materialEditor.ShaderProperty(properties.layer5Color, Styles.layer5ColorText.text, 2); materialEditor.ShaderProperty(properties.layer5Smoothness, Styles.layer5SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer5Metallic, Styles.layer5MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer5UVSet, Styles.layer5UVSetText.text, 2); } else { material.SetTexture("_Layer5Normal", null); material.SetTexture("_Layer5Mask", null); } materialEditor.TexturePropertySingleLine(Styles.layer6TexText, properties.layer6Tex); if (material.GetTexture("_Layer6Tex")) { TextureLayout(materialEditor, Styles.layer6NormalText, properties.layer6Normal, properties.layer6NormalScale); TextureLayout(materialEditor, Styles.layer6MaskText, properties.layer6Mask); materialEditor.TextureScaleOffsetProperty(properties.layer6Tex); materialEditor.ShaderProperty(properties.layer6Color, Styles.layer6ColorText.text, 2); materialEditor.ShaderProperty(properties.layer6Smoothness, Styles.layer6SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer6Metallic, Styles.layer6MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer6UVSet, Styles.layer6UVSetText.text, 2); } else { material.SetTexture("_Layer6Normal", null); material.SetTexture("_Layer6Mask", null); } materialEditor.TexturePropertySingleLine(Styles.layer7TexText, properties.layer7Tex); if (material.GetTexture("_Layer7Tex")) { TextureLayout(materialEditor, Styles.layer7NormalText, properties.layer7Normal, properties.layer7NormalScale); TextureLayout(materialEditor, Styles.layer7MaskText, properties.layer7Mask); materialEditor.TextureScaleOffsetProperty(properties.layer7Tex); materialEditor.ShaderProperty(properties.layer7Color, Styles.layer7ColorText.text, 2); materialEditor.ShaderProperty(properties.layer7Smoothness, Styles.layer7SmoothnessText.text, 2); materialEditor.ShaderProperty(properties.layer7Metallic, Styles.layer7MetallicText.text, 2); materialEditor.ShaderProperty(properties.layer7UVSet, Styles.layer7UVSetText.text, 2); } else { material.SetTexture("_Layer7Normal", null); material.SetTexture("_Layer7Mask", null); } }
public static void Inputs(LitProperties properties, MaterialEditor materialEditor, Material material) { DoMetallicSpecularArea(properties, materialEditor, material); }
public static void Inputs(LitProperties properties, MaterialEditor materialEditor, Material material) { DoMRAArea(properties, materialEditor, material); BaseShaderGUI.DrawNormalArea(materialEditor, properties.bumpMapProp, properties.bumpScaleProp); }