[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,102 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class AdvancedPropertiesDrawer
{
private List<int> advancedPropertiesIndices;
private int blendSrcIndex;
private int blendDstIndex;
private AllIn13DShaderInspectorReferences references;
private MaterialProperty advancedPropertiesEnabledMatProperty;
private bool AdvancedPropertiesEnabled
{
get
{
bool res = advancedPropertiesEnabledMatProperty.floatValue > 0;
return res;
}
set
{
float floatValue = value ? 1.0f : 0f;
advancedPropertiesEnabledMatProperty.floatValue = floatValue;
}
}
public AdvancedPropertiesDrawer(List<int> advancedPropertiesIndices, int blendSrcIndex, int blendDstIndex, AllIn13DShaderInspectorReferences references)
{
this.advancedPropertiesIndices = advancedPropertiesIndices;
this.blendSrcIndex = blendSrcIndex;
this.blendDstIndex = blendDstIndex;
this.references = references;
advancedPropertiesEnabledMatProperty = references.matProperties[advancedPropertiesIndices[0]];
}
public void Draw()
{
AdvancedPropertiesEnabled = GUILayout.Toggle(AdvancedPropertiesEnabled, new GUIContent("Show Advanced Configuration"), references.toggleButtonStyle);
if (AdvancedPropertiesEnabled)
{
EditorGUILayout.BeginVertical(references.propertiesStyle);
MaterialProperty matPropertyBlendSrc = references.matProperties[blendSrcIndex];
MaterialProperty matProeprtyBlendDst = references.matProperties[blendDstIndex];
EffectPropertyDrawer.DrawProperty(
materialProperty: matPropertyBlendSrc,
labelPrefix: string.Empty,
displayName: matPropertyBlendSrc.displayName,
customValue: string.Empty,
allowReset: false,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references);
EffectPropertyDrawer.DrawProperty(
materialProperty: matProeprtyBlendDst,
labelPrefix: string.Empty,
displayName: matProeprtyBlendDst.displayName,
customValue: string.Empty,
allowReset: false,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references);
EditorUtils.DrawThinLine();
for (int i = 1; i < advancedPropertiesIndices.Count; i++)
{
//if(i == blendSrcIndex || i == blendDstIndex) { continue; }
MaterialProperty matProperty = references.matProperties[advancedPropertiesIndices[i]];
EffectPropertyDrawer.DrawProperty(
materialProperty: matProperty,
labelPrefix: string.Empty,
displayName: matProperty.displayName,
customValue: string.Empty,
allowReset: false,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
EditorUtils.DrawThinLine();
}
references.editorMat.EnableInstancingField();
Rect rect = EditorGUILayout.GetControlRect();
rect.x += 3f;
rect.width -= 3f;
references.editorMat.RenderQueueField(rect);
EditorGUILayout.EndVertical();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4877ef4771a6497458bd45402be12188
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/AdvancedPropertiesDrawer.cs
uploadId: 865720
@@ -0,0 +1,130 @@
using System.IO;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class AtlasPackerDrawer
{
private AtlasPackerTool atlasPackerTool;
public AtlasPackerValues ToolValues => atlasPackerTool.values;
private CommonStyles commonStyles;
private SerializedObject soAtlasPackerValues;
public AtlasPackerDrawer(AtlasPackerTool atlasPackerTool, CommonStyles commonStyles)
{
this.atlasPackerTool = atlasPackerTool;
this.commonStyles = commonStyles;
RefreshAtlasPackerValues();
}
private void RefreshAtlasPackerValues()
{
soAtlasPackerValues = new SerializedObject(ToolValues);
}
public void Draw()
{
soAtlasPackerValues.Update();
if (ToolValues == null)
{
RefreshAtlasPackerValues();
}
GUILayout.Label("Texture Atlas / Spritesheet Packer", commonStyles.bigLabel);
GUILayout.Space(20);
GUILayout.Label("Add Textures to the Atlas array", EditorStyles.boldLabel);
SerializedProperty atlasProperty = soAtlasPackerValues.FindProperty("atlas");
EditorGUILayout.PropertyField(atlasProperty, true, GUILayout.MaxWidth(200));
soAtlasPackerValues.ApplyModifiedProperties();
//ToolValues.atlas = Atlas;
ToolValues.squareAtlas = EditorGUILayout.Toggle("Square Atlas?", ToolValues.squareAtlas, GUILayout.MaxWidth(200));
EditorGUILayout.BeginHorizontal();
{
if (ToolValues.squareAtlas)
{
ToolValues.atlasXCount = EditorGUILayout.IntSlider("Column and Row Count", ToolValues.atlasXCount, 1, 8, GUILayout.MaxWidth(302));
ToolValues.atlasYCount = ToolValues.atlasXCount;
}
else
{
ToolValues.atlasXCount = EditorGUILayout.IntSlider("Column Count", ToolValues.atlasXCount, 1, 8, GUILayout.MaxWidth(302));
GUILayout.Space(10);
ToolValues.atlasYCount = EditorGUILayout.IntSlider("Row Count", ToolValues.atlasYCount, 1, 8, GUILayout.MaxWidth(302));
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
if (ToolValues.squareAtlas)
{
GUILayout.Label("Atlas Size:", GUILayout.MaxWidth(100));
ToolValues.atlasSizesX = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.atlasSizesX, GUILayout.MaxWidth(200));
ToolValues.atlasSizesY = ToolValues.atlasSizesX;
}
else
{
GUILayout.Label("Atlas Size X:", GUILayout.MaxWidth(100));
ToolValues.atlasSizesX = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.atlasSizesX, GUILayout.MaxWidth(200));
GUILayout.Space(10);
GUILayout.Label("Atlas Size Y:", GUILayout.MaxWidth(100));
ToolValues.atlasSizesY = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.atlasSizesY, GUILayout.MaxWidth(200));
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Atlas Filtering: ", GUILayout.MaxWidth(100));
ToolValues.atlasFiltering = (FilterMode)EditorGUILayout.EnumPopup(ToolValues.atlasFiltering, GUILayout.MaxWidth(200));
}
EditorGUILayout.EndHorizontal();
int atlasElements = atlasPackerTool.GetAtlasElements();
int atlasWidth = (int)ToolValues.atlasSizesX;
int atlasHeight = (int)ToolValues.atlasSizesY;
GUILayout.Label("Output will be a " + ToolValues.atlasXCount + " X " + ToolValues.atlasYCount + " atlas, " + atlasElements + " elements in total. In a " +
atlasWidth + "pixels X " + atlasHeight + "pixels texture", EditorStyles.boldLabel);
int usedAtlasSlots = 0;
for (int i = 0; i < ToolValues.atlas.Length; i++)
{
if (ToolValues.atlas[i] != null)
{
usedAtlasSlots++;
}
}
if (usedAtlasSlots > atlasElements)
{
GUILayout.Label("*Please reduce the Atlas texture slots by " + Mathf.Abs(atlasElements - ToolValues.atlas.Length) + " (extra textures will be ignored)", EditorStyles.boldLabel);
}
if (atlasElements > usedAtlasSlots)
{
GUILayout.Label("*" + (atlasElements - usedAtlasSlots) + " atlas slots unused or null (it will be filled with black)", EditorStyles.boldLabel);
}
GUILayout.Space(20);
GUILayout.Label("Select the folder where new Atlases will be saved", EditorStyles.boldLabel);
GlobalConfiguration.instance.AtlasesSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.AtlasesSavePath, /*AllIn13DShaderConfig.ATLASES_SAVE_PATH_DEFAULT,*/ "Atlas");
if (Directory.Exists(GlobalConfiguration.instance.AtlasesSavePath))
{
if (GUILayout.Button("Create And Save Atlas Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
{
atlasPackerTool.CreateAtlas();
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.AtlasesSavePath, "Atlas", "Texture Atlas", ToolValues.createdAtlas, ToolValues.atlasFiltering, TextureImporterType.Default, TextureWrapMode.Clamp);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dca812f5788e4cb49942f0cb9072a9d3
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/AtlasPackerDrawer.cs
uploadId: 865720
@@ -0,0 +1,76 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class CommonStyles
{
public const int BUTTON_WIDTH = 600;
public const int BIG_FONT_SIZE = 16;
public GUIStyle shaderPropertiesStyle;
public GUIStyle wordWrappedStyle;
public GUIStyle style;
public GUIStyle bigLabel;
public GUIStyle warningLabel;
public GUIStyle okLabel;
public GUIStyle linkStyle;
public GUIStyle boxStyle;
public void InitStyles()
{
if(wordWrappedStyle == null)
{
wordWrappedStyle = new GUIStyle(EditorStyles.largeLabel);
wordWrappedStyle.wordWrap = true;
}
if(style == null)
{
style = new GUIStyle(EditorStyles.helpBox);
style.margin = new RectOffset(0, 0, 0, 0);
}
if(bigLabel == null)
{
bigLabel = new GUIStyle(EditorStyles.boldLabel);
bigLabel.fontSize = BIG_FONT_SIZE;
}
if(okLabel == null)
{
okLabel = new GUIStyle(EditorStyles.label);
okLabel.fontSize = BIG_FONT_SIZE;
okLabel.normal.textColor = Color.green;
okLabel.wordWrap = true;
okLabel.richText = true;
}
if(warningLabel == null)
{
warningLabel = new GUIStyle(EditorStyles.label);
warningLabel.fontSize = BIG_FONT_SIZE;
warningLabel.normal.textColor = Color.yellow;
warningLabel.wordWrap = true;
warningLabel.richText = true;
}
if(linkStyle == null)
{
linkStyle = new GUIStyle(EditorStyles.linkLabel);
}
if(boxStyle == null)
{
boxStyle = new GUIStyle(EditorStyles.helpBox);
boxStyle.margin = new RectOffset(0, 0, 0, 0);
}
if(shaderPropertiesStyle == null)
{
shaderPropertiesStyle = new GUIStyle(EditorStyles.helpBox);
shaderPropertiesStyle.margin = new RectOffset(25, 0, 0, 0);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: aba3dca1c691c3b4891e7a7e67ad55dc
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/CommonStyles.cs
uploadId: 865720
@@ -0,0 +1,111 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class DepthColoringPropertiesDrawer
{
private AllIn1DepthColoringProperties depthColoringProperties;
private CommonStyles commonStyles;
private GradientEditorDrawer gradientDrawer;
private DepthColoringCamera depthColoringCamera;
private bool isActive;
public DepthColoringPropertiesDrawer(AllIn1DepthColoringProperties depthColoringProperties)
{
SetDepthColoringProperties(depthColoringProperties);
}
public void SetDepthColoringProperties(AllIn1DepthColoringProperties depthColoringProperties)
{
this.depthColoringProperties = depthColoringProperties;
}
private void RefreshReferences()
{
if (gradientDrawer == null)
{
gradientDrawer = new GradientEditorDrawer();
}
if (commonStyles == null)
{
commonStyles = new CommonStyles();
commonStyles.InitStyles();
}
if(depthColoringCamera == null)
{
depthColoringCamera = GameObject.FindFirstObjectByType<DepthColoringCamera>();
}
}
public void Draw(bool useBoxStyle = false)
{
RefreshReferences();
if (useBoxStyle)
{
EditorGUILayout.BeginVertical(commonStyles.boxStyle);
}
else
{
EditorGUILayout.BeginVertical();
}
EditorGUI.BeginChangeCheck();
Rect rect = EditorGUILayout.GetControlRect(true, gradientDrawer.GetPropertyHeight());
depthColoringProperties.depthColoringGradientTex = (Texture2D)gradientDrawer.Draw(rect, depthColoringProperties.depthColoringGradientTex);
depthColoringProperties.depthZoneLength = EditorGUILayout.FloatField("Depth Zone Length", depthColoringProperties.depthZoneLength);
depthColoringProperties.depthColoringMinDepth = EditorGUILayout.FloatField("Depth Min", depthColoringProperties.depthColoringMinDepth);
depthColoringProperties.fallOff = EditorGUILayout.Slider("Fall Off", depthColoringProperties.fallOff, 0.1f, 1.5f);
GUILayout.Space(20f);
if (depthColoringCamera == null)
{
EditorGUILayout.LabelField("Depth coloring camera not found in the scene. You need to add DepthColoringCamera.cs component to the main camera in order to use this effect.", commonStyles.warningLabel);
isActive = false;
}
else
{
isActive = depthColoringCamera.depthColoringProperties == depthColoringProperties;
if (isActive)
{
EditorGUILayout.LabelField("Active", commonStyles.okLabel);
}
else
{
EditorGUILayout.LabelField("This properties are not active", commonStyles.warningLabel);
if (GUILayout.Button("Active"))
{
depthColoringCamera.depthColoringProperties = depthColoringProperties;
isActive = true;
EditorUtils.SetDirtyCurrentScene();
}
}
}
EditorGUILayout.EndVertical();
if (EditorGUI.EndChangeCheck() && isActive)
{
ApplyChanges();
}
}
private void ApplyChanges()
{
EditorUtility.SetDirty(depthColoringProperties);
depthColoringProperties.ApplyValues();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 605016f1af959104f98b4f8873abe8e0
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/DepthColoringPropertiesDrawer.cs
uploadId: 865720
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 377339d02577eb24793e9b80a10ae599
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
@@ -0,0 +1,370 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public static class EffectPropertyDrawer
{
public static void DrawMainProperty(int globalEffectIndex,
AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references,
bool isEffectAvailable, bool isEffectAvailableOnGlobalConfig)
{
EditorGUILayout.BeginHorizontal();
bool isShaderVariant = references.IsShaderVariant();
string label = $"{globalEffectIndex}. {effectConfig.displayName}";
if (isEffectAvailableOnGlobalConfig || isShaderVariant)
{
switch (effectConfig.effectConfigType)
{
case EffectConfigType.EFFECT_TOGGLE:
DrawMainPropertyToggle(label, effectConfig, references, isShaderVariant);
break;
case EffectConfigType.EFFECT_ENUM:
DrawMainPropertyEnum(label, effectConfig, references, isEffectAvailable, isShaderVariant);
break;
}
}
else
{
int keywordSelectedIndex = 0;
references.IsEffectEnabled(effectConfig, ref keywordSelectedIndex);
GUIContent guiContent = effectConfig.CreateGUIContent(globalEffectIndex, keywordSelectedIndex);
EditorGUILayout.LabelField(guiContent, GUILayout.Width(180f));
EditorGUILayout.LabelField("Disabled in Active Effects List");
}
EditorGUILayout.EndHorizontal();
}
public static void DrawMainPropertyToggle(string label,
AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references,
bool isShaderVariant)
{
bool isEffectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, references);
EditorGUI.BeginChangeCheck();
string tooltip = effectConfig.keywords[0].keyword + " (C#)";
GUIContent guiContent = new GUIContent(label, tooltip);
bool effectEnabledInAllMaterials = true;
bool effectDisabledInAllMaterials = true;
bool allMaterialsAreVariants = true;
for (int i = 0; i < references.targetMatInfos.Length; i++)
{
bool effectEnabledThisMat = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, references.targetMatInfos[i]);
effectEnabledInAllMaterials = effectEnabledInAllMaterials && effectEnabledThisMat;
effectDisabledInAllMaterials = effectDisabledInAllMaterials && !effectEnabledThisMat;
allMaterialsAreVariants = allMaterialsAreVariants && references.targetMatInfos[i].IsShaderVariant();
}
if (allMaterialsAreVariants)
{
GUILayout.Label(guiContent);
}
else
{
bool mixedValue = (!(effectEnabledInAllMaterials || effectDisabledInAllMaterials)) && references.targetMatInfos.Length > 1;
string style = mixedValue ? "ToggleMixed" : "Toggle";
isEffectEnabled = GUILayout.Toggle(isEffectEnabled, guiContent, style);
}
if (EditorGUI.EndChangeCheck())
{
for(int i = 0; i < references.targetMatInfos.Length; i++)
{
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
if (isEffectEnabled)
{
AllIn13DEffectConfig.EnableEffect(effectConfig, references, matInfo);
}
else
{
AllIn13DEffectConfig.DisableEffect(effectConfig, matInfo);
}
}
references.matProperties[effectConfig.keywordPropertyIndex].floatValue = isEffectEnabled ? 1f : 0f;
EditorUtils.SetDirtyCurrentScene();
references.SetMaterialsDirty();
}
}
public static void DrawMainPropertyEnum(string label,
AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references,
bool isEffectAvailable, bool isShaderVariant)
{
int selectedIndex = 0;
//bool isEffectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, ref selectedIndex, references);
bool sameEnumValueInAllMaterials = references.IsEffectEnabled(effectConfig, ref selectedIndex);
//bool sameEnumValueInAllMaterials = true;
//for(int i = 0; i < references.targetMatInfos.Length; i++)
//{
// int enumIdx = -1;
// AbstractMaterialInfo matInfo = references.targetMatInfos[i];
// bool effectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, ref enumIdx, matInfo);
// if(i == 0)
// {
// selectedIndex = enumIdx;
// }
// else
// {
// sameEnumValueInAllMaterials = sameEnumValueInAllMaterials && (enumIdx == selectedIndex);
// }
//}
string tooltip = effectConfig.keywords[selectedIndex].keyword + " (C#)";
GUIContent guiContent = new GUIContent(label, tooltip);
if (isShaderVariant)
{
if (isEffectAvailable)
{
EditorGUILayout.BeginHorizontal(references.propertiesStyle);
EditorGUILayout.LabelField(guiContent);
EditorGUILayout.LabelField(effectConfig.keywordsDisplayNames[selectedIndex]);
EditorGUILayout.EndHorizontal();
}
else
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(guiContent);
EditorGUILayout.EndHorizontal();
}
}
else
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = !sameEnumValueInAllMaterials;
selectedIndex = EditorGUILayout.Popup(guiContent, selectedIndex, effectConfig.keywordsDisplayNames);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
{
for (int i = 0; i < references.targetMatInfos.Length; i++)
{
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
if (selectedIndex >= 0)
{
AllIn13DEffectConfig.EnableEffectByIndex(effectConfig, selectedIndex, references, matInfo);
}
else
{
AllIn13DEffectConfig.DisableEffect(effectConfig, matInfo);
}
}
references.matProperties[effectConfig.keywordPropertyIndex].floatValue = selectedIndex;
EditorUtils.SetDirtyCurrentScene();
references.SetMaterialsDirty();
}
}
}
//public static void DrawProperty(int propertyIndex, string labelPrefix, bool allowReset, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
//{
// MaterialProperty targetProperty = references.matProperties[propertyIndex];
// DrawProperty(
// materialProperty: targetProperty,
// labelPrefix: labelPrefix,
// displayName: targetProperty.displayName,
// allowReset: allowReset,
// isKeywordProperty: isKeywordProperty,
// references: references);
//}
//public static void DrawProperty(EffectProperty effectProperty, string labelPrefix, bool allowReset, AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(effectProperty.propertyIndex, labelPrefix, effectProperty.allowReset, effectProperty.IsPropertyWithKeywords(), references);
//}
//public static void DrawProperty(EffectProperty effectProperty, AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(propertyIndex: effectProperty.propertyIndex, isKeywordProperty: effectProperty.IsPropertyWithKeywords(), references: references);
//}
//public static void DrawProperty(int propertyIndex, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(propertyIndex, string.Empty, true, isKeywordProperty, references);
//}
//public static void DrawProperty(MaterialProperty materialProperty, AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(materialProperty, false, references);
//}
//public static void DrawProperty(MaterialProperty materialProperty, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(
// materialProperty: materialProperty,
// labelPrefix: string.Empty,
// displayName: materialProperty.displayName,
// allowReset: true,
// isKeywordProperty: isKeywordProperty,
// references: references);
//}
//public static void DrawProperty(MaterialProperty materialProperty, bool allowReset, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(
// materialProperty: materialProperty,
// labelPrefix: string.Empty,
// displayName: materialProperty.displayName,
// allowReset: allowReset,
// isKeywordProperty: isKeywordProperty,
// references: references);
//}
//public static void DrawProperty(
// MaterialProperty materialProperty,
// string labelPrefix,
// bool allowReset,
// bool isKeywordProperty,
// AllIn13DShaderInspectorReferences references)
//{
// DrawProperty(
// materialProperty: materialProperty,
// labelPrefix: labelPrefix,
// displayName: materialProperty.displayName,
// allowReset: allowReset,
// isKeywordProperty: isKeywordProperty,
// references: references);
//}
//public static void DrawPropertyCustomValue(
// EffectProperty effectProperty,
// string labelPrefix,
// string displayName,
// bool allowReset,
// bool isKeywordProperty,
// AllIn13DShaderInspectorReferences references)
//{
// MaterialProperty materialProperty = references.matProperties[effectProperty.propertyIndex];
// string label = $"{labelPrefix} {displayName}";
// string tooltip = materialProperty.name + "(C#)";
// EditorGUILayout.BeginHorizontal();
// DrawShaderProperty(materialProperty: materialProperty, label: label, tooltip: tooltip, isKeywordProperty: isKeywordProperty, references: references);
// if (allowReset)
// {
// DrawResetButton(materialProperty, references);
// }
// EditorGUILayout.EndHorizontal();
//}
public static void DrawProperty(
MaterialProperty materialProperty,
string labelPrefix,
string displayName,
string customValue,
bool allowReset,
bool isKeywordProperty,
EffectProperty.PropertyType propertyType,
AllIn13DShaderInspectorReferences references)
{
string label = $"{labelPrefix} {displayName}";
string tooltip = materialProperty.name + "(C#)";
EditorGUILayout.BeginHorizontal();
bool isShaderVariant = references.IsShaderVariant();
if(isShaderVariant && isKeywordProperty)
{
DrawShaderPropertyCustomValue(label: label, tooltip: tooltip, customValue: customValue, isKeywordProperty: isKeywordProperty, propertyType: propertyType, references: references);
}
else
{
DrawShaderProperty(materialProperty: materialProperty, label: label, tooltip: tooltip, isKeywordProperty: isKeywordProperty, references: references);
if (allowReset)
{
DrawResetButton(materialProperty, references);
}
}
EditorGUILayout.EndHorizontal();
}
private static void DrawShaderProperty(
MaterialProperty materialProperty,
string label,
string tooltip,
bool isKeywordProperty,
AllIn13DShaderInspectorReferences references)
{
GUIContent propertyLabel = new GUIContent();
propertyLabel.text = label;
propertyLabel.tooltip = tooltip;
EditorGUI.BeginChangeCheck();
references.editorMat.ShaderProperty(materialProperty, propertyLabel);
if (EditorGUI.EndChangeCheck())
{
if (isKeywordProperty)
{
references.RefreshMaterialKeywords();
}
}
}
private static void DrawShaderPropertyCustomValue(
string label,
string tooltip,
string customValue,
bool isKeywordProperty,
EffectProperty.PropertyType propertyType,
AllIn13DShaderInspectorReferences references)
{
EditorGUILayout.BeginHorizontal();
GUIContent propertyLabel = new GUIContent();
propertyLabel.text = label;
propertyLabel.tooltip = tooltip;
if(propertyType == EffectProperty.PropertyType.TOGGLE)
{
EditorGUILayout.Toggle(propertyLabel, true);
}
else
{
EditorGUILayout.LabelField(propertyLabel);
EditorGUILayout.LabelField(customValue);
}
EditorGUILayout.EndHorizontal();
}
public static void DrawResetButton(MaterialProperty targetProperty, AllIn13DShaderInspectorReferences references)
{
GUIContent resetButtonLabel = new GUIContent();
resetButtonLabel.text = "R";
resetButtonLabel.tooltip = "Resets to default value";
if (GUILayout.Button(resetButtonLabel, GUILayout.Width(20)))
{
for (int i = 0; i < references.targetMatInfos.Length; i++)
{
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
AllIn13DEffectConfig.ResetProperty(targetProperty, references, matInfo);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: edd8e2faf4f408743829655503b71b17
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/EffectPropertyDrawer.cs
uploadId: 865720
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class GlobalPropertiesDrawer
{
private List<int> globalPropertiesIndices;
private AllIn13DShaderInspectorReferences references;
public GlobalPropertiesDrawer()
{
}
public void Draw(List<int> globalPropertiesIndices, AllIn13DShaderInspectorReferences references)
{
this.globalPropertiesIndices = globalPropertiesIndices;
this.references = references;
GUILayout.Label("Global Properties", references.bigLabelStyle);
EditorGUILayout.BeginVertical(references.propertiesStyle);
for (int i = 0; i < globalPropertiesIndices.Count; i++)
{
MaterialProperty matProperty = references.matProperties[globalPropertiesIndices[i]];
EffectPropertyDrawer.DrawProperty(
materialProperty: matProperty,
labelPrefix: string.Empty,
displayName: matProperty.displayName,
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
}
EditorGUILayout.EndVertical();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 55fc5c9db4641f54a912ca07e7d764f8
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/GlobalPropertiesDrawer.cs
uploadId: 865720
@@ -0,0 +1,107 @@
using System.IO;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class GradientCreatorDrawer
{
private GradientCreatorTool gradientCreatorTool;
private CommonStyles commonStyles;
private Texture2D GradientTex
{
get
{
return gradientCreatorTool.gradientTex;
}
set
{
gradientCreatorTool.gradientTex = value;
}
}
private Gradient Grad
{
get
{
return gradientCreatorTool.gradient;
}
set
{
gradientCreatorTool.gradient = value;
}
}
private TextureSizes GradientSizes
{
get
{
return gradientCreatorTool.gradientSizes;
}
set
{
gradientCreatorTool.gradientSizes = value;
}
}
private FilterMode GradientFiltering
{
get
{
return gradientCreatorTool.gradientFiltering;
}
set
{
gradientCreatorTool.gradientFiltering = value;
}
}
public GradientCreatorDrawer(GradientCreatorTool gradientCreatorTool, CommonStyles commonStyles)
{
this.gradientCreatorTool = gradientCreatorTool;
this.commonStyles = commonStyles;
}
public void Draw()
{
GUILayout.Label("Color Gradient Creator", commonStyles.bigLabel);
GUILayout.Space(20);
GUILayout.Label("This feature can be used to create textures for the Color Ramp Effect", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
Grad = EditorGUILayout.GradientField("Color Gradient: ", Grad, GUILayout.Height(25), GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH));
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Texture Size:", GUILayout.MaxWidth(145));
GradientSizes = (TextureSizes)EditorGUILayout.EnumPopup(GradientSizes, GUILayout.MaxWidth(200));
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("New Textures Filtering: ", GUILayout.MaxWidth(145));
GradientFiltering = (FilterMode)EditorGUILayout.EnumPopup(GradientFiltering, GUILayout.MaxWidth(200));
}
EditorGUILayout.EndHorizontal();
bool gradientChanged = EditorGUI.EndChangeCheck();
if (gradientChanged)
{
gradientCreatorTool.CreateGradientTexture();
}
GUILayout.Space(20);
GUILayout.Label("Select the folder where new Color Gradient Textures will be saved", EditorStyles.boldLabel);
GlobalConfiguration.instance.GradientSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.GradientSavePath, /*AllIn13DShaderConfig.GRADIENT_SAVE_PATH_DEFAULT,*/ "Gradients");
if (Directory.Exists(GlobalConfiguration.instance.GradientSavePath))
{
if (GUILayout.Button("Save Color Gradient Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
{
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.GradientSavePath, "ColorGradient", "Gradient", GradientTex, GradientFiltering,
TextureImporterType.Default, TextureWrapMode.Clamp);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 53d536ed22c0b4d4e8472402997463dd
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/GradientCreatorDrawer.cs
uploadId: 865720
@@ -0,0 +1,332 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class GradientEditorDrawer
{
private const float OFFSET = 5f;
private Gradient gradient;
private Rect lastRect;
private Texture2D previewTex;
private GradientCreatorTool gradientCreatorTool;
private bool createGradientToggle;
private bool textureSaved;
private bool usingPreviewTex;
private bool isModifyingExistingTexture;
private Texture lastSavedTexture;
private Gradient lastGradient;
private GradientTexture gradientTextureAsset;
private void RefreshReferences(Texture lastTexture)
{
if (gradient == null)
{
gradient = new Gradient();
}
if (previewTex == null)
{
previewTex = new Texture2D(128, 128);
}
if (gradientCreatorTool == null)
{
gradientCreatorTool = new GradientCreatorTool();
}
if (lastSavedTexture == null)
{
lastSavedTexture = lastTexture;
}
if (lastGradient == null)
{
lastGradient = new Gradient();
}
}
private Texture RefreshGradientState(Texture texValue)
{
Texture res = texValue;
if (createGradientToggle)
{
lastSavedTexture = texValue;
isModifyingExistingTexture = EditorUtils.IsProjectAsset(lastSavedTexture);
this.gradientTextureAsset = GradientCreatorTool.FindGradientTexureByTex(texValue);
if (this.gradientTextureAsset != null)
{
GradientCreatorTool.CopyGradient(gradientTextureAsset.gradient, gradient);
}
else
{
if (texValue != null)
{
gradient = CreateGradientFromTexture(texValue);
}
else
{
gradient = new Gradient();
}
}
previewTex = gradientCreatorTool.CreateGradientTexture(gradient);
res = previewTex;
}
else
{
GradientCreatorTool.CopyGradient(gradient, lastGradient);
previewTex = null;
res = lastSavedTexture;
}
return res;
}
private Gradient CreateGradientFromTexture(Texture texSource)
{
int width = texSource.width;
int height = texSource.height;
RenderTexture renderTex = RenderTexture.GetTemporary(
width,
height,
0,
RenderTextureFormat.Default,
RenderTextureReadWrite.Linear);
Graphics.Blit(texSource, renderTex);
RenderTexture previous = RenderTexture.active;
RenderTexture.active = renderTex;
Texture2D readableText = new Texture2D(texSource.width, texSource.height);
readableText.filterMode = texSource.filterMode;
readableText.wrapMode = texSource.wrapMode;
readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
readableText.Apply();
RenderTexture.active = previous;
RenderTexture.ReleaseTemporary(renderTex);
Gradient res = new Gradient();
List<GradientColorKey> gradientColorKeys = new List<GradientColorKey>();
int numSamples = 5;
float step = (((float)width) / numSamples) / width;
Vector2 sampleUV = Vector2.zero;
sampleUV.y = renderTex.height * 0.5f;
for (int i = 0; i < numSamples; i++)
{
Color col = readableText.GetPixelBilinear(sampleUV.x, sampleUV.y);
gradientColorKeys.Add(new GradientColorKey(col, sampleUV.x));
sampleUV.x += step;
}
Color lastCol = readableText.GetPixelBilinear(sampleUV.x, sampleUV.y);
gradientColorKeys.Add(new GradientColorKey(lastCol, sampleUV.x));
res.colorKeys = gradientColorKeys.ToArray();
res.mode = GradientMode.Blend;
return res;
}
public Texture Draw(Rect position, Texture gradientTexture)
{
RefreshReferences(gradientTexture);
lastRect = position;
Texture texValue = gradientTexture;
EditorGUI.BeginChangeCheck();
if (createGradientToggle && texValue == null)
{
texValue = lastSavedTexture;
createGradientToggle = false;
}
texValue = DrawTextureField(texValue, 60f, "Color ramp texture");
bool changes = EditorGUI.EndChangeCheck();
if (changes)
{
createGradientToggle = false;
lastSavedTexture = texValue;
}
EditorGUI.BeginChangeCheck();
DrawCreateGradientToggle(15f, "Create Gradient");
bool createGradientToggleChanged = EditorGUI.EndChangeCheck();
if (createGradientToggleChanged)
{
texValue = RefreshGradientState(texValue);
}
EditorGUI.BeginChangeCheck();
if (createGradientToggle)
{
texValue = DrawGradientField(40f, "Gradient", texValue);
}
EditorGUI.showMixedValue = false;
bool gradientFieldChanged = EditorGUI.EndChangeCheck();
if (gradientFieldChanged && !textureSaved)
{
previewTex = gradientCreatorTool.CreateGradientTexture(TextureSizes._256, FilterMode.Bilinear, gradient);
texValue = previewTex;
usingPreviewTex = true;
}
textureSaved = false;
return texValue;
}
private Texture DrawTextureField(Texture tex, float height, string label)
{
Rect rect = new Rect(lastRect);
rect.height = height;
GUIStyle labelStyle = EditorStyles.label;
labelStyle.alignment = TextAnchor.UpperLeft;
Rect labelRect = new Rect(rect);
labelRect.width = 200f;
EditorGUI.LabelField(labelRect, new GUIContent(label), labelStyle);
GUIStyle textureStyle = EditorStyles.objectField;
textureStyle.alignment = TextAnchor.MiddleLeft;
Rect textureRect = new Rect(rect);
textureRect.width = height;
textureRect.height = height;
textureRect.x = rect.width - textureRect.width - 10f;
Texture res = (Texture)EditorGUI.ObjectField(textureRect, tex, typeof(Texture), false);
lastRect.y += height;
return res;
}
private Texture DrawGradientField(float height, string label, Texture texValue)
{
Texture res = texValue;
Rect rect = new Rect(lastRect);
rect.height = height;
rect.y += height * 0.5f;
float createButtonWidth = 100f;
GUIStyle labelStyle = EditorStyles.label;
labelStyle.alignment = TextAnchor.UpperLeft;
Rect labelRect = new Rect(rect);
labelRect.width = 200f;
EditorGUI.LabelField(labelRect, new GUIContent(label), labelStyle);
GUIStyle textureStyle = EditorStyles.objectField;
textureStyle.alignment = TextAnchor.MiddleLeft;
Rect gradientAndButtonRect = new Rect(rect);
gradientAndButtonRect.width = rect.width - labelRect.width;
gradientAndButtonRect.height = rect.height;
gradientAndButtonRect.x = labelRect.x + labelRect.width;
Rect gradientRect = new Rect(gradientAndButtonRect);
gradientRect.width = gradientAndButtonRect.width * 0.5f;
gradientRect.height = rect.height * 0.5f;
gradientRect.x = rect.x + rect.width - gradientRect.width - (createButtonWidth * 2f) - 10f;
gradient = EditorGUI.GradientField(gradientRect, gradient);
Rect createButtonRect = new Rect(gradientAndButtonRect);
createButtonRect.width = createButtonWidth;
createButtonRect.height = gradientRect.height;
createButtonRect.x = gradientRect.x + gradientRect.width + 10f;
Rect modifyButtonRect = new Rect(createButtonRect);
modifyButtonRect.x = createButtonRect.x + createButtonRect.width + 10f;
if (GUI.Button(createButtonRect, "Save Texture"))
{
res = ChangeTextureOnDisk(true);
}
EditorGUI.BeginDisabledGroup(!isModifyingExistingTexture || gradientTextureAsset == null);
if (GUI.Button(modifyButtonRect, "Overwrite"))
{
res = ChangeTextureOnDisk(false);
}
EditorGUI.EndDisabledGroup();
lastRect.y += height + OFFSET;
if (usingPreviewTex && !textureSaved)
{
Rect helpBoxRect = new Rect(lastRect);
helpBoxRect.height = 40f;
EditorGUI.HelpBox(helpBoxRect, "Texture is not saved! Click on Save Texture to save it", MessageType.Warning);
lastRect.y += helpBoxRect.height + OFFSET;
}
return res;
}
private Texture ChangeTextureOnDisk(bool createNew)
{
gradientCreatorTool.CreateGradientTexture(gradient);
Texture savedTex = gradientCreatorTool.SaveGradientTexture(gradientTextureAsset, createNew);
Texture res = savedTex;
lastSavedTexture = savedTex;
textureSaved = true;
usingPreviewTex = false;
createGradientToggle = false;
gradientTextureAsset = null;
return res;
}
private void DrawCreateGradientToggle(float height, string label)
{
Rect rect = new Rect(lastRect);
rect.height = height;
Rect toggleRect = new Rect(rect);
createGradientToggle = EditorGUI.ToggleLeft(toggleRect, label, createGradientToggle);
lastRect.y += height;
}
public float GetPropertyHeight()
{
float res = 80f;
if (createGradientToggle)
{
res += 45f;
if (usingPreviewTex)
{
res += 40f;
}
}
return res;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 42eeae2ae0fe6674786f324f6b74294c
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/GradientEditorDrawer.cs
uploadId: 865720
@@ -0,0 +1,124 @@
using System.IO;
using UnityEditor;
using UnityEngine;
using static AllIn13DShader.NoiseCreatorTool;
namespace AllIn13DShader
{
public class NoiseCreatorDrawer
{
private NoiseCreatorTool noiseCreatorTool;
private CommonStyles commonStyles;
private NoiseCreatorValues Values
{
get
{
return noiseCreatorTool.values;
}
}
public NoiseCreatorDrawer(NoiseCreatorTool noiseCreatorTool, CommonStyles commonStyles)
{
this.noiseCreatorTool = noiseCreatorTool;
this.commonStyles = commonStyles;
}
public void Draw()
{
GUILayout.Label("Tileable Noise Creator", commonStyles.bigLabel);
GUILayout.Space(20);
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.BeginVertical(GUILayout.MaxWidth(550));
{
if (Values.noisePreview == null)
{
GUILayout.Label("*Change a property to start editing a Noise texture", EditorStyles.boldLabel);
}
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Noise Type:", GUILayout.MaxWidth(145));
Values.noiseType = (NoiseTypes)EditorGUILayout.EnumPopup(Values.noiseType, GUILayout.MaxWidth(200));
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
noiseCreatorTool.NoiseSetMaterial();
noiseCreatorTool.CheckCreationNoiseTextures();
noiseCreatorTool.UpdateNoiseMatAndRender();
}
EditorGUI.BeginChangeCheck();
if (Values.isFractalNoise)
{
EditorUtils.TextureEditorFloatParameter("Scale X", ref Values.noiseScaleX, 0.1f, 50f, 4f);
if (!Values.noiseSquareScale) EditorUtils.TextureEditorFloatParameter("Scale Y", ref Values.noiseScaleY, 0.1f, 50f, 4f);
}
else
{
EditorUtils.TextureEditorFloatParameter("Scale X", ref Values.noiseScaleX, 0.1f, 50f, 10f);
if (!Values.noiseSquareScale) EditorUtils.TextureEditorFloatParameter("Scale Y", ref Values.noiseScaleY, 0.1f, 50f, 10f);
}
Values.noiseSquareScale = EditorGUILayout.Toggle("Square Scale?", Values.noiseSquareScale, GUILayout.MaxWidth(200));
if (Values.noiseSquareScale) Values.noiseScaleY = Values.noiseScaleX;
if (Values.noiseType == NoiseTypes.Fractal) EditorUtils.TextureEditorFloatParameter("Fractal Amount", ref Values.noiseFractalAmount, 1f, 10f, 8f);
else if (Values.noiseType == NoiseTypes.Perlin) EditorUtils.TextureEditorFloatParameter("Fractal Amount", ref Values.noiseFractalAmount, 1f, 10f, 1f);
else if (Values.noiseType == NoiseTypes.Billow) EditorUtils.TextureEditorFloatParameter("Fractal Amount", ref Values.noiseFractalAmount, 1f, 10f, 4f);
else EditorUtils.TextureEditorFloatParameter("Jitter", ref Values.noiseJitter, 0.0f, 2f, 1f);
EditorUtils.TextureEditorFloatParameter("Contrast", ref Values.noiseContrast, 0.1f, 10f, 1f);
EditorUtils.TextureEditorFloatParameter("Brightness", ref Values.noiseBrightness, -1f, 1f, 0f);
EditorUtils.TextureEditorIntParameter("Random Seed", ref Values.noiseSeed, 0, 100, 0);
Values.noiseInverted = EditorGUILayout.Toggle("Inverted?", Values.noiseInverted);
if (EditorGUI.EndChangeCheck())
{
if (Values.noiseMaterial == null)
{
noiseCreatorTool.NoiseSetMaterial();
}
noiseCreatorTool.CheckCreationNoiseTextures();
noiseCreatorTool.UpdateNoiseMatAndRender();
}
GUILayout.Space(20);
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Noise Size:", GUILayout.MaxWidth(145));
Values.noiseSize = (TextureSizes)EditorGUILayout.EnumPopup(Values.noiseSize, GUILayout.MaxWidth(200));
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("New Noise Filtering: ", GUILayout.MaxWidth(145));
Values.noiseFiltering = (FilterMode)EditorGUILayout.EnumPopup(Values.noiseFiltering, GUILayout.MaxWidth(200));
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
if (Values.noisePreview != null) GUILayout.Label(Values.noisePreview, GUILayout.MaxWidth(450), GUILayout.MaxHeight(450));
}
EditorGUILayout.EndHorizontal();
GUILayout.Space(20);
GUILayout.Label("Select the folder where new Noise Textures will be saved", EditorStyles.boldLabel);
GlobalConfiguration.instance.NoiseSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.NoiseSavePath, /*AllIn13DShaderConfig.NOISES_SAVE_PATH_DEFAULT,*/ "Noises");
if (Directory.Exists(GlobalConfiguration.instance.NoiseSavePath) && Values.noisePreview != null)
{
if (GUILayout.Button("Save Noise Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
{
noiseCreatorTool.CreateNoiseTex();
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.NoiseSavePath, "Noise", "Noises",
Values.finalNoiseTex, Values.noiseFiltering, TextureImporterType.Default, TextureWrapMode.Clamp);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f1d0e6ca131aebb45a4e398281fa7db3
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/NoiseCreatorDrawer.cs
uploadId: 865720
@@ -0,0 +1,62 @@
using UnityEngine;
namespace AllIn13DShader
{
public class NoiseCreatorValues
{
public Texture2D noisePreview = null;
public Texture2D finalNoiseTex = null;
public RenderTexture noiseRenderTarget = null;
public Material noiseMaterial;
public float noiseScaleX = 10f;
public float noiseScaleY = 10f;
public float noiseContrast = 1f;
public float noiseBrightness = 0f;
public float noiseFractalAmount = 1f;
public float noiseJitter = 1f;
public int noiseSeed = 0;
public bool noiseSquareScale = false;
public bool noiseInverted = false;
public bool isFractalNoise = false;
public NoiseCreatorTool.NoiseTypes noiseType;
public TextureSizes noiseSize;
public FilterMode noiseFiltering;
public NoiseCreatorValues()
{
SetDefault();
}
public void SetDefault()
{
noisePreview = null;
noiseRenderTarget = null;
finalNoiseTex = null;
noiseMaterial = null;
noiseScaleX = 10f;
noiseScaleY = 10f;
noiseContrast = 1f;
noiseBrightness = 0f;
noiseFractalAmount = 1f;
noiseJitter = 1f;
noiseSeed = 0;
noiseSquareScale = false;
noiseInverted = false;
isFractalNoise = false;
noiseType = NoiseCreatorTool.NoiseTypes.Voronoi;
noiseSize = TextureSizes._512;
noiseFiltering = FilterMode.Bilinear;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 14c147009aa5dae418a84b61107ada3c
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/NoiseCreatorValues.cs
uploadId: 865720
@@ -0,0 +1,138 @@
using System;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class NormalMapCreatorDrawer
{
private NormalMapCreatorTool normalMapCreatorTool;
private CommonStyles commonStyles;
private Action repaintAction;
private Texture2D TargetNormalImage
{
get
{
return normalMapCreatorTool.targetNormalImage;
}
set
{
normalMapCreatorTool.targetNormalImage = value;
}
}
private float NormalStrength
{
get
{
return normalMapCreatorTool.normalStrength;
}
set
{
normalMapCreatorTool.normalStrength = value;
}
}
private int NormalSmoothing
{
get
{
return normalMapCreatorTool.normalSmoothing;
}
set
{
normalMapCreatorTool.normalSmoothing = value;
}
}
private bool InvertNormals{ get; set; }
private int IsComputingNormals
{
get
{
return normalMapCreatorTool.isComputingNormals;
}
set
{
normalMapCreatorTool.isComputingNormals = value;
}
}
public NormalMapCreatorDrawer(NormalMapCreatorTool normalMapCreatorTool, CommonStyles commonStyles, Action repaintAction)
{
this.normalMapCreatorTool = normalMapCreatorTool;
this.commonStyles = commonStyles;
this.repaintAction = repaintAction;
}
public void Draw()
{
GUILayout.Label("Normal/Distortion Map Creator", commonStyles.bigLabel);
GUILayout.Space(20);
GUILayout.Label("Select the folder where new Normal Maps will be saved when the Create Normal Map button of the asset component is pressed", EditorStyles.boldLabel);
GlobalConfiguration.instance.NormalMapSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.NormalMapSavePath, /*AllIn13DShaderConfig.NORMAL_MAP_SAVE_PATH_DEFAULT,*/ "Normal Maps Folder");
GUILayout.Label("Assign a texture you want to create a normal map from. Choose the normal map settings and press the 'Create And Save Normal Map' button", EditorStyles.boldLabel);
TargetNormalImage = (Texture2D)EditorGUILayout.ObjectField("Target Image", TargetNormalImage, typeof(Texture2D), false, GUILayout.MaxWidth(225));
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Normal Strength:", GUILayout.MaxWidth(150));
NormalStrength = EditorGUILayout.Slider(NormalStrength, 1f, 20f, GUILayout.MaxWidth(400));
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Normal Smoothing:", GUILayout.MaxWidth(150));
NormalSmoothing = EditorGUILayout.IntSlider(NormalSmoothing, 0, 3, GUILayout.MaxWidth(400));
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Invert Normal Direction:", GUILayout.MaxWidth(150));
InvertNormals = EditorGUILayout.Toggle(InvertNormals, GUILayout.MaxWidth(400));
}
EditorGUILayout.EndHorizontal();
if (IsComputingNormals == 0)
{
if (TargetNormalImage != null)
{
if (GUILayout.Button("Create And Save Normal Map", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
{
IsComputingNormals = 1;
return;
}
}
else
{
GUILayout.Label("Add a Target Image to use this feature", EditorStyles.boldLabel);
}
}
else
{
GUILayout.Label("Normal Map is currently being created, be patient", EditorStyles.boldLabel, GUILayout.Height(40));
repaintAction();
IsComputingNormals++;
if(IsComputingNormals > 5)
{
EditorUtils.SetTextureReadWrite(AssetDatabase.GetAssetPath(TargetNormalImage), true);
Texture2D normalMapToSave = normalMapCreatorTool.CreateNormalMap(InvertNormals);
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.NormalMapSavePath, "NormalMap", "Normal Map", normalMapToSave, FilterMode.Bilinear, TextureImporterType.NormalMap, TextureWrapMode.Repeat);
IsComputingNormals = 0;
}
}
GUILayout.Label("*This process will freeze the editor for some seconds, larger images will take longer", EditorStyles.boldLabel);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6304f118428d4744c8f82a134c469288
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/NormalMapCreatorDrawer.cs
uploadId: 865720
@@ -0,0 +1,67 @@
using UnityEngine;
using UnityEditor;
namespace AllIn13DShader
{
public class NormalMapEffectDrawer : AbstractEffectDrawer
{
private int mainTexPropertyIndex;
private EffectProperty effectPropNormalMap;
private EffectProperty effectPropNormalStrength;
private bool invertNormalMapDirection = false;
private float normalCreateStrength = 2.0f;
private float normalCreateSmooth = 1.0f;
public NormalMapEffectDrawer(AllIn13DShaderInspectorReferences references,
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
{
drawerID = Constants.NORMAL_MAP_EFFECT_DRAWER_ID;
effectConfig = propertiesConfig.FindEffectConfigByID("NORMAL_MAP");
mainTexPropertyIndex = FindPropertyIndex("_MainTex");
effectPropNormalMap = effectConfig.FindEffectPropertyByName("_NormalMap");
effectPropNormalStrength = effectConfig.FindEffectPropertyByName("_NormalStrength");
}
protected override void DrawProperties()
{
DrawProperty(effectPropNormalMap);
DrawProperty(effectPropNormalStrength);
EditorUtils.DrawLine(Color.grey, 1, 3);
EditorGUILayout.LabelField("Normal Map Creation", EditorStyles.boldLabel);
EditorUtils.TextureEditorFloatParameter("Strength", ref normalCreateStrength, 0.1f, 8.0f, 2.0f);
EditorUtils.TextureEditorFloatParameter("Smooth", ref normalCreateSmooth, 0.0f, 5.0f, 1.0f);
invertNormalMapDirection = EditorGUILayout.Toggle("Invert Normal Direction", invertNormalMapDirection);
GUILayout.Space(2);
if(GUILayout.Button("Create Normal Map Texture")) CreateNormalMap();
}
private void CreateNormalMap()
{
Texture2D sourceTexture = references.matProperties[mainTexPropertyIndex].textureValue as Texture2D;
if(sourceTexture == null)
{
EditorUtility.DisplayDialog("Error", "No Main Tex found. Please assign it first", "OK");
return;
}
EditorUtils.SetTextureReadWrite(AssetDatabase.GetAssetPath(sourceTexture), true);
NormalMapCreatorTool normalMapCreatorTool = new NormalMapCreatorTool
{
targetNormalImage = sourceTexture,
normalStrength = normalCreateStrength,
normalSmoothing = Mathf.RoundToInt(normalCreateSmooth),
isComputingNormals = 1
};
Texture2D normalMapToSave = normalMapCreatorTool.CreateNormalMap(invertNormalMapDirection);
Texture savedTex = EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.NormalMapSavePath, "NormalMap", "Normal Map", normalMapToSave, FilterMode.Bilinear, TextureImporterType.NormalMap, TextureWrapMode.Repeat);
normalMapCreatorTool.isComputingNormals = 0;
references.matProperties[effectPropNormalMap.propertyIndex].textureValue = savedTex;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 160bf870855ebf849b074fb395bf0e99
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/NormalMapEffectDrawer.cs
uploadId: 865720
@@ -0,0 +1,131 @@
using System.IO;
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class RGBAPackerDrawer
{
private const float LABEL_WIDTH = 70f;
private const float TEXTURE_FIELD_WIDTH = 200f;
private const float SPACING_BETWEEN_FIELDS = 20f;
private const float BOOLEAN_LABEL_WIDTH = 100f;
private const float SETTINGS_FIELD_WIDTH = 200f;
private RGBAPackerTool rgbaPackerTool;
public RGBAPackerValues ToolValues => rgbaPackerTool.values;
private CommonStyles commonStyles;
public RGBAPackerDrawer(RGBAPackerTool rgbaPackerTool, CommonStyles commonStyles)
{
this.rgbaPackerTool = rgbaPackerTool;
this.commonStyles = commonStyles;
}
public void Draw()
{
GUILayout.Label("RGBA Channel Packer", commonStyles.bigLabel);
GUILayout.Space(20);
GUILayout.Label("Pack red channels from 4 textures into RGBA channels", EditorStyles.boldLabel);
GUILayout.Space(10);
// Channel texture slots
EditorGUILayout.BeginVertical();
{
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("R Channel", GUILayout.Width(LABEL_WIDTH));
ToolValues.rChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.rChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
GUILayout.Space(SPACING_BETWEEN_FIELDS);
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
ToolValues.rChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.rChannelDefaultWhite);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("G Channel", GUILayout.Width(LABEL_WIDTH));
ToolValues.gChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.gChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
GUILayout.Space(SPACING_BETWEEN_FIELDS);
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
ToolValues.gChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.gChannelDefaultWhite);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("B Channel", GUILayout.Width(LABEL_WIDTH));
ToolValues.bChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.bChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
GUILayout.Space(SPACING_BETWEEN_FIELDS);
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
ToolValues.bChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.bChannelDefaultWhite);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("A Channel", GUILayout.Width(LABEL_WIDTH));
ToolValues.aChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.aChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
GUILayout.Space(SPACING_BETWEEN_FIELDS);
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
ToolValues.aChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.aChannelDefaultWhite);
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
GUILayout.Space(15);
// Texture settings
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Texture Size:", GUILayout.MaxWidth(100));
ToolValues.textureSizes = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.textureSizes, GUILayout.MaxWidth(SETTINGS_FIELD_WIDTH));
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
GUILayout.Label("Filtering:", GUILayout.MaxWidth(100));
ToolValues.filtering = (FilterMode)EditorGUILayout.EnumPopup(ToolValues.filtering, GUILayout.MaxWidth(SETTINGS_FIELD_WIDTH));
}
EditorGUILayout.EndHorizontal();
GUILayout.Space(10);
// Info about input channels
int channelCount = 0;
if(ToolValues.rChannelTexture != null) channelCount++;
if(ToolValues.gChannelTexture != null) channelCount++;
if(ToolValues.bChannelTexture != null) channelCount++;
if(ToolValues.aChannelTexture != null) channelCount++;
int textureSize = (int)ToolValues.textureSizes;
GUILayout.Label($"Output will be a {textureSize}x{textureSize} RGBA texture with {channelCount}/4 channels assigned", EditorStyles.boldLabel);
if(channelCount == 0)
{
GUILayout.Label("*No input textures assigned - output will use default values", EditorStyles.boldLabel);
}
else if(channelCount < 4)
{
GUILayout.Label($"*{4 - channelCount} channels will use default values (black or white based on toggles)", EditorStyles.boldLabel);
}
GUILayout.Space(20);
GUILayout.Label("Select the folder where RGBA textures will be saved", EditorStyles.boldLabel);
GlobalConfiguration.instance.AtlasesSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.AtlasesSavePath, "RGBA");
if(Directory.Exists(GlobalConfiguration.instance.AtlasesSavePath))
{
if(GUILayout.Button("Create And Save RGBA Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
{
rgbaPackerTool.CreateRGBATexture();
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.AtlasesSavePath, "RGBA_Packed", "RGBA Channel Packed Texture", ToolValues.createdRGBATexture, ToolValues.filtering, TextureImporterType.Default, TextureWrapMode.Clamp);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: abdebde6324c8434180274a2f8375efe
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/RGBAPackerDrawer.cs
uploadId: 865720
@@ -0,0 +1,168 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class TextureBlendingEffectDrawer : AbstractEffectDrawer
{
private int mainTexPropertyIndex;
private EffectProperty mainNormalEffectProperty;
private EffectProperty effectPropBlendingSource;
private EffectProperty effectPropTexBlendingMask;
private EffectProperty effectPropBlendingMaskCutoffG;
private EffectProperty effectPropBlendingMaskSmoothnessG;
private EffectProperty effectPropBlendingMaskCutoffB;
private EffectProperty effectPropBlendingMaskSmoothnessB;
private EffectProperty effectPropBlendingMaskCutoffWhite;
private EffectProperty effectPropBlendingMaskSmoothnessWhite;
private EffectProperty effectPropBlendingMode;
private EffectProperty effectPropBlendingTextureG;
private EffectProperty effectPropBlendingTextureB;
private EffectProperty effectPropBlendingTextureWhite;
private EffectProperty effectPropBlendingNormalMapG;
private EffectProperty effectPropBlendingNormalMapB;
private EffectProperty effectPropBlendingNormalMapWhite;
public TextureBlendingEffectDrawer(EffectProperty mainNormalMapEffectProperty, AllIn13DShaderInspectorReferences references,
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
{
this.drawerID = Constants.TEXTURE_BLENDING_EFFECT_DRAWER_ID;
mainTexPropertyIndex = FindPropertyIndex("_MainTex");
this.mainNormalEffectProperty = mainNormalMapEffectProperty;
this.effectConfig = propertiesConfig.FindEffectConfigByID("TEXTURE_BLENDING");
this.effectPropBlendingSource = effectConfig.FindEffectPropertyByName("_TextureBlendingSource");
this.effectPropTexBlendingMask = effectConfig.FindEffectPropertyByName("_TexBlendingMask");
this.effectPropBlendingMaskCutoffG = effectConfig.FindEffectPropertyByName("_BlendingMaskCutoffG");
this.effectPropBlendingMaskSmoothnessG = effectConfig.FindEffectPropertyByName("_BlendingMaskSmoothnessG");
this.effectPropBlendingMaskCutoffB = effectConfig.FindEffectPropertyByName("_BlendingMaskCutoffB");
this.effectPropBlendingMaskSmoothnessB = effectConfig.FindEffectPropertyByName("_BlendingMaskSmoothnessB");
this.effectPropBlendingMaskCutoffWhite = effectConfig.FindEffectPropertyByName("_BlendingMaskCutoffWhite");
this.effectPropBlendingMaskSmoothnessWhite = effectConfig.FindEffectPropertyByName("_BlendingMaskSmoothnessWhite");
this.effectPropBlendingMode = effectConfig.FindEffectPropertyByName("_TextureBlendingMode");
this.effectPropBlendingTextureG = effectConfig.FindEffectPropertyByName("_BlendingTextureG");
this.effectPropBlendingTextureB = effectConfig.FindEffectPropertyByName("_BlendingTextureB");
this.effectPropBlendingTextureWhite = effectConfig.FindEffectPropertyByName("_BlendingTextureWhite");
this.effectPropBlendingNormalMapG = effectConfig.FindEffectPropertyByName("_BlendingNormalMapG");
this.effectPropBlendingNormalMapB = effectConfig.FindEffectPropertyByName("_BlendingNormalMapB");
this.effectPropBlendingNormalMapWhite = effectConfig.FindEffectPropertyByName("_BlendingNormalMapWhite");
}
protected override void DrawProperties()
{
bool isRGBMode = references.IsKeywordEnabled("_TEXTUREBLENDINGMODE_RGB");
bool isBlendingSourceTexture = references.IsKeywordEnabled("_TEXTUREBLENDINGSOURCE_TEXTURE");
bool isNormalEnabled = references.IsKeywordEnabled("_NORMAL_MAP_ON");
DrawProperty(effectPropBlendingSource);
if(IsEffectPropertyVisible(effectPropTexBlendingMask, references.targetMatInfos))
{
DrawProperty(effectPropTexBlendingMask);
}
DrawProperty(effectPropBlendingMode);
GUILayout.Space(20f);
MaterialProperty matPropertyMainNormalMap = references.matProperties[mainNormalEffectProperty.propertyIndex];
if (isRGBMode)
{
EffectPropertyDrawer.DrawProperty(
materialProperty: references.matProperties[mainTexPropertyIndex],
labelPrefix: string.Empty,
displayName: $"{references.matProperties[mainTexPropertyIndex].displayName} (R)",
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
if (isNormalEnabled)
{
EffectPropertyDrawer.DrawProperty(
materialProperty: matPropertyMainNormalMap,
labelPrefix: string.Empty,
displayName: $"{matPropertyMainNormalMap.displayName} (R)",
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
}
GUILayout.Space(20f);
DrawProperty(effectPropBlendingTextureG);
if (isNormalEnabled)
{
DrawProperty(effectPropBlendingNormalMapG);
}
DrawProperty(effectPropBlendingMaskCutoffG);
DrawProperty(effectPropBlendingMaskSmoothnessG);
GUILayout.Space(20f);
DrawProperty(effectPropBlendingTextureB);
if (isNormalEnabled)
{
DrawProperty(effectPropBlendingNormalMapB);
}
DrawProperty(effectPropBlendingMaskCutoffB);
DrawProperty(effectPropBlendingMaskSmoothnessB);
GUILayout.Space(20f);
}
else
{
EffectPropertyDrawer.DrawProperty(
materialProperty: references.matProperties[mainTexPropertyIndex],
labelPrefix: string.Empty,
displayName: $"{references.matProperties[mainTexPropertyIndex].displayName} (Black)",
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
if (isNormalEnabled)
{
EffectPropertyDrawer.DrawProperty(
materialProperty: matPropertyMainNormalMap,
labelPrefix: string.Empty,
displayName: $"{matPropertyMainNormalMap.displayName} (R)",
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
}
DrawProperty(effectPropBlendingTextureWhite);
if (isNormalEnabled)
{
DrawProperty(effectPropBlendingNormalMapWhite);
}
if (isBlendingSourceTexture)
{
DrawProperty(effectPropBlendingMaskCutoffWhite);
DrawProperty(effectPropBlendingMaskSmoothnessWhite);
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 081c5e8bfd291a145abf082e4835e2b2
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/TextureBlendingEffectDrawer.cs
uploadId: 865720
@@ -0,0 +1,172 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class TextureEditorValuesDrawer
{
private TextureEditorTool textureEditorTool;
private TextureEditorValues values
{
get
{
return textureEditorTool.values;
}
}
private Texture2D editorTexInput
{
get
{
return textureEditorTool.editorTexInput;
}
}
private Texture2D editorTex
{
get
{
return textureEditorTool.editorTex;
}
}
private Texture2D cleanEditorTex
{
get
{
return textureEditorTool.cleanEditorTex;
}
}
private const int BUTTON_WIDTH = 600;
public void Setup(TextureEditorTool textureEditorTool)
{
this.textureEditorTool = textureEditorTool;
}
public void Draw()
{
EditorGUILayout.BeginHorizontal();
if (!values.showOriginalImage)
{
GUILayout.Label(editorTex);
}
else
{
GUILayout.Label(cleanEditorTex);
}
EditorGUILayout.BeginVertical();
EditorGUI.BeginChangeCheck();
EditorUtils.TextureEditorColorParameter("Color Tint", ref values.editorColorTint, Color.white);
EditorUtils.TextureEditorFloatParameter("Brightness", ref values.brightness, -1f, 5f);
EditorUtils.TextureEditorFloatParameter("Contrast", ref values.contrast, 0.0f, 5.0f, 1f);
EditorUtils.TextureEditorFloatParameter("Gamma", ref values.gamma, 0.0f, 10f, 1f);
EditorUtils.TextureEditorFloatParameter("Exposure", ref values.exposure, -5f, 5f, 0f);
EditorUtils.TextureEditorFloatParameter("Saturation", ref values.saturation, 0f, 5f, 1f);
EditorUtils.TextureEditorFloatParameter("Hue", ref values.hue, 0f, 360f, 0f);
EditorGUILayout.BeginHorizontal();
{
values.invert = EditorGUILayout.Toggle("Invert", values.invert, GUILayout.Width(253));
values.greyscale = EditorGUILayout.Toggle("Greyscale", values.greyscale);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
values.fullWhite = EditorGUILayout.Toggle("Fully white", values.fullWhite, GUILayout.Width(253));
values.blackBackground = EditorGUILayout.Toggle("Black background", values.blackBackground);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
values.alphaGreyscale = EditorGUILayout.Toggle("Greyscale is alpha", values.alphaGreyscale, GUILayout.Width(253));
values.alphaIsOne = EditorGUILayout.Toggle("Alpha to 1", values.alphaIsOne);
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
textureEditorTool.RecalculateEditorTexture();
}
EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal();
{
if (GUILayout.Button("Rotate Left 90°", GUILayout.MaxWidth(210)))
{
textureEditorTool.RotateEditorTextureLeft();
}
if (GUILayout.Button("Rotate Right 90°", GUILayout.MaxWidth(210)))
{
for (int i = 0; i < 3; i++)
{
textureEditorTool.RotateEditorTextureLeft();
}
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
{
if (GUILayout.Button("Flip Horizontal", GUILayout.MaxWidth(210)))
{
textureEditorTool.FlipEditorTexture(true);
}
if (GUILayout.Button("Flip Vertical", GUILayout.MaxWidth(210)))
{
textureEditorTool.FlipEditorTexture(false);
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
if (!values.showOriginalImage)
{
if (GUILayout.Button("Press to show Original Image", GUILayout.MaxWidth(425)))
{
values.showOriginalImage = true;
}
}
else
{
Color backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = Color.red;
if (GUILayout.Button("Press to show Editor Image", GUILayout.MaxWidth(425)))
{
values.showOriginalImage = false;
}
GUI.backgroundColor = backgroundColor;
}
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
GUILayout.Label("*Preview is locked to 256px maximum (bigger textures are scaled down), but the image will be saved to its full resolution", EditorStyles.boldLabel);
EditorUtils.DrawThinLine();
EditorGUILayout.Space();
EditorUtils.TextureEditorFloatParameter("Export Scale", ref values.exportScale, 0.01f, 2f, 1f);
int currWidth = Mathf.ClosestPowerOfTwo((int)(editorTexInput.width * values.exportScale));
int currHeight = Mathf.ClosestPowerOfTwo((int)(editorTexInput.height * values.exportScale));
GUILayout.Label("Current export size is: " + currWidth + " x " + currHeight + " (size snaps to the closest power of 2)", EditorStyles.boldLabel);
if (GUILayout.Button("Save Resulting Image as PNG file", GUILayout.MaxWidth(BUTTON_WIDTH)))
{
textureEditorTool.SaveAsPNG();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d9909526746655a4a9be1aaef56a41b9
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/TextureEditorValuesDrawer.cs
uploadId: 865720
@@ -0,0 +1,63 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class TriplanarEffectDrawer : AbstractEffectDrawer
{
private int mainTexPropertyIndex;
private EffectProperty mainNormalMapProperty;
public TriplanarEffectDrawer(EffectProperty mainNormalMapProperty, AllIn13DShaderInspectorReferences references,
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
{
this.drawerID = Constants.TRIPLANAR_EFFECT_DRAWER_ID;
this.mainNormalMapProperty = mainNormalMapProperty;
mainTexPropertyIndex = FindPropertyIndex("_MainTex");
}
protected override void DrawProperties()
{
bool isTriplanarNoiseTransitionEnabled = references.IsKeywordEnabled("_TRIPLANAR_NOISE_TRANSITION_ON");
MaterialProperty matProperty = references.matProperties[mainTexPropertyIndex];
EffectPropertyDrawer.DrawProperty(
materialProperty: matProperty,
labelPrefix: string.Empty,
displayName: matProperty.displayName,
customValue: string.Empty,
allowReset: true,
isKeywordProperty: false,
propertyType: EffectProperty.PropertyType.BASIC,
references: references);
EffectProperty triplanarNoiseTransitionToggleProperty = effectConfig.effectProperties[6];
DrawProperty(effectConfig.effectProperties[0]);
DrawProperty(effectConfig.effectProperties[1]);
if (IsEffectPropertyVisible(mainNormalMapProperty, references.targetMatInfos))
{
EditorUtils.DrawLine(Color.grey, 1, 3);
DrawProperty(mainNormalMapProperty, false);
DrawProperty(effectConfig.effectProperties[2]);
}
EditorUtils.DrawLine(Color.grey, 1, 3);
DrawProperty(effectConfig.effectProperties[3]);
DrawProperty(effectConfig.effectProperties[4]);
EditorUtils.DrawLine(Color.grey, 1, 3);
DrawProperty(effectConfig.effectProperties[5]);
DrawProperty(triplanarNoiseTransitionToggleProperty);
if (isTriplanarNoiseTransitionEnabled)
{
DrawProperty(effectConfig.effectProperties[7]);
DrawProperty(effectConfig.effectProperties[8]);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 580ede76f9fd8d844ab570643abe14cd
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/TriplanarEffectDrawer.cs
uploadId: 865720
@@ -0,0 +1,40 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class Vector2Drawer : MaterialPropertyDrawer
{
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
{
AllIn1ShaderPropertyType propType = EditorUtils.GetShaderTypeByMaterialProperty(prop);
if (propType != AllIn1ShaderPropertyType.Vector)
{
EditorGUI.LabelField(position, label, "Vector3Drawer only works with Vector properties.");
return;
}
EditorGUI.BeginChangeCheck();
// Get current vector4 value
Vector4 vec4Value = prop.vectorValue;
// Convert to Vector2 for editing
Vector2 vec2Value = new Vector2(vec4Value.x, vec4Value.y);
// Create property field for Vector3
vec2Value = EditorGUI.Vector2Field(position, label, vec2Value);
if (EditorGUI.EndChangeCheck())
{
// Convert back to Vector4, preserving the w component
prop.vectorValue = new Vector4(vec2Value.x, vec2Value.y, vec4Value.z, vec4Value.w);
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
return EditorGUIUtility.singleLineHeight;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 87a63d9b7f80f9f4bbbe3ae4dc5b0e2a
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/Vector2Drawer.cs
uploadId: 865720
@@ -0,0 +1,38 @@
using UnityEditor;
using UnityEngine;
namespace AllIn13DShader
{
public class Vector3Drawer : MaterialPropertyDrawer
{
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
{
AllIn1ShaderPropertyType propType = EditorUtils.GetShaderTypeByMaterialProperty(prop);
if (propType != AllIn1ShaderPropertyType.Vector) {
EditorGUI.LabelField(position, label, "Vector3Drawer only works with Vector properties.");
return;
}
EditorGUI.BeginChangeCheck();
// Get current vector4 value
Vector4 vec4Value = prop.vectorValue;
// Convert to Vector3 for editing
Vector3 vec3Value = new Vector3(vec4Value.x, vec4Value.y, vec4Value.z);
// Create property field for Vector3
vec3Value = EditorGUI.Vector3Field(position, label, vec3Value);
if(EditorGUI.EndChangeCheck()) {
// Convert back to Vector4, preserving the w component
prop.vectorValue = new Vector4(vec3Value.x, vec3Value.y, vec3Value.z, vec4Value.w);
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
return EditorGUIUtility.singleLineHeight;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ba6a058864ddc094aa1e321cab78ebd2
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/Vector3Drawer.cs
uploadId: 865720