|
|
|
|
|
|
public static GUIContent AlbedoModeText = new GUIContent("Albedo contribution", "Base color + Blend, Blend only"); |
|
|
|
} |
|
|
|
|
|
|
|
enum NormalPerPixelBlendSource |
|
|
|
{ |
|
|
|
AlbedoMapAlpha, |
|
|
|
MaskMapBlue |
|
|
|
} |
|
|
|
protected string[] normalPerPixelBlendSourceNames = Enum.GetNames(typeof(NormalPerPixelBlendSource)); |
|
|
|
|
|
|
|
enum MaskPerPixelBlendSource |
|
|
|
{ |
|
|
|
Zero, |
|
|
|
AlbedoMapAlpha, |
|
|
|
MaskMapBlue |
|
|
|
} |
|
|
|
protected string[] maskPerPixelBlendSourceNames = Enum.GetNames(typeof(MaskPerPixelBlendSource)); |
|
|
|
|
|
|
|
protected MaterialProperty baseColorMap = new MaterialProperty(); |
|
|
|
protected const string kBaseColorMap = "_BaseColorMap"; |
|
|
|
|
|
|
|
|
|
|
protected MaterialProperty albedoMode = new MaterialProperty(); |
|
|
|
protected const string kAlbedoMode = "_AlbedoMode"; |
|
|
|
|
|
|
|
protected MaterialProperty normalPerPixelBlend = new MaterialProperty(); |
|
|
|
protected const string kNormalPerPixelBlend = "_NormalPerPixelBlend"; |
|
|
|
protected MaterialProperty metalnessPerPixelBlend = new MaterialProperty(); |
|
|
|
protected const string kMetalnessPerPixelBlend = "_MetalnessPerPixelBlend"; |
|
|
|
|
|
|
|
protected MaterialProperty AOPerPixelBlend = new MaterialProperty(); |
|
|
|
protected const string kAOPerPixelBlend = "_AOPerPixelBlend"; |
|
|
|
|
|
|
|
protected MaterialProperty smoothnessPerPixelBlend = new MaterialProperty(); |
|
|
|
protected const string kSmoothnessPerPixelBlend = "_SmoothnessPerPixelBlend"; |
|
|
|
|
|
|
|
|
|
|
|
protected MaterialEditor m_MaterialEditor; |
|
|
|
|
|
|
|
// This is call by the inspector
|
|
|
|
|
|
|
maskMap = FindProperty(kMaskMap, props); |
|
|
|
decalBlend = FindProperty(kDecalBlend, props); |
|
|
|
albedoMode = FindProperty(kAlbedoMode, props); |
|
|
|
normalPerPixelBlend = FindProperty(kNormalPerPixelBlend, props); |
|
|
|
metalnessPerPixelBlend = FindProperty(kMetalnessPerPixelBlend, props); |
|
|
|
AOPerPixelBlend = FindProperty(kAOPerPixelBlend, props); |
|
|
|
smoothnessPerPixelBlend = FindProperty(kSmoothnessPerPixelBlend, props); |
|
|
|
// always instanced
|
|
|
|
SerializedProperty instancing = m_MaterialEditor.serializedObject.FindProperty("m_EnableInstancingVariants"); |
|
|
|
instancing.boolValue = true; |
|
|
|
|
|
|
{ |
|
|
|
// Use default labelWidth
|
|
|
|
EditorGUIUtility.labelWidth = 0f; |
|
|
|
float normalPerPixelBlendValue = normalPerPixelBlend.floatValue; |
|
|
|
float metalnessPerPixelBlendValue = metalnessPerPixelBlend.floatValue; |
|
|
|
float AOPerPixelBlendValue = AOPerPixelBlend.floatValue; |
|
|
|
float smoothnessPerPixelBlendValue = smoothnessPerPixelBlend.floatValue; |
|
|
|
EditorGUI.showMixedValue = normalPerPixelBlend.hasMixedValue; |
|
|
|
// Detect any changes to the material
|
|
|
|
EditorGUI.BeginChangeCheck(); |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText2, baseColorMap, baseColor); |
|
|
|
} |
|
|
|
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap); |
|
|
|
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap); |
|
|
|
normalPerPixelBlendValue = EditorGUILayout.Popup( "Normal Per Pixel Blend", (int)normalPerPixelBlendValue, normalPerPixelBlendSourceNames); |
|
|
|
metalnessPerPixelBlendValue = EditorGUILayout.Popup( "Metalness Per Pixel Blend", (int)metalnessPerPixelBlendValue, maskPerPixelBlendSourceNames); |
|
|
|
smoothnessPerPixelBlendValue = EditorGUILayout.Popup( "Smoothness Per Pixel Blend", (int)smoothnessPerPixelBlendValue, maskPerPixelBlendSourceNames); |
|
|
|
EditorGUILayout.Space(); |
|
|
|
AOPerPixelBlendValue = EditorGUILayout.Popup( "AO Per Pixel Blend", (int)AOPerPixelBlendValue, maskPerPixelBlendSourceNames); |
|
|
|
EditorGUILayout.Space(); |
|
|
|
m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText); |
|
|
|
EditorGUI.indentLevel--; |
|
|
|
} |
|
|
|
|
|
|
m_MaterialEditor.RegisterPropertyChangeUndo( "Normal Per Pixel Blend"); |
|
|
|
normalPerPixelBlend.floatValue = normalPerPixelBlendValue; |
|
|
|
m_MaterialEditor.RegisterPropertyChangeUndo( "Metalness Per Pixel Blend"); |
|
|
|
metalnessPerPixelBlend.floatValue = metalnessPerPixelBlendValue; |
|
|
|
m_MaterialEditor.RegisterPropertyChangeUndo( "AO Per Pixel Blend"); |
|
|
|
AOPerPixelBlend.floatValue = AOPerPixelBlendValue; |
|
|
|
m_MaterialEditor.RegisterPropertyChangeUndo( "Smoothness Per Pixel Blend"); |
|
|
|
smoothnessPerPixelBlend.floatValue = smoothnessPerPixelBlendValue; |
|
|
|
EditorGUI.showMixedValue = false; |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) |
|
|
|