[Add] All in one shader

This commit is contained in:
2026-02-23 22:01:07 +07:00
parent ec0aa86ac2
commit 4f942cd7c0
806 changed files with 401510 additions and 33 deletions
@@ -0,0 +1,339 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public abstract class AbstractEffectDrawer
{
private const float HEIGHT_PER_LINE = 12.5f;
protected string drawerID;
protected PropertiesConfig propertiesConfig;
protected AllIn13DEffectConfig effectConfig;
protected AllIn13DShaderInspectorReferences references;
protected int globalEffectIndex;
public string ID
{
get
{
return drawerID;
}
}
public AbstractEffectDrawer(AllIn13DShaderInspectorReferences references, PropertiesConfig propertiesConfig)
{
this.references = references;
this.propertiesConfig = propertiesConfig;
}
public void Draw(PropertiesConfig propertiesConfig, AllIn13DEffectConfig effectConfig, int globalEffectIndex)
{
this.propertiesConfig = propertiesConfig;
this.effectConfig = effectConfig;
this.globalEffectIndex = globalEffectIndex;
Draw();
}
protected virtual void Draw()
{
bool isShaderVariant = references.IsShaderVariant();
bool areDependenciesMet = AreDependenciesMet();
bool isEffectAvailableOnGlobalConfig = references.effectsProfileCollection.generalProfile.IsEffectEnabled(effectConfig.effectName);
bool isEffectAvailable = AllIn13DEffectConfig.IsEffectAvailable(effectConfig, references);
bool groupEnabled = isEffectAvailable;
if (!isShaderVariant)
{
groupEnabled = groupEnabled && areDependenciesMet && isEffectAvailableOnGlobalConfig;
}
//bool groupEnabled = areDependenciesMet && isEffectAvailable && isEffectAvailableOnGlobalConfig /*|| (references.isShaderVariant && isEnabledInEffectsProfile)*/;
//bool disableGroup = !groupEnabled;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginDisabledGroup(!groupEnabled);
EffectPropertyDrawer.DrawMainProperty(globalEffectIndex, effectConfig, references, isEffectAvailable, isEffectAvailableOnGlobalConfig);
EditorGUILayout.EndHorizontal();
bool isAnyPropertyVisible = IsAnyPropertyVisible();
if (isAnyPropertyVisible)
{
EditorGUILayout.BeginVertical(references.propertiesStyle);
DrawExtraData();
DrawProperties();
EditorGUILayout.EndVertical();
}
EditorGUI.EndDisabledGroup();
}
private void DrawExtraData()
{
if (IsParentPropertyEnabled())
{
string customMessage = effectConfig.GetCustomMessage(references.targetMatInfos);
if (!string.IsNullOrEmpty(customMessage))
{
EditorGUILayout.BeginHorizontal();
int numLines = EditorUtils.GetNumLines(customMessage);
float heightField = numLines * HEIGHT_PER_LINE;
if (!string.IsNullOrEmpty(effectConfig.docURL))
{
if (GUILayout.Button("?", GUILayout.Width(heightField), GUILayout.Height(heightField)))
{
Application.OpenURL(effectConfig.docURL);
}
}
EditorGUILayout.LabelField(customMessage, references.smallLabelStyle, GUILayout.Height(heightField));
EditorGUILayout.EndHorizontal();
}
}
}
protected virtual void DrawProperties()
{
for (int i = 0; i < effectConfig.effectProperties.Count; i++)
{
EffectProperty effectProperty = effectConfig.effectProperties[i];
DrawProperty(effectProperty, string.Empty, true);
}
}
protected virtual void DrawProperty(EffectProperty effectProperty)
{
DrawProperty(effectProperty, true);
}
protected virtual void DrawProperty(EffectProperty effectProperty, bool allowReset)
{
DrawProperty(effectProperty, string.Empty, allowReset);
}
protected virtual void DrawProperty(EffectProperty effectProperty, string labelPrefix, bool allowReset)
{
if (IsEffectPropertyVisible(effectProperty, references.targetMatInfos))
{
EffectProperty.PropertyType propertyType = effectProperty.GetPropertyType();
MaterialProperty matProperty = references.matProperties[effectProperty.propertyIndex];
string propertyCustomValue = string.Empty;
if(references.IsShaderVariant() && effectProperty.IsPropertyWithKeywords())
{
int index = 0;
bool isEnabled = references.IsEffectPropertyEnabled(effectProperty, ref index);
if (isEnabled)
{
if (effectProperty.IsEnumProperty())
{
propertyCustomValue = effectProperty.propertyKeywords[index];
}
else
{
propertyCustomValue = string.Empty;
}
}
}
EffectPropertyDrawer.DrawProperty(
materialProperty: matProperty,
labelPrefix: labelPrefix,
displayName: effectProperty.displayName,
customValue: propertyCustomValue,
allowReset: allowReset,
isKeywordProperty: effectProperty.IsPropertyWithKeywords(),
propertyType: effectProperty.GetPropertyType(),
references: references);
//EffectPropertyDrawer.DrawProperty(effectProperty, labelPrefix, effectProperty.displayName, allowReset, effectProperty.IsPropertyWithKeywords(), references);
//EffectPropertyDrawer.DrawProperty(effectProperty, labelPrefix, allowReset, references);
}
}
protected bool IsParentPropertyEnabled()
{
bool res = true;
for (int matIdx = 0; matIdx < references.targetMatInfos.Length; matIdx++)
{
AbstractMaterialInfo targetMatInfo = references.targetMatInfos[matIdx];
bool thisMatParentPropertyEnabled = false;
for (int kwIdx = 0; kwIdx < effectConfig.keywords.Count; kwIdx++)
{
string kw = effectConfig.keywords[kwIdx].keyword;
if (targetMatInfo.IsKeywordEnabled(kw))
{
thisMatParentPropertyEnabled = true;
break;
}
}
res = res && thisMatParentPropertyEnabled;
}
return res;
}
protected bool IsAnyPropertyVisible()
{
bool res = false;
bool parentPropertyEnabled = IsParentPropertyEnabled();
if (parentPropertyEnabled)
{
for (int propIdx = 0; propIdx < effectConfig.effectProperties.Count; propIdx++)
{
EffectProperty effectProperty = effectConfig.effectProperties[propIdx];
res = IsEffectPropertyVisible(effectProperty, references.targetMatInfos);
if (res)
{
break;
}
}
}
res = res || (parentPropertyEnabled && !string.IsNullOrEmpty(effectConfig.GetCustomMessage(references.targetMatInfos)));
return res;
}
protected bool IsEffectPropertyVisible(EffectProperty effectProperty, AbstractMaterialInfo[] targetMatInfos)
{
bool res = true;
for (int i = 0; i < targetMatInfos.Length; i++)
{
res = res && IsEffectPropertyVisible(effectProperty, targetMatInfos[i]);
}
return res;
}
protected bool IsEffectPropertyVisible(EffectProperty effectProperty, AbstractMaterialInfo targetMatInfo)
{
bool res = false;
bool anyIncompatibilities = false;
for (int i = 0; i < effectProperty.incompatibleKeywords.Count; i++)
{
string incompatibleKw = effectProperty.incompatibleKeywords[i];
if (targetMatInfo.IsKeywordEnabled(incompatibleKw))
{
anyIncompatibilities = true;
}
}
if (!anyIncompatibilities)
{
if (effectProperty.keywordsOp == KeywordsOp.OR)
{
for (int i = 0; i < effectProperty.keywords.Count; i++)
{
string keyword = effectProperty.keywords[i];
if (targetMatInfo.IsKeywordEnabled(keyword))
{
res = true;
break;
}
}
}
else
{
res = true;
for (int i = 0; i < effectProperty.keywords.Count; i++)
{
string keyword = effectProperty.keywords[i];
if (!targetMatInfo.IsKeywordEnabled(keyword))
{
res = false;
break;
}
}
}
}
return res;
}
protected MaterialProperty FindPropertyByName(string propertyName)
{
MaterialProperty res = null;
for (int i = 0; i < references.matProperties.Length; i++)
{
if (references.matProperties[i].name == propertyName)
{
res = references.matProperties[i];
break;
}
}
return res;
}
protected int FindPropertyIndex(string propertyName)
{
int res = -1;
for (int i = 0; i < references.matProperties.Length; i++)
{
if (references.matProperties[i].name == propertyName)
{
res = i;
break;
}
}
return res;
}
protected bool AreDependenciesMet()
{
bool res = true;
if (!string.IsNullOrEmpty(effectConfig.dependentOnEffect))
{
AllIn13DEffectConfig dependentEffect = propertiesConfig.FindEffectConfigByID(effectConfig.dependentOnEffect);
res = res && AllIn13DEffectConfig.IsEffectEnabled(dependentEffect, references);
}
if (!string.IsNullOrEmpty(effectConfig.incompatibleWithEffectID))
{
AllIn13DEffectConfig dependentEffect = propertiesConfig.FindEffectConfigByID(effectConfig.incompatibleWithEffectID);
res = res && !AllIn13DEffectConfig.IsEffectEnabled(dependentEffect, references);
}
return res;
}
protected bool IsShaderVariant()
{
bool res = true;
for(int i = 0; i < references.targetMatInfos.Length; i++)
{
if (references.targetMatInfos[i].IsShaderVariant())
{
res = false;
break;
}
}
return res;
}
public virtual void Refresh(AllIn13DShaderInspectorReferences references)
{
this.references = references;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1fc7c21ef6e0e8b4c9333a9fdd7a4bb6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/AbstractEffectDrawer.cs
uploadId: 865720
@@ -0,0 +1,43 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class AllIn13DShaderGradientDrawer : MaterialPropertyDrawer
{
private GradientEditorDrawer gradientEditorDrawer;
private void RefreshReferences(MaterialProperty prop)
{
if(gradientEditorDrawer == null)
{
gradientEditorDrawer = new GradientEditorDrawer();
}
}
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
RefreshReferences(prop);
Texture texValue = prop.textureValue;
EditorGUI.BeginChangeCheck();
Texture newTex = gradientEditorDrawer.Draw(position, texValue);
if (EditorGUI.EndChangeCheck())
{
prop.textureValue = newTex;
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
float res = 0f;
if(gradientEditorDrawer != null)
{
res = gradientEditorDrawer.GetPropertyHeight();
}
return res;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: aaf7449ec0a51804980a5d076861735c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/AllIn13DShaderGradientDrawer.cs
uploadId: 865720
@@ -0,0 +1,25 @@
using UnityEditor;
namespace AllIn13DShader
{
public class ColorRampEffectDrawer : AbstractEffectDrawer
{
public ColorRampEffectDrawer(AllIn13DShaderInspectorReferences references,
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
{
this.drawerID = Constants.COLOR_RAMP_EFFECT_DRAWER_ID;
}
protected override void DrawProperties()
{
for(int i = 0; i < effectConfig.effectProperties.Count; i++)
{
DrawProperty(effectConfig.effectProperties[i]);
if (i == 2)
{
EditorGUILayout.LabelField("*Set the Color Ramp Texture to Repeat Wrap Mode if using Tiling and/or Scroll Speed", references.smallLabelStyle);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 17130facc1b999348a0cbd8784766aba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/ColorRampEffectDrawer.cs
uploadId: 865720
@@ -0,0 +1,11 @@
namespace AllIn13DShader
{
public class GeneralEffectDrawer : AbstractEffectDrawer
{
public GeneralEffectDrawer(AllIn13DShaderInspectorReferences references,
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
{
this.drawerID = Constants.GENERAL_EFFECT_DRAWER_ID;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8d0ce6e8dd172c346b1c817ec5065103
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/GeneralEffectDrawer.cs
uploadId: 865720
@@ -0,0 +1,35 @@
using UnityEditor;
namespace AllIn13DShader
{
public class OutlineEffectDrawer : AbstractEffectDrawer
{
private MaterialProperty stencilRefMatProperty;
public OutlineEffectDrawer(AllIn13DShaderInspectorReferences references,
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
{
this.drawerID = Constants.OUTLINE_DRAWER_ID;
stencilRefMatProperty = FindPropertyByName("_StencilRef");
}
protected override void DrawProperties()
{
base.DrawProperties();
if (stencilRefMatProperty != null)
{
EffectPropertyDrawer.DrawProperty(
materialProperty: stencilRefMatProperty,
labelPrefix: string.Empty,
displayName: stencilRefMatProperty.displayName,
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6cc036b9a5e6daf40895576180575dd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/OutlineEffectDrawer.cs
uploadId: 865720