Added new stocking surface feature; Added unity 6.3 support; Fixed the issue that ssr weight does not blend ibl and ssr properly; Fixed the issue that material recive ssr regardless of specular ambient mode;
129 lines
7.7 KiB
C#
129 lines
7.7 KiB
C#
using Misaki.ShaderGUI;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
using static Misaki.HdrpToon.UTSPropertyName.SurfaceOptions;
|
|
|
|
namespace Misaki.HdrpToon.Editor
|
|
{
|
|
internal class SurfaceOptionsScope : MaterialUIScope<ShaderGUIExpandable>
|
|
{
|
|
private static class Properties
|
|
{
|
|
public static MaterialProperty surfaceType;
|
|
|
|
public static MaterialProperty fogOnTransparent;
|
|
public static MaterialProperty transparentDepthPrepassEnable;
|
|
public static MaterialProperty transparentDepthPostpassEnable;
|
|
public static MaterialProperty transparentBackfaceEnable;
|
|
public static MaterialProperty transparentZWrite;
|
|
public static MaterialProperty receivesSSRTransparent;
|
|
public static MaterialProperty transparentWritingMotionVec;
|
|
|
|
public static MaterialProperty alphaClipEnable;
|
|
public static MaterialProperty alphaClip;
|
|
public static MaterialProperty cullMode;
|
|
public static MaterialProperty doubleSidedNormalMode;
|
|
|
|
public static MaterialProperty shadingMode;
|
|
public static MaterialProperty materialType;
|
|
public static MaterialProperty pbrMode;
|
|
|
|
public static MaterialProperty hairBlendingTarget;
|
|
public static MaterialProperty surfaceFeatures;
|
|
}
|
|
|
|
private static class Styles
|
|
{
|
|
public static readonly GUIContent transparentModeText = new("Surface Type", "Controls the surface type of the material.");
|
|
public static readonly GUIContent fogOnTransparentText = new("Fog On Transparent", "Enable to apply fog effect on transparent objects.");
|
|
public static readonly GUIContent transparentDepthPrepassEnableText = new("Depth Prepass", "Enable to perform a depth prepass for transparent objects.");
|
|
public static readonly GUIContent transparentDepthPostpassEnableText = new("Depth Postpass", "Enable to perform a depth postpass for transparent objects.");
|
|
public static readonly GUIContent transparentBackfaceEnableText = new("Back Then Front Rendering", "Enable to render the back faces of transparent objects first, then the front faces.");
|
|
public static readonly GUIContent transparentZWriteText = new("Depth Write", "Enable to write depth for transparent objects. This is useful for correct depth testing with other transparent objects.");
|
|
public static readonly GUIContent receivesSSRTransparentText = new("Receives SSR", "Enable to allow transparent objects to receive Screen Space Reflections (SSR).");
|
|
public static readonly GUIContent transparentWritingMotionVec = new("Motion Vectors Write", "Enable to write motion vectors for transparent objects.");
|
|
|
|
public static readonly GUIContent alphaClipEnableText = new("Alpha Clipping", "Enable alpha clipping.");
|
|
public static readonly GUIContent alphaClipText = new("Alpha Clipping Threshold", "Threshold for alpha clipping.");
|
|
public static readonly GUIContent cullingModeText = new("Culling Mode", "Controls the sides of polygons that should not be drawn (culled).");
|
|
public static readonly GUIContent doubleSidedNormalModeText = new("Double Sided Mode", "Controls the normal mode for double-sided rendering.");
|
|
|
|
public static readonly GUIContent shadingModeText = new("Shading Color Mode", "Specifies the shading grade mode.");
|
|
public static readonly GUIContent materialTypeText = new("Material Type", "Specifies the material type.");
|
|
public static readonly GUIContent pbrModeText = new("PBR Mode", "Specifies PBR model mode.");
|
|
|
|
public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
|
|
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
|
|
}
|
|
|
|
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
|
|
|
|
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
|
|
|
protected override void LoadMaterialProperties()
|
|
{
|
|
Properties.surfaceType = FindProperty(SURFACE_TYPE);
|
|
|
|
Properties.fogOnTransparent = FindProperty(FOG_ON_TRANSPARENT);
|
|
Properties.transparentDepthPrepassEnable = FindProperty(TRANSPARENT_DEPTH_PREPASS_ENABLE);
|
|
Properties.transparentDepthPostpassEnable = FindProperty(TRANSPARENT_DEPTH_POSTPASS_ENABLE);
|
|
Properties.transparentBackfaceEnable = FindProperty(TRANSPARENT_BACKFACE_ENABLE);
|
|
Properties.transparentZWrite = FindProperty(TRANSPARENT_Z_WRITE);
|
|
Properties.receivesSSRTransparent = FindProperty(RECEIVES_SSR_TRANSPARENT);
|
|
Properties.transparentWritingMotionVec = FindProperty(TRANSPARENT_WRITING_MOTION_VEC);
|
|
|
|
Properties.alphaClipEnable = FindProperty(ALPHA_CLIP_ENABLE);
|
|
Properties.alphaClip = FindProperty(ALPHA_CUTOFF);
|
|
Properties.cullMode = FindProperty(CULL_MODE);
|
|
Properties.doubleSidedNormalMode = FindProperty(DOUBLE_SIDED_NORMAL_MODE);
|
|
|
|
Properties.shadingMode = FindProperty(SHADING_MODE);
|
|
Properties.materialType = FindProperty(MATERIAL_TYPE);
|
|
Properties.pbrMode = FindProperty(PBR_MODE);
|
|
|
|
Properties.hairBlendingTarget = FindProperty(HAIR_BLENDING_TARGET);
|
|
Properties.surfaceFeatures = FindProperty(SURFACE_FEATURE);
|
|
}
|
|
|
|
protected override void DrawContent()
|
|
{
|
|
editor.ShaderProperty(Properties.surfaceType, Styles.transparentModeText);
|
|
using (new EditorGUI.IndentLevelScope())
|
|
{
|
|
if (Properties.surfaceType.GetBooleanValue())
|
|
{
|
|
editor.ShaderProperty(Properties.fogOnTransparent, Styles.fogOnTransparentText);
|
|
editor.ShaderProperty(Properties.transparentDepthPrepassEnable, Styles.transparentDepthPrepassEnableText);
|
|
editor.ShaderProperty(Properties.transparentDepthPostpassEnable, Styles.transparentDepthPostpassEnableText);
|
|
editor.ShaderProperty(Properties.transparentBackfaceEnable, Styles.transparentBackfaceEnableText);
|
|
editor.ShaderProperty(Properties.transparentZWrite, Styles.transparentZWriteText);
|
|
editor.ShaderProperty(Properties.receivesSSRTransparent, Styles.receivesSSRTransparentText);
|
|
editor.ShaderProperty(Properties.transparentWritingMotionVec, Styles.transparentWritingMotionVec);
|
|
}
|
|
|
|
editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText);
|
|
if (Properties.cullMode.intValue == 0)
|
|
{
|
|
using (new EditorGUI.IndentLevelScope())
|
|
{
|
|
editor.ShaderProperty(Properties.doubleSidedNormalMode, Styles.doubleSidedNormalModeText);
|
|
}
|
|
}
|
|
}
|
|
|
|
editor.ShaderProperty(Properties.alphaClipEnable, Styles.alphaClipEnableText);
|
|
if (Properties.alphaClipEnable.GetBooleanValue())
|
|
{
|
|
using var s = new EditorGUI.IndentLevelScope();
|
|
editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText);
|
|
}
|
|
|
|
editor.ShaderProperty(Properties.shadingMode, Styles.shadingModeText);
|
|
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
|
|
editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText);
|
|
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
|
|
editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
|
|
}
|
|
}
|
|
} |