Added AmbientScope;
This commit is contained in:
113
Editor/MeterialEditor/UIScopes/AmbientScope.cs
Normal file
113
Editor/MeterialEditor/UIScopes/AmbientScope.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using Misaki.ShaderGUI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class AmbientScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AmbientMode;
|
||||
protected override GUIContent Header => new("Ambient Settings");
|
||||
|
||||
private static class Properties
|
||||
{
|
||||
public static MaterialProperty IndirectDiffuseMode;
|
||||
public static MaterialProperty IndirectDiffuseIntensity;
|
||||
public static MaterialProperty IndirectSpecularMode;
|
||||
public static MaterialProperty IndirectReflectionIntensity;
|
||||
public static MaterialProperty EnableSSAO;
|
||||
public static MaterialProperty SSAOFactor;
|
||||
public static MaterialProperty EnableSSGI;
|
||||
public static MaterialProperty SSGIFactor;
|
||||
public static MaterialProperty EnableSSR;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent IndirectDiffuseModeText =
|
||||
new("Indirect Diffuse Mode", "Specifies indirect diffuse mode.");
|
||||
|
||||
public static readonly GUIContent IndirectDiffuseIntensityText =
|
||||
new("Indirect Diffuse Intensity",
|
||||
"The Environment Light color is added to the material color according to the GI Intensity value.");
|
||||
|
||||
public static readonly GUIContent IndirectSpecularModeText =
|
||||
new("Indirect Specular Mode", "Specifies indirect specular mode.");
|
||||
|
||||
public static readonly GUIContent IndirectReflectionIntensityText =
|
||||
new("Indirect Reflection Intensity",
|
||||
"The Environment Light color is added to the material color according to the GI Intensity value.");
|
||||
|
||||
public static readonly GUIContent EnableSSAOText = new("Enable SSAO", "Enable SSAO.");
|
||||
public static readonly GUIContent SSAOFactorText = new("SSAO Factor", "The weight of SSAO.");
|
||||
public static readonly GUIContent EnableSSGIText = new("Enable SSGI", "Enable SSGI.");
|
||||
public static readonly GUIContent SSGIFactorText = new("SSGI Factor", "The weight of SSGI.");
|
||||
public static readonly GUIContent EnableSSRText = new("Enable SSR", "Enable SSR.");
|
||||
}
|
||||
|
||||
private readonly string[] _indirectDiffuseModeDefines =
|
||||
{ "_INDIRECT_DIFFUSE_OFF", "_INDIRECT_DIFFUSE_IBL", "_INDIRECT_DIFFUSE_MATCAP", "_INDIRECT_DIFFUSE_RAMP" };
|
||||
|
||||
private readonly string[] _indirectSpecularModeDefines =
|
||||
{ "_INDIRECT_SPECULAR_OFF", "_INDIRECT_SPECULAR_IBL", "_INDIRECT_SPECULAR_MATCAP" };
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.IndirectDiffuseMode = FindProperty("_Indirect_Diffuse_Mode");
|
||||
Properties.IndirectDiffuseIntensity = FindProperty("_ID_Intensity");
|
||||
Properties.IndirectSpecularMode = FindProperty("_Indirect_Specular_Mode");
|
||||
Properties.IndirectReflectionIntensity = FindProperty("_IR_Intensity");
|
||||
Properties.EnableSSAO = FindProperty("_ReceivesSSAO");
|
||||
Properties.SSAOFactor = FindProperty("_AO_Factor");
|
||||
Properties.EnableSSGI = FindProperty("_ReceivesSSGI");
|
||||
Properties.SSGIFactor = FindProperty("_GI_Factor");
|
||||
Properties.EnableSSR = FindProperty("_ReceivesSSR");
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.IndirectDiffuseMode, Styles.IndirectDiffuseModeText);
|
||||
for (int i = 0; i < _indirectDiffuseModeDefines.Length; i++)
|
||||
{
|
||||
editor.SetKeyword(_indirectDiffuseModeDefines[i], Properties.IndirectDiffuseMode.intValue == i);
|
||||
}
|
||||
|
||||
if (Properties.IndirectDiffuseMode.intValue != 0)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.IndirectDiffuseIntensity, Styles.IndirectDiffuseIntensityText);
|
||||
editor.ShaderProperty(Properties.EnableSSAO, Styles.EnableSSAOText);
|
||||
if (Properties.EnableSSAO.floatValue > 0)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.SSAOFactor, Styles.SSAOFactorText);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.EnableSSGI, Styles.EnableSSGIText);
|
||||
if (Properties.EnableSSGI.floatValue > 0)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.SSGIFactor, Styles.SSGIFactorText);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.IndirectSpecularMode, Styles.IndirectSpecularModeText);
|
||||
for (int i = 0; i < _indirectSpecularModeDefines.Length; i++)
|
||||
{
|
||||
editor.SetKeyword(_indirectSpecularModeDefines[i], Properties.IndirectSpecularMode.intValue == i);
|
||||
}
|
||||
|
||||
if (Properties.IndirectSpecularMode.intValue != 0)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.IndirectReflectionIntensity, Styles.IndirectReflectionIntensityText);
|
||||
editor.ShaderProperty(Properties.EnableSSR, Styles.EnableSSRText);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/MeterialEditor/UIScopes/AmbientScope.cs.meta
Normal file
3
Editor/MeterialEditor/UIScopes/AmbientScope.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f3997bcef824e5a9bd3728830006bd1
|
||||
timeCreated: 1738419718
|
||||
Reference in New Issue
Block a user