Skip to content

Commit

Permalink
Merge pull request #54 from Santarh/refactoringInspector
Browse files Browse the repository at this point in the history
Refactor Lighting inspector panel
  • Loading branch information
Santarh authored May 24, 2019
2 parents 999899e + f0316ba commit f825847
Showing 1 changed file with 41 additions and 25 deletions.
66 changes: 41 additions & 25 deletions MToon/Editor/MToonInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace MToon
{
public class MToonInspector : ShaderGUI
{
private static bool isAdvancedLightingPanelFoldout = false;

private MaterialProperty _blendMode;
private MaterialProperty _bumpMap;
private MaterialProperty _bumpScale;
Expand Down Expand Up @@ -145,36 +147,11 @@ private void Draw(MaterialEditor materialEditor, Material[] materials)
EditorGUILayout.LabelField("Lighting", EditorStyles.boldLabel);
EditorGUILayout.BeginVertical(GUI.skin.box);
{
EditorGUILayout.LabelField("Lit & Shade Mixing", EditorStyles.boldLabel);
{
materialEditor.ShaderProperty(_shadeShift,
new GUIContent("Shading Shift",
"Zero is Default. Negative value increase lit area. Positive value increase shade area."));
materialEditor.ShaderProperty(_shadeToony,
new GUIContent("Shading Toony",
"0.0 is Lambert. Higher value get toony shading."));
materialEditor.TexturePropertySingleLine(
new GUIContent("Shadow Receive Multiplier",
"Texture (A) * Rate. White is Default. Black attenuates shadows."),
_receiveShadowTexture,
_receiveShadowRate);
materialEditor.TexturePropertySingleLine(
new GUIContent("Lit & Shade Mixing Multiplier",
"Texture (R) * Rate. Compatible with UTS2 ShadingGradeMap. White is Default. Black amplifies shade."),
_shadingGradeTexture,
_shadingGradeRate);
}
EditorGUILayout.Space();

EditorGUILayout.LabelField("Light Color", EditorStyles.boldLabel);
{
materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation");
materialEditor.ShaderProperty(_indirectLightIntensity, "GI Intensity");
}
EditorGUILayout.Space();

EditorGUILayout.LabelField("Normal", EditorStyles.boldLabel);
{
// Normal
EditorGUI.BeginChangeCheck();
materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map [Normal]", "Normal Map (RGB)"),
Expand All @@ -186,6 +163,45 @@ private void Draw(MaterialEditor materialEditor, Material[] materials)
ModeChanged(materials);
}
}
EditorGUILayout.Space();

EditorGUI.indentLevel++;
{
isAdvancedLightingPanelFoldout = EditorGUILayout.Foldout(isAdvancedLightingPanelFoldout, "Advanced Settings", EditorStyles.boldFont);

if (isAdvancedLightingPanelFoldout)
{
if (materialEditor.HelpBoxWithButton(
new GUIContent(
"The default settings are suitable for Advanced Settings if you want to toony result."),
new GUIContent("Reset")))
{
_shadeShift.floatValue = 0;
_receiveShadowTexture.textureValue = null;
_receiveShadowRate.floatValue = 1;
_shadingGradeTexture.textureValue = null;
_shadingGradeRate.floatValue = 1;
_lightColorAttenuation.floatValue = 0;
_indirectLightIntensity.floatValue = 0.1f;
}
materialEditor.ShaderProperty(_shadeShift,
new GUIContent("Shading Shift",
"Zero is Default. Negative value increase lit area. Positive value increase shade area."));
materialEditor.TexturePropertySingleLine(
new GUIContent("Shadow Receive Multiplier",
"Texture (A) * Rate. White is Default. Black attenuates shadows."),
_receiveShadowTexture,
_receiveShadowRate);
materialEditor.TexturePropertySingleLine(
new GUIContent("Lit & Shade Mixing Multiplier",
"Texture (R) * Rate. Compatible with UTS2 ShadingGradeMap. White is Default. Black amplifies shade."),
_shadingGradeTexture,
_shadingGradeRate);
materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation");
materialEditor.ShaderProperty(_indirectLightIntensity, "GI Intensity");
}
}
EditorGUI.indentLevel--;
}
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
Expand Down

0 comments on commit f825847

Please sign in to comment.