Skip to content

Commit

Permalink
Merge pull request #48 from Xiexe/development
Browse files Browse the repository at this point in the history
Development to master 3.5.0
  • Loading branch information
Xiexe authored Feb 10, 2024
2 parents 3a45c02 + d09e5ae commit 15fd63d
Show file tree
Hide file tree
Showing 57 changed files with 2,645 additions and 317 deletions.
54 changes: 4 additions & 50 deletions Editor/XSStyles.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEditor;
using UnityEngine;
using System.IO;

namespace XSToon3
{
[InitializeOnLoad]
public class XSStyles : MonoBehaviour
{
public static string ver = "3.0.2";

//Help URLs
public static string mainURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.xh0nk8x7ws1g";
public static string normalsURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.j7qze9btrmw8";
public static string shadowsURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.8l0gi0hntyfs";
public static string rimlightURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.tpxp2jrhrhxp";
public static string emissionsURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.zc983jrwb5x4";
public static string specularURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.gyu8l75mbtdq";
public static string reflURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.yqzg9axi3gi";
public static string sssURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.j2nk83f6azph";
public static string outlineURL = "https://docs.google.com/document/d/1xJ4PID_nwqVm_UCsO2c2gEdiEoWoCGeM_GDK_L8-aZE/edit#bookmark=id.jpaf9t25in8p";

public static string ver = "3.5.0";
public static string uiPath;
private static string patronpath;

Expand Down Expand Up @@ -99,19 +86,15 @@ static public GUIStyle LineStyle
//GUI Buttons
static public void CallGradientEditor(Material focusedMat = null, string prop = null)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.skin = null;
if (GUILayout.Button("Open Gradient Editor", GUILayout.Width(200), GUILayout.Height(20)))
if (GUILayout.Button("Ramp Tool \u2197\ufe0f", GUILayout.Height(20)))
{
XSGradientEditor.focusedMat = focusedMat;
if (prop != null) {
XSGradientEditor.rampProperty = prop;
}
XSGradientEditor.Init();
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

static public void CallTexArrayManager()
Expand Down Expand Up @@ -241,12 +224,6 @@ public static void helpPopup(string url)//bool showBox, string title, string mes
if (GUILayout.Button("?", "helpButton", GUILayout.Width(16), GUILayout.Height(16)))
{
Application.OpenURL(url);
// showBox = true;
// if (showBox == true)
// {
// EditorUtility.DisplayDialog(title,
// message, button);
// }
}
}

Expand Down Expand Up @@ -283,26 +260,6 @@ public static void discordButton(int Width, int Height)

}

public static void patreonButton(int Width, int Height)
{
if (GUILayout.Button("Patreon", GUILayout.Width(Width), GUILayout.Height(Height)))
{
Application.OpenURL("https://www.patreon.com/xiexe");
}
}

public static void openInfoPanel(int Width, int Height)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Updater | Documentation", GUILayout.Width(Width), GUILayout.Height(Height)))
{
XSUpdater.Init();
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

private static Rect DrawShuriken(string title, Vector2 contentOffset, int HeaderHeight)
{
var style = new GUIStyle("ShurikenModuleTitle");
Expand Down Expand Up @@ -369,12 +326,9 @@ public static void DoFooter()
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
XSStyles.discordButton(70, 30);
XSStyles.patreonButton(70, 30);
XSStyles.githubButton(70, 30);
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();

XSStyles.openInfoPanel(200, 20);
}

public static bool HelpBoxWithButton(GUIContent messageContent, GUIContent buttonContent)
Expand Down
68 changes: 38 additions & 30 deletions Editor/XSToonInspector.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Reflection;

namespace XSToon3
Expand All @@ -27,6 +24,14 @@ public partial class FoldoutToggles
public bool ShowFur = false;
}

public enum Mode
{
Opaque,
Cutout,
Fade,
Transparent
}

public class XSToonInspector : ShaderGUI
{
protected static Dictionary<Material, FoldoutToggles> Foldouts = new Dictionary<Material, FoldoutToggles>();
Expand Down Expand Up @@ -186,7 +191,7 @@ public class XSToonInspector : ShaderGUI
protected MaterialProperty _ClipSlider14 = null;
protected MaterialProperty _ClipSlider15 = null;

//Material Properties for Patreon Plugins
//Material Properties for Eye tracking Plugins
protected MaterialProperty _LeftRightPan = null;
protected MaterialProperty _UpDownPan = null;
protected MaterialProperty _Twitchyness = null;
Expand Down Expand Up @@ -222,7 +227,6 @@ public class XSToonInspector : ShaderGUI

private static bool OverrideRenderSettings = false;
protected static int BlendMode;
protected bool isPatreonShader = false;
protected bool isEyeTracking = false;
protected bool isFurShader = false;
protected bool isOutlined = false;
Expand All @@ -241,7 +245,6 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
isDithered = BlendMode == 2;
isA2C = BlendMode == 3;
isOutlined = shader.name.Contains("Outline");
isPatreonShader = shader.name.Contains("Patreon");
isEyeTracking = shader.name.Contains("EyeTracking");
isFurShader = shader.name.Contains("Fur");

Expand All @@ -258,7 +261,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
}

EditorGUI.BeginChangeCheck();
XSStyles.ShurikenHeaderCentered("XSToon v" + XSStyles.ver);
XSStyles.ShurikenHeaderCentered($"XSToon v{XSStyles.ver}");
materialEditor.ShaderProperty(_AdvMode, new GUIContent("Shader Mode", "Setting this to 'Advanced' will give you access to things such as stenciling, and other expiremental/advanced features."));
materialEditor.ShaderProperty(_Culling, new GUIContent("Culling Mode", "Changes the culling mode. 'Off' will result in a two sided material, while 'Front' and 'Back' will cull those sides respectively"));
materialEditor.ShaderProperty(_TilingMode, new GUIContent("Tiling Mode", "Setting this to Merged will tile and offset all textures based on the Main texture's Tiling/Offset."));
Expand Down Expand Up @@ -293,7 +296,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
PluginGUI(materialEditor, material);

DrawAdvancedSettings(materialEditor, material);
DrawPatreonSettings(materialEditor, material);
DrawEyeTrackingSettings(materialEditor, material);

//!RDPSFunctionCallInject

Expand All @@ -320,6 +323,7 @@ private void DoBlendModeSettings(Material material)
switch (BlendMode)
{
case 0: //Opaque
material.SetInt("_Mode", (int)Mode.Opaque);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.BlendMode.Zero,
(int) UnityEngine.Rendering.RenderQueue.Geometry, 1, 0);
Expand All @@ -328,6 +332,7 @@ private void DoBlendModeSettings(Material material)
break;

case 1: //Cutout
material.SetInt("_Mode", (int)Mode.Cutout);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.BlendMode.Zero,
(int) UnityEngine.Rendering.RenderQueue.AlphaTest, 1, 0);
Expand All @@ -336,6 +341,7 @@ private void DoBlendModeSettings(Material material)
break;

