Skip to content

Commit

Permalink
Version 2.0
Browse files Browse the repository at this point in the history
It's been a while but I've finally finished my big overhaul of the backend systems.
What does that mean for you?
Absolutely nothing!
But it means for me that I'll have a lot less headaches updating and adding on new functionality for shaders.
I have touched up on a couple things:
-Cleaned out some older, obsolete versions
-Updated the Stealth shader for the first time in forever (still be careful, haven't testing it in-game)
-Updated Fader Shader with another variant to apply a normal map specifically to the 2nd matcap as well as functionality so that it doesn't overwrite itself.
  • Loading branch information
Rhyperi committed Feb 13, 2020
1 parent aa4a8b7 commit 15fc447
Show file tree
Hide file tree
Showing 26 changed files with 1,157 additions and 3,023 deletions.
13 changes: 13 additions & 0 deletions Lit + MMD Spheres/Editor/RhyEditorVariables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;

namespace publicVariables
{
public class shaderVariables
{
//Editor Variables
public static string versionNumber = "2.0";
}
}
66 changes: 23 additions & 43 deletions Lit + MMD Spheres/Editor/RhyFlatLitMMDEditor - 2xEmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using publicVariables;

public class RhyFlatLitMMDEditor2xEmission : ShaderGUI
{

public enum OutlineMode
public enum CullMode
{
None,
Tinted,
Colored
Front,
Back
}

public enum BlendMode
Expand All @@ -22,6 +22,7 @@ public enum BlendMode
}

MaterialProperty blendMode;
MaterialProperty cullMode;
MaterialProperty mainTexture;
MaterialProperty opacity;
MaterialProperty color;
Expand All @@ -33,6 +34,7 @@ public enum BlendMode
MaterialProperty sphereMulTexture;
MaterialProperty sphereMulIntensity;
MaterialProperty toonTex;
MaterialProperty shadowTex;
MaterialProperty defaultLightDir;
MaterialProperty emissionMap;
MaterialProperty emissionColor;
Expand All @@ -55,6 +57,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
{
{ //Find Properties
blendMode = FindProperty("_Mode", props);
cullMode = FindProperty("_Cull", props);
mainTexture = FindProperty("_MainTex", props);
opacity = FindProperty("_Opacity", props);
color = FindProperty("_Color", props);
Expand All @@ -66,6 +69,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
sphereMulTexture = FindProperty("_SphereMulTex", props);
sphereMulIntensity = FindProperty("_SphereMulIntensity", props);
toonTex = FindProperty("_ToonTex", props);
shadowTex = FindProperty("_ShadowTex", props);
defaultLightDir = FindProperty("_DefaultLightDir", props);
emissionMap = FindProperty("_EmissionMap", props);
emissionColor = FindProperty("_EmissionColor", props);
Expand All @@ -92,7 +96,10 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
EditorGUI.BeginChangeCheck();
{
EditorGUI.showMixedValue = blendMode.hasMixedValue;
EditorGUI.showMixedValue = cullMode.hasMixedValue;

var bMode = (BlendMode)blendMode.floatValue;
var cMode = (CullMode)cullMode.floatValue;

EditorGUI.BeginChangeCheck();
GUILayout.Label("-General Textures-", EditorStyles.boldLabel);
Expand All @@ -107,14 +114,22 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
SetupMaterialWithBlendMode((Material)obj, (BlendMode)material.GetFloat("_Mode"));
}
}
cMode = (CullMode)EditorGUILayout.Popup("Cull Mode", (int)cMode, Enum.GetNames(typeof(CullMode)));
if (EditorGUI.EndChangeCheck())
{
materialEditor.RegisterPropertyChangeUndo("Rendering Mode");
cullMode.floatValue = (float)cMode;
}

EditorGUI.showMixedValue = false;
materialEditor.TexturePropertySingleLine(new GUIContent("Main Texture", "Main Color Texture"), mainTexture, color);
EditorGUI.indentLevel += 2;

if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout)
materialEditor.ShaderProperty(alphaCutoff, "Alpha Cutoff", 2);
if ((BlendMode)material.GetFloat("_Mode") == BlendMode.Transparent)
materialEditor.ShaderProperty(opacity, "Opacity", 1);

materialEditor.ShaderProperty(colIntensity, "Color Intensity", 2);
materialEditor.TexturePropertySingleLine(new GUIContent("Color Mask", "Masks Color Tinting"), colorMask);
EditorGUI.indentLevel -= 2;
Expand All @@ -131,6 +146,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
GUILayout.Space(6);
GUILayout.Label("-Toon Ramp-", EditorStyles.boldLabel);
materialEditor.TexturePropertySingleLine(new GUIContent("Toon Texture"), toonTex);
materialEditor.TexturePropertySingleLine(new GUIContent("Shadow Texture"), shadowTex);
materialEditor.VectorProperty(defaultLightDir, "Default Light Direction");
GUILayout.Label("-Normal Maps-", EditorStyles.boldLabel);
materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map"), normalMap);
Expand All @@ -154,7 +170,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
materialEditor.ShaderProperty(speedY2, new GUIContent("2nd Mask Y Scroll Speed"), 0);
EditorGUI.indentLevel -= 2;
GUILayout.Space(20);
GUILayout.Label("Version: 1.82 - 2x Emission");
GUILayout.Label("Version: " + shaderVariables.versionNumber + " - 2x Emission");
EditorGUI.BeginChangeCheck();


Expand All @@ -174,65 +190,29 @@ public static void SetupMaterialWithBlendMode(Material material, BlendMode blend
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
break;
case BlendMode.Cutout:
material.SetOverrideTag("RenderType", "TransparentCutout");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest;
break;
case BlendMode.Fade:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
break;
case BlendMode.Transparent:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
break;
}
}

public static void SetupMaterialWithOutlineMode(Material material, OutlineMode outlineMode)
{
switch ((OutlineMode)material.GetFloat("_OutlineMode"))
{
case OutlineMode.None:
material.EnableKeyword("NO_OUTLINE");
material.DisableKeyword("TINTED_OUTLINE");
material.DisableKeyword("COLORED_OUTLINE");
break;
case OutlineMode.Tinted:
material.DisableKeyword("NO_OUTLINE");
material.EnableKeyword("TINTED_OUTLINE");
material.DisableKeyword("COLORED_OUTLINE");
break;
case OutlineMode.Colored:
material.DisableKeyword("NO_OUTLINE");
material.DisableKeyword("TINTED_OUTLINE");
material.EnableKeyword("COLORED_OUTLINE");
break;
default:
break;
}
}
}
Loading

0 comments on commit 15fc447

Please sign in to comment.