Skip to content

Commit

Permalink
added Simple Ice shader
Browse files Browse the repository at this point in the history
  • Loading branch information
orels1 committed Jan 18, 2021
1 parent 9031c63 commit e6b64e3
Show file tree
Hide file tree
Showing 35 changed files with 2,874 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.autosave
23 changes: 21 additions & 2 deletions Editor/ORS1MaterialEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,28 @@
public class ORS1MaterialEditor : ShaderGUI {
private Texture headerImage;
private bool headerFailed;
private string helpLink;
private bool noHelpLink;

public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) {
try {
if (!headerFailed) {
if (headerImage == null) {
if (!headerFailed && !noHelpLink) {
if (headerImage == null || helpLink == null) {
var shaderName = (materialEditor.target as Material).shader.name;
if (shaderName.StartsWith("orels1") || shaderName.StartsWith("ors1")) {
headerImage = ORS1ShaderMap.GetShaderHeaderTexture(shaderName);
helpLink = ORS1ShaderMap.GetShaderHelpLink(shaderName);
if (headerImage == null) {
headerFailed = true;
}

if (helpLink == null) {
noHelpLink = true;
}
}
else {
headerFailed = true;
noHelpLink = true;
}
}

Expand All @@ -25,10 +36,18 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
var rect = EditorGUILayout.GetControlRect(GUILayout.Height(64));
GUI.DrawTexture(rect, headerImage, ScaleMode.ScaleToFit);
}

if (!noHelpLink) {
if (GUILayout.Button(new GUIContent("Check out the docs"), GUILayout.Height(15))) {
Application.OpenURL(helpLink);
}
EditorGUILayout.Space();
}
}
}
catch {
headerFailed = true;
noHelpLink = true;
}
EditorGUI.BeginChangeCheck();
base.OnGUI(materialEditor, properties);
Expand Down
18 changes: 17 additions & 1 deletion Editor/ORS1ShaderMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ namespace orels1 {
public class ORS1ShaderMap {
private static Dictionary<string, string> shaderMap = new Dictionary<string, string> {
{"ProgramWaveNoise", "ProgramWave"},
{"ProgramWaveSimple", "ProgramWave"}
{"ProgramWaveSimple", "ProgramWave"},
{"SimpleIce", "SimpleIce"}
};

private static Dictionary<string, string> docsMap = new Dictionary<string, string> {
{"ProgramWaveNoise", "https://shaders.orels.sh/shaders/program-wave"},
{"ProgramWaveSimple", "https://shaders.orels.sh/shaders/program-wave"},
{"SimpleIce", "https://shaders.orels.sh/shaders/simple-ice"}
};

public static Texture GetShaderHeaderTexture(string shaderName) {
Expand All @@ -17,5 +24,14 @@ public static Texture GetShaderHeaderTexture(string shaderName) {
}
return null;
}

public static string GetShaderHelpLink(string shaderName) {
var linkKey = shaderName.Substring(shaderName.IndexOf("/") + 1);
linkKey = linkKey.Replace(" ", "");
if (docsMap.ContainsKey(linkKey)) {
return docsMap[linkKey];
}
return null;
}
}
}
2 changes: 1 addition & 1 deletion Program Wave/Program Wave Small Simple.mat
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Material:
- _AutoSweepSpeed: 2.88
- _GlobalMaskContrastMax: 0.31
- _GlobalMaskContrastMin: -0.02
- _GlobalSweep: 0.659
- _GlobalSweep: 0.594
- _GlossyReflections: 1
- _MaxWaveHeight: 2.94
- _Metallic: 1
Expand Down
Binary file added Resources/ors1_SimpleIce.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions Resources/ors1_SimpleIce.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Simple Ice.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Simple Ice/Ice Base.fbx
Binary file not shown.
97 changes: 97 additions & 0 deletions Simple Ice/Ice Base.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Simple Ice/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
In the Shader Previews I am using a free albedo texture from [textures.com](https://www.textures.com/download/pbr0169/133204)

I cannot package it with the shader due to their ToS, so I am providing a simple texture in a similar-ish style that I made myself.

I highly recommend grabbing a better albedo texture if you are going to use the shader.
You can leave the rest as is, they should be good enough out of the box.

But feel free to customize and experiment!
7 changes: 7 additions & 0 deletions Simple Ice/README.MD.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e6b64e3

Please sign in to comment.