case 2: //Dithered
material.SetInt("_Mode", (int)Mode.Cutout);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.BlendMode.Zero,
(int) UnityEngine.Rendering.RenderQueue.AlphaTest, 1, 0);
Expand All @@ -344,6 +350,7 @@ private void DoBlendModeSettings(Material material)
break;

case 3: //Alpha To Coverage
material.SetInt("_Mode", (int)Mode.Cutout);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.BlendMode.Zero,
(int) UnityEngine.Rendering.RenderQueue.AlphaTest, 1, 1);
Expand All @@ -352,6 +359,7 @@ private void DoBlendModeSettings(Material material)
break;

case 4: //Transparent
material.SetInt("_Mode", (int)Mode.Transparent);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha,
(int) UnityEngine.Rendering.RenderQueue.Transparent, 0, 0);
Expand All @@ -360,6 +368,7 @@ private void DoBlendModeSettings(Material material)
break;

case 5: //Fade
material.SetInt("_Mode", (int)Mode.Fade);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.SrcAlpha,
(int) UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha,
(int) UnityEngine.Rendering.RenderQueue.Transparent, 0, 0);
Expand All @@ -368,6 +377,7 @@ private void DoBlendModeSettings(Material material)
break;

case 6: //Additive
material.SetInt("_Mode", (int)Mode.Transparent);
SetBlend(material, (int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.BlendMode.One,
(int) UnityEngine.Rendering.RenderQueue.Transparent, 0, 0);
Expand Down Expand Up @@ -462,8 +472,11 @@ private void DrawShadowSettings(MaterialEditor materialEditor, Material material
}
}

