Improve AmbientScope and OutlineScope
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Misaki.HdrpToon.Editor
|
||||
Shadow = 1 << 2,
|
||||
MaterialFeature = 1 << 3,
|
||||
SurfaceInputs = 1 << 4,
|
||||
AmbientMode = 1 << 5,
|
||||
Ambient = 1 << 5,
|
||||
Highlight = 1 << 6,
|
||||
Rimlight = 1 << 7,
|
||||
MatCap = 1 << 8,
|
||||
|
||||
@@ -6,106 +6,110 @@ namespace Misaki.HdrpToon.Editor
|
||||
{
|
||||
public class AmbientScope : MaterialUIScope<ShaderGUIExpandable>
|
||||
{
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AmbientMode;
|
||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Ambient;
|
||||
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;
|
||||
public static MaterialProperty indirectDiffuseMode;
|
||||
public static MaterialProperty indirectSpecularMode;
|
||||
|
||||
public static MaterialProperty indirectDiffuseMatCapMap;
|
||||
public static MaterialProperty indirectDiffuseMatCapLod;
|
||||
|
||||
public static MaterialProperty indirectDiffuseIntensity;
|
||||
public static MaterialProperty ssaoWeight;
|
||||
public static MaterialProperty ssgiWeight;
|
||||
|
||||
public static MaterialProperty indirectSpecularMatCapMap;
|
||||
public static MaterialProperty indirectSpecularMatCapLod;
|
||||
|
||||
public static MaterialProperty indirectReflectionIntensity;
|
||||
public static MaterialProperty ssrWeight;
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent IndirectDiffuseModeText =
|
||||
new("Indirect Diffuse Mode", "Specifies indirect diffuse mode.");
|
||||
public static readonly GUIContent indirectDiffuseModeText = new("Indirect Diffuse Mode", "Specifies indirect diffuse mode.");
|
||||
public static readonly GUIContent indirectSpecularModeText = new("Indirect Specular Mode", "Specifies indirect specular 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 indirectDiffuseMatCapMapText = new("MatCap Map", "The material capture map for indirect diffuse evaluation, with the additional setting for controlling the LOD offset when sampling the indirect diffuse material capture map.");
|
||||
|
||||
public static readonly GUIContent IndirectSpecularModeText =
|
||||
new("Indirect Specular Mode", "Specifies indirect specular mode.");
|
||||
public static readonly GUIContent indirectDiffuseIntensityText = new("Intensity", "The indirect diffuse color is added to the material color according to the intensity value.");
|
||||
public static readonly GUIContent ssaoWeightText = new("SSAO Weight", "The weight of SSAO.");
|
||||
public static readonly GUIContent ssgiWeightText = new("SSGI Weight", "The weight of SSGI.");
|
||||
|
||||
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 indirectSpecularMatCapMapText = new("MatCap Map", "The material capture map for indirect specular evaluation, with the additional setting for controlling the LOD offset when sampling the indirect specular material capture map.");
|
||||
|
||||
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.");
|
||||
public static readonly GUIContent indirectReflectionIntensityText = new("Intensity", "The indirect reflection color is added to the material color according to the intensity value.");
|
||||
public static readonly GUIContent ssrWeightText = new("SSR Weight", "SSR Weight");
|
||||
}
|
||||
|
||||
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");
|
||||
Properties.indirectDiffuseMode = FindProperty("_Indirect_Diffuse_Mode");
|
||||
Properties.indirectSpecularMode = FindProperty("_Indirect_Specular_Mode");
|
||||
|
||||
Properties.indirectDiffuseMatCapMap = FindProperty("_IndirectDiffuseMatCapMap");
|
||||
Properties.indirectDiffuseMatCapLod = FindProperty("_IndirectDiffuseMatCapLod");
|
||||
|
||||
Properties.indirectDiffuseIntensity = FindProperty("_IndirectDiffuseIntensity");
|
||||
Properties.ssaoWeight = FindProperty("_SSAOWeight");
|
||||
Properties.ssgiWeight = FindProperty("_SSGIWeight");
|
||||
|
||||
Properties.indirectSpecularMatCapMap = FindProperty("_IndirectSpecularMatCapMap");
|
||||
Properties.indirectSpecularMatCapLod = FindProperty("_IndirectSpecularMatCapLod");
|
||||
|
||||
Properties.indirectReflectionIntensity = FindProperty("_IndirectSpecularIntensity");
|
||||
Properties.ssrWeight = FindProperty("_SSRWeight");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
editor.ShaderProperty(Properties.indirectDiffuseMode, Styles.indirectDiffuseModeText);
|
||||
editor.ShaderProperty(Properties.indirectSpecularMode, Styles.indirectSpecularModeText);
|
||||
|
||||
if (Properties.IndirectDiffuseMode.intValue != 0)
|
||||
var indirectDiffuseMode = Properties.indirectDiffuseMode.GetEnumValue<IndirectDiffuseMode>();
|
||||
var indirectSpecularMode = Properties.indirectSpecularMode.GetEnumValue<IndirectSpecularMode>();
|
||||
|
||||
if (indirectDiffuseMode != IndirectDiffuseMode.Off)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.IndirectDiffuseIntensity, Styles.IndirectDiffuseIntensityText);
|
||||
editor.ShaderProperty(Properties.EnableSSAO, Styles.EnableSSAOText);
|
||||
if (Properties.EnableSSAO.floatValue > 0)
|
||||
|
||||
if (indirectDiffuseMode == IndirectDiffuseMode.Matcap)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.SSAOFactor, Styles.SSAOFactorText);
|
||||
EditorGUI.indentLevel--;
|
||||
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.EnableSSGI, Styles.EnableSSGIText);
|
||||
if (Properties.EnableSSGI.floatValue > 0)
|
||||
editor.ShaderProperty(Properties.indirectDiffuseIntensity, Styles.indirectDiffuseIntensityText);
|
||||
editor.ShaderProperty(Properties.ssaoWeight, Styles.ssaoWeightText);
|
||||
|
||||
if (indirectDiffuseMode == IndirectDiffuseMode.IBL)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.SSGIFactor, Styles.SSGIFactorText);
|
||||
EditorGUI.indentLevel--;
|
||||
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.IndirectSpecularMode, Styles.IndirectSpecularModeText);
|
||||
for (int i = 0; i < _indirectSpecularModeDefines.Length; i++)
|
||||
if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
|
||||
{
|
||||
editor.SetKeyword(_indirectSpecularModeDefines[i], Properties.IndirectSpecularMode.intValue == i);
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
|
||||
|
||||
if (Properties.IndirectSpecularMode.intValue != 0)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
editor.ShaderProperty(Properties.IndirectReflectionIntensity, Styles.IndirectReflectionIntensityText);
|
||||
editor.ShaderProperty(Properties.EnableSSR, Styles.EnableSSRText);
|
||||
|
||||
if (indirectSpecularMode == IndirectSpecularMode.Matcap)
|
||||
{
|
||||
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
|
||||
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static MaterialProperty outlineColor;
|
||||
public static MaterialProperty outlineColorMap;
|
||||
public static MaterialProperty albedoAffectOutline;
|
||||
public static MaterialProperty skyColorAffectOutline;
|
||||
public static MaterialProperty skyColorIntensity;
|
||||
|
||||
public static MaterialProperty fadeIn;
|
||||
public static MaterialProperty fadeOut;
|
||||
@@ -26,6 +28,9 @@ namespace Misaki.HdrpToon.Editor
|
||||
public static readonly GUIContent outlineWidthText = new("Outline Width", "Specifies the width of the outline.");
|
||||
public static readonly GUIContent outlineColorText = new("Outline Color", "Specifies the color of the outline.");
|
||||
public static readonly GUIContent albedoAffectOutlineText = new("Albedo Affect Outline", "Enable to affect the outline color with the albedo color.");
|
||||
public static readonly GUIContent skyColorAffectOutlineText = new("Sky Color Affect Outline", "Enable to affect the outline color with the sky color.");
|
||||
public static readonly GUIContent skyColorIntensityText = new("Sky Color Intensity", "The intensity of the sky color when add to the outline color.");
|
||||
|
||||
public static readonly GUIContent fadeInText = new("Fade In Distance", "Specify the nearest distance, where the outline width changes with the distance between the camera and the object. The outline will be the maximum width at this distance.");
|
||||
public static readonly GUIContent fadeOutText = new("Fade Out Distance", "Specify the furthest distance, where the outline width changes with the distance between the camera and the object. The outline will be zero at this distance.");
|
||||
public static readonly GUIContent useSmoothedNormalText = new("Use Smoothed Normal", "Enable to use smoothed normal(that packed in uv2) for outline calculation.");
|
||||
@@ -45,6 +50,8 @@ namespace Misaki.HdrpToon.Editor
|
||||
Properties.outlineColor = FindProperty("_OutlineColor");
|
||||
Properties.outlineColorMap = FindProperty("_OutlineColorMap");
|
||||
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
|
||||
Properties.skyColorAffectOutline = FindProperty("_SkyColorAffectOutline");
|
||||
Properties.skyColorIntensity = FindProperty("_SkyColorIntensity");
|
||||
|
||||
Properties.fadeIn = FindProperty("_OutlineFadeIn");
|
||||
Properties.fadeOut = FindProperty("_OutlineFadeOut");
|
||||
@@ -57,9 +64,16 @@ namespace Misaki.HdrpToon.Editor
|
||||
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
|
||||
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
|
||||
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
|
||||
editor.ShaderProperty(Properties.skyColorAffectOutline, Styles.skyColorAffectOutlineText);
|
||||
if (Properties.skyColorAffectOutline.GetBooleanValue())
|
||||
{
|
||||
editor.ShaderProperty(Properties.skyColorIntensity, Styles.skyColorIntensityText);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
editor.ShaderProperty(Properties.fadeIn, Styles.fadeInText);
|
||||
editor.ShaderProperty(Properties.fadeOut, Styles.fadeOutText);
|
||||
editor.ShaderProperty(Properties.useSmoothedNormal, Styles.useSmoothedNormalText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user