-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added first iteration of shader gui for the unlit TMP3D shader Renamed some shader keywords for better reflecting their usage
- Loading branch information
Showing
7 changed files
with
327 additions
and
126 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Ikaroon.TMP3D.Editor", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:6546d7765b4165b40850b3667f981c26", | ||
"GUID:6055be8ebefd69e48b49212b09b47b2f" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
using TMPro.EditorUtilities; | ||
using TMPro; | ||
|
||
namespace Ikaroon.TMP3DEditor | ||
{ | ||
public class TMP3D_UnlitShaderGUI : TMP_BaseShaderGUI | ||
{ | ||
public enum VolumeMode | ||
{ | ||
Surface, | ||
Full | ||
} | ||
|
||
static ShaderFeature s_OutlineFeature; | ||
|
||
static bool s_Face = true; | ||
static bool s_Outline = true; | ||
static bool s_Raymarch = true; | ||
|
||
const string c_volumeModeSurface = "_VOLUMEMODE_SURFACE"; | ||
const string c_volumeModeFull = "_VOLUMEMODE_FULL"; | ||
|
||
static TMP3D_UnlitShaderGUI() | ||
{ | ||
s_OutlineFeature = new ShaderFeature() | ||
{ | ||
undoLabel = "Outline", | ||
keywords = new[] { "OUTLINE_ON" } | ||
}; | ||
} | ||
|
||
VolumeMode GetVolumeMode(Material material) | ||
{ | ||
if (material.IsKeywordEnabled(c_volumeModeSurface)) | ||
return VolumeMode.Surface; | ||
|
||
if (material.IsKeywordEnabled(c_volumeModeFull)) | ||
return VolumeMode.Full; | ||
|
||
material.EnableKeyword(c_volumeModeSurface); | ||
return VolumeMode.Surface; | ||
} | ||
|
||
protected override void DoGUI() | ||
{ | ||
s_Face = BeginPanel("Face", s_Face); | ||
if (s_Face) | ||
{ | ||
DoFacePanel(); | ||
} | ||
|
||
EndPanel(); | ||
|
||
s_Outline = BeginPanel("Outline", s_OutlineFeature, s_Outline); | ||
if (s_Outline) | ||
{ | ||
DoOutlinePanel(); | ||
} | ||
|
||
EndPanel(); | ||
|
||
s_Raymarch = BeginPanel("Raymarch", s_Raymarch); | ||
if (s_Raymarch) | ||
{ | ||
DoRaymarchPanel(); | ||
} | ||
|
||
EndPanel(); | ||
|
||
s_DebugExtended = BeginPanel("Debug Settings", s_DebugExtended); | ||
if (s_DebugExtended) | ||
{ | ||
DoDebugPanel(); | ||
} | ||
|
||
EndPanel(); | ||
} | ||
|
||
void DoFacePanel() | ||
{ | ||
EditorGUI.indentLevel += 1; | ||
|
||
DoColor("_FaceColor", "Color"); | ||
|
||
EditorGUI.indentLevel -= 1; | ||
EditorGUILayout.Space(); | ||
} | ||
|
||
void DoOutlinePanel() | ||
{ | ||
EditorGUI.indentLevel += 1; | ||
DoColor("_OutlineColor", "Color"); | ||
DoSlider("_OutlineWidth", "Thickness"); | ||
|
||
EditorGUI.indentLevel -= 1; | ||
EditorGUILayout.Space(); | ||
} | ||
|
||
void DoRaymarchPanel() | ||
{ | ||
EditorGUI.indentLevel += 1; | ||
|
||
var mode = GetVolumeMode(m_Material); | ||
var targetMode = (VolumeMode)EditorGUILayout.EnumPopup(new GUIContent("Volume Mode"), mode); | ||
if (targetMode != mode) | ||
{ | ||
switch (targetMode) | ||
{ | ||
case VolumeMode.Surface: | ||
m_Material.EnableKeyword(c_volumeModeSurface); | ||
m_Material.DisableKeyword(c_volumeModeFull); | ||
break; | ||
case VolumeMode.Full: | ||
m_Material.EnableKeyword(c_volumeModeFull); | ||
m_Material.DisableKeyword(c_volumeModeSurface); | ||
break; | ||
} | ||
} | ||
|
||
DoSlider("_RaymarchMinStep", "Min Step"); | ||
|
||
EditorGUI.indentLevel -= 1; | ||
EditorGUILayout.Space(); | ||
} | ||
|
||
void DoDebugPanel() | ||
{ | ||
EditorGUI.indentLevel += 1; | ||
DoTexture2D("_MainTex", "Font Atlas"); | ||
DoFloat("_GradientScale", "Gradient Scale"); | ||
DoFloat("_TextureWidth", "Texture Width"); | ||
DoFloat("_TextureHeight", "Texture Height"); | ||
EditorGUILayout.Space(); | ||
DoFloat("_ScaleX", "Scale X"); | ||
DoFloat("_ScaleY", "Scale Y"); | ||
|
||
DoSlider("_PerspectiveFilter", "Perspective Filter"); | ||
EditorGUILayout.Space(); | ||
DoFloat("_VertexOffsetX", "Offset X"); | ||
DoFloat("_VertexOffsetY", "Offset Y"); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
EditorGUI.BeginDisabledGroup(true); | ||
DoFloat("_ScaleRatioA", "Scale Ratio A"); | ||
DoFloat("_ScaleRatioB", "Scale Ratio B"); | ||
DoFloat("_ScaleRatioC", "Scale Ratio C"); | ||
EditorGUI.EndDisabledGroup(); | ||
EditorGUI.indentLevel -= 1; | ||
EditorGUILayout.Space(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.