115 lines
5.9 KiB
C#
115 lines
5.9 KiB
C#
using Misaki.ShaderGUI;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Misaki.HdrpToon.Editor
|
|
{
|
|
public class AmbientScope : MaterialUIScope<ShaderGUIExpandable>
|
|
{
|
|
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Ambient;
|
|
protected override GUIContent Header => new("Ambient Settings");
|
|
|
|
private static class Properties
|
|
{
|
|
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 indirectSpecularModeText = new("Indirect Specular Mode", "Specifies indirect specular mode.");
|
|
|
|
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 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 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 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");
|
|
}
|
|
|
|
public override void LoadMaterialProperties()
|
|
{
|
|
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);
|
|
editor.ShaderProperty(Properties.indirectSpecularMode, Styles.indirectSpecularModeText);
|
|
|
|
var indirectDiffuseMode = Properties.indirectDiffuseMode.GetEnumValue<IndirectDiffuseMode>();
|
|
var indirectSpecularMode = Properties.indirectSpecularMode.GetEnumValue<IndirectSpecularMode>();
|
|
|
|
if (indirectDiffuseMode != IndirectDiffuseMode.Off)
|
|
{
|
|
EditorGUILayout.Space();
|
|
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
|
|
{
|
|
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
|
|
}
|
|
|
|
if (indirectDiffuseMode == IndirectDiffuseMode.Matcap)
|
|
{
|
|
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
|
|
}
|
|
|
|
editor.ShaderProperty(Properties.indirectDiffuseIntensity, Styles.indirectDiffuseIntensityText);
|
|
editor.ShaderProperty(Properties.ssaoWeight, Styles.ssaoWeightText);
|
|
|
|
if (indirectDiffuseMode == IndirectDiffuseMode.IBL)
|
|
{
|
|
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
|
|
}
|
|
}
|
|
|
|
if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
|
|
{
|
|
EditorGUILayout.Space();
|
|
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
|
|
{
|
|
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
|
|
}
|
|
|
|
if (indirectSpecularMode == IndirectSpecularMode.Matcap)
|
|
{
|
|
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);
|
|
}
|
|
|
|
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
|
|
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
|
|
}
|
|
}
|
|
}
|
|
} |