Added translaprent support
This commit is contained in:
@@ -2,18 +2,22 @@ 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 transparentMode;
|
||||
public static MaterialProperty surfaceType;
|
||||
public static MaterialProperty fogOnTransparent;
|
||||
|
||||
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;
|
||||
@@ -24,12 +28,14 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static readonly GUIContent transparentModeText = new("Transparent Mode", "Enable different modes that allow the simulation of a variety of transparent objects.");
|
||||
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 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.");
|
||||
@@ -44,56 +50,53 @@ namespace Misaki.HdrpToon.Editor
|
||||
|
||||
public override void LoadMaterialProperties()
|
||||
{
|
||||
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
||||
Properties.surfaceType = FindProperty(SURFACE_TYPE);
|
||||
Properties.fogOnTransparent = FindProperty(FOG_ON_TRANSPARENT);
|
||||
|
||||
Properties.alphaClipEnable = FindProperty("_AlphaCutoffEnable");
|
||||
Properties.alphaClip = FindProperty("_AlphaCutoff");
|
||||
Properties.alphaClipEnable = FindProperty(ALPHA_CLIP_ENABLE);
|
||||
Properties.alphaClip = FindProperty(ALPHA_CUTOFF);
|
||||
Properties.cullMode = FindProperty(CULL_MODE);
|
||||
Properties.doubleSidedNormalMode = FindProperty(DOUBLE_SIDED_NORMAL_MODE);
|
||||
|
||||
Properties.cullMode = FindProperty("_CullMode");
|
||||
Properties.shadingMode = FindProperty("_Shading_Mode");
|
||||
Properties.materialType = FindProperty("_Material_Type");
|
||||
Properties.pbrMode = FindProperty("_PBR_Mode");
|
||||
Properties.shadingMode = FindProperty(SHADING_MODE);
|
||||
Properties.materialType = FindProperty(MATERIAL_TYPE);
|
||||
Properties.pbrMode = FindProperty(PBR_MODE);
|
||||
|
||||
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
||||
Properties.surfaceFeatures = FindProperty("_SurfaceFeatures");
|
||||
Properties.hairBlendingTarget = FindProperty(HAIR_BLENDING_TARGET);
|
||||
Properties.surfaceFeatures = FindProperty(SURFACE_FEATURE);
|
||||
}
|
||||
|
||||
protected override void DrawContent()
|
||||
{
|
||||
editor.ShaderProperty(Properties.transparentMode, Styles.transparentModeText);
|
||||
editor.ShaderProperty(Properties.surfaceType, Styles.transparentModeText);
|
||||
using (new EditorGUI.IndentLevelScope())
|
||||
{
|
||||
if (Properties.surfaceType.GetBooleanValue())
|
||||
{
|
||||
editor.ShaderProperty(Properties.fogOnTransparent, Styles.fogOnTransparentText);
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
using var s = new EditorGUI.IndentLevelScope();
|
||||
editor.ShaderProperty(Properties.alphaClip, Styles.alphaClipText);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.cullMode, Styles.cullingModeText);
|
||||
editor.ShaderProperty(Properties.shadingMode, Styles.shadingModeText);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
editor.ShaderProperty(Properties.materialType, Styles.materialTypeText);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, Properties.materialType.GetEnumValue<MaterialType>() == MaterialType.FrontHair);
|
||||
}
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.pbrMode, Styles.pbrModeText);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
editor.ShaderProperty(Properties.hairBlendingTarget, Styles.hairBlendingTargetText);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
foreach (var material in materials)
|
||||
{
|
||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.GetBooleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
editor.ShaderProperty(Properties.surfaceFeatures, Styles.surfaceFeaturesText);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user