XSStyles.CallGradientEditor(material);
materialEditor.TexturePropertySingleLine(new GUIContent("Shadow Ramp", "Shadow Ramp, Dark to Light should be Left to Right"), _Ramp);
GUILayout.BeginHorizontal();
materialEditor.TexturePropertySingleLine(new GUIContent("Shadow Ramp", "Shadow Ramp, Dark to Light should be Left to Right"), _Ramp);
XSStyles.CallGradientEditor(material);
GUILayout.EndHorizontal();

materialEditor.ShaderProperty(_ShadowSharpness, new GUIContent("Shadow Sharpness", "Controls the sharpness of recieved shadows, as well as the sharpness of 'shadows' from Vertex Lighting."));

XSStyles.SeparatorThin();
Expand Down Expand Up @@ -777,33 +790,28 @@ private void DrawAdvancedSettings(MaterialEditor materialEditor, Material materi
}
}

private void DrawPatreonSettings(MaterialEditor materialEditor, Material material)
private void DrawEyeTrackingSettings(MaterialEditor materialEditor, Material material)
{
//Plugins for Patreon releases
if (isPatreonShader)
if (isEyeTracking)
{
if (isEyeTracking)
Foldouts[material].ShowEyeTracking = XSStyles.ShurikenFoldout("Eye Tracking Settings", Foldouts[material].ShowEyeTracking);
if (Foldouts[material].ShowEyeTracking)
{
Foldouts[material].ShowEyeTracking = XSStyles.ShurikenFoldout("Eye Tracking Settings", Foldouts[material].ShowEyeTracking);
if (Foldouts[material].ShowEyeTracking)
{
materialEditor.ShaderProperty(_LeftRightPan, new GUIContent("Left Right Adj.", "Adjusts the eyes manually left or right."));
materialEditor.ShaderProperty(_UpDownPan, new GUIContent("Up Down Adj.", "Adjusts the eyes manually up or down."));
materialEditor.ShaderProperty(_LeftRightPan, new GUIContent("Left Right Adj.", "Adjusts the eyes manually left or right."));
materialEditor.ShaderProperty(_UpDownPan, new GUIContent("Up Down Adj.", "Adjusts the eyes manually up or down."));

XSStyles.SeparatorThin();
materialEditor.ShaderProperty(_AttentionSpan, new GUIContent("Attention Span", "How often should the eyes look at the target; 0 = never, 1 = always, 0.5 = half of the time."));
materialEditor.ShaderProperty(_FollowPower, new GUIContent("Follow Power", "The influence the target has on the eye"));
materialEditor.ShaderProperty(_LookSpeed, new GUIContent("Look Speed", "How fast the eye transitions to looking at the target"));
materialEditor.ShaderProperty(_Twitchyness, new GUIContent("Refocus Frequency", "How much should the eyes look around near the target?"));
XSStyles.SeparatorThin();
materialEditor.ShaderProperty(_AttentionSpan, new GUIContent("Attention Span", "How often should the eyes look at the target; 0 = never, 1 = always, 0.5 = half of the time."));
materialEditor.ShaderProperty(_FollowPower, new GUIContent("Follow Power", "The influence the target has on the eye"));
materialEditor.ShaderProperty(_LookSpeed, new GUIContent("Look Speed", "How fast the eye transitions to looking at the target"));
materialEditor.ShaderProperty(_Twitchyness, new GUIContent("Refocus Frequency", "How much should the eyes look around near the target?"));

XSStyles.SeparatorThin();
materialEditor.ShaderProperty(_IrisSize, new GUIContent("Iris Size", "Size of the iris"));
materialEditor.ShaderProperty(_FollowLimit, new GUIContent("Follow Limit", "Limits the angle from the front of the face on how far the eyes can track/rotate."));
materialEditor.ShaderProperty(_EyeOffsetLimit, new GUIContent("Offset Limit", "Limit for how far the eyes can turn"));
}
XSStyles.SeparatorThin();
materialEditor.ShaderProperty(_IrisSize, new GUIContent("Iris Size", "Size of the iris"));
materialEditor.ShaderProperty(_FollowLimit, new GUIContent("Follow Limit", "Limits the angle from the front of the face on how far the eyes can track/rotate."));
materialEditor.ShaderProperty(_EyeOffsetLimit, new GUIContent("Offset Limit", "Limit for how far the eyes can turn"));
}
}
//
}

private void DrawFurSettings(MaterialEditor materialEditor, Material material)
Expand Down
Loading

0 comments on commit 15fd63d

Please sign in to comment.