Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteflare committed Jul 13, 2019
2 parents 58e7322 + e039db7 commit 7d2b3cd
Show file tree
Hide file tree
Showing 20 changed files with 539 additions and 400 deletions.
45 changes: 45 additions & 0 deletions Editor/WF_ShaderCustomEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
}
// 描画
materialEditor.ShaderProperty(prop, prop.displayName);

if (prop.name == "_TS_BaseTex") {
Rect position = EditorGUILayout.GetControlRect(true, 24);
Rect fieldpos = EditorGUI.PrefixLabel(position, new GUIContent("[SH] Shade Color Suggest", "ベース色をもとに1影2影色を設定します"));
fieldpos.height = 20;
if (GUI.Button(fieldpos, "APPLY")) {
SuggestShadowColor(materialEditor.targets);
}
}
}

EditorGUILayout.Space();
Expand All @@ -65,6 +74,42 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
materialEditor.EnableInstancingField();
//materialEditor.DoubleSidedGIField();
}

private void SuggestShadowColor(object[] targets) {
foreach (object obj in targets) {
Material m = obj as Material;
if (m == null) {
continue;
}
Undo.RecordObject(m, "shade color change");
// ベース色を取得
Color baseColor = m.GetColor("_TS_BaseColor");
float hur, sat, val;
Color.RGBToHSV(baseColor, out hur, out sat, out val);
// 影1
Color shade1Color = Color.HSVToRGB(ShiftHur(hur, sat, 0.6f), sat + 0.1f, val * 0.9f);
m.SetColor("_TS_1stColor", shade1Color);
// 影2
Color shade2Color = Color.HSVToRGB(ShiftHur(hur, sat, 0.4f), sat + 0.15f, val * 0.8f);
m.SetColor("_TS_2ndColor", shade2Color);
}
}

private static float ShiftHur(float hur, float sat, float mul) {
if (sat < 0.05f) {
return 4 / 6f;
}
// R = 0/6f, G = 2/6f, B = 4/6f
float[] COLOR = { 0 / 6f, 2 / 6f, 4 / 6f, 6 / 6f };
// Y = 1/6f, C = 3/6f, M = 5/6f
float[] LIMIT = { 1 / 6f, 3 / 6f, 5 / 6f, 10000 };
for (int i = 0; i < COLOR.Length; i++) {
if (hur < LIMIT[i]) {
return (hur - COLOR[i]) * mul + COLOR[i];
}
}
return hur;
}
}

internal class MaterialToggleNoKwdDrawer : MaterialPropertyDrawer
Expand Down
Binary file added Matcaps/CubeMap/WorldSnapshot-JustH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions Matcaps/CubeMap/WorldSnapshot-JustH.png.meta

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

4 changes: 2 additions & 2 deletions Shaders/Unlit_WF_FakeFur_TransCutout.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/WF_FakeFur_TransCutout" {

/*
* authors:
* ver:2019/05/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand Down Expand Up @@ -46,6 +46,7 @@ Shader "UnlitWF/WF_FakeFur_TransCutout" {
_FurShadowPower ("Fur ShadowPower", Range(0, 1)) = 0
[IntRange]
_FurRepeat ("Fur Repeat", Range(1, 8)) = 3
_FurVector ("Fur Static Vector", Vector) = (0, 0, 0, 0)

// 色変換
[Header(Color Change)]
Expand Down Expand Up @@ -155,7 +156,6 @@ Shader "UnlitWF/WF_FakeFur_TransCutout" {
#pragma fragment frag_fakefur_cutoff

#define _CL_ENABLE
#define _HL_ENABLE
#define _TS_ENABLE

#pragma target 5.0
Expand Down
4 changes: 2 additions & 2 deletions Shaders/Unlit_WF_FakeFur_Transparent.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/WF_FakeFur_Transparent" {

/*
* authors:
* ver:2019/05/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -45,6 +45,7 @@ Shader "UnlitWF/WF_FakeFur_Transparent" {
_FurShadowPower ("Fur ShadowPower", Range(0, 1)) = 0
[IntRange]
_FurRepeat ("Fur Repeat", Range(1, 8)) = 3
_FurVector ("Fur Static Vector", Vector) = (0, 0, 0, 0)

// 色変換
[Header(Color Change)]
Expand Down Expand Up @@ -156,7 +157,6 @@ Shader "UnlitWF/WF_FakeFur_Transparent" {
#pragma fragment frag_fakefur

#define _CL_ENABLE
#define _HL_ENABLE
#define _TS_ENABLE

#pragma target 5.0
Expand Down
4 changes: 1 addition & 3 deletions Shaders/Unlit_WF_UnToon_Mobile_Texture.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_Texture" {

/*
* authors:
* ver:2019/06/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -35,8 +35,6 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_Texture" {
[Enum(OFF,0,BRIGHT,80,DARK,97,BLACK,100)]
_GL_Level ("Anti-Glare", Float) = 97
_GL_BrendPower ("Blend Light Color", Range(0, 1)) = 0.8
[Toggle(_)]
_GL_CastShadow ("Cast Shadows", Range(0, 1)) = 1

// 法線マップ
[Header(NormalMap)]
Expand Down
4 changes: 1 addition & 3 deletions Shaders/Unlit_WF_UnToon_Mobile_TransCutout.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_TransCutout" {

/*
* authors:
* ver:2019/06/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -35,8 +35,6 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_TransCutout" {
[Enum(OFF,0,BRIGHT,80,DARK,97,BLACK,100)]
_GL_Level ("Anti-Glare", Float) = 97
_GL_BrendPower ("Blend Light Color", Range(0, 1)) = 0.8
[Toggle(_)]
_GL_CastShadow ("Cast Shadows", Range(0, 1)) = 1

// Alpha
[Header(Transparent Alpha)]
Expand Down
6 changes: 3 additions & 3 deletions Shaders/Unlit_WF_UnToon_Mobile_Transparent.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_Transparent" {

/*
* authors:
* ver:2019/06/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -35,8 +35,6 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_Transparent" {
[Enum(OFF,0,BRIGHT,80,DARK,97,BLACK,100)]
_GL_Level ("Anti-Glare", Float) = 97
_GL_BrendPower ("Blend Light Color", Range(0, 1)) = 0.8
[Toggle(_)]
_GL_CastShadow ("Cast Shadows", Range(0, 1)) = 1

// Alpha
[Header(Transparent Alpha)]
Expand All @@ -45,6 +43,7 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_Transparent" {
[NoScaleOffset]
_AL_MaskTex ("[AL] Alpha Mask Texture", 2D) = "white" {}
_AL_Power ("[AL] Power", Range(0, 2)) = 1.0
_AL_Fresnel ("[AL] Fresnel Power", Range(0, 2)) = 0
[Enum(OFF,0,ON,1)]
_AL_ZWrite ("[AL] ZWrite", int) = 0

Expand Down Expand Up @@ -142,6 +141,7 @@ Shader "UnlitWF/UnToon_Mobile/WF_UnToon_Transparent" {
#pragma target 3.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _ES_ENABLE
#define _HL_ENABLE
#define _TR_ENABLE
Expand Down
5 changes: 4 additions & 1 deletion Shaders/Unlit_WF_UnToon_Tess_Transparent.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent" {

/*
* authors:
* ver:2019/06/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -43,6 +43,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent" {
[NoScaleOffset]
_AL_MaskTex ("[AL] Alpha Mask Texture", 2D) = "white" {}
_AL_Power ("[AL] Power", Range(0, 2)) = 1.0
_AL_Fresnel ("[AL] Fresnel Power", Range(0, 2)) = 0
[Enum(OFF,0,ON,1)]
_AL_ZWrite ("[AL] ZWrite", int) = 0

Expand Down Expand Up @@ -205,6 +206,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent" {
#pragma target 5.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _ES_ENABLE
#define _MT_ENABLE
Expand Down Expand Up @@ -240,6 +242,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent" {
#pragma target 5.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _ES_ENABLE
#define _HL_ENABLE
Expand Down
6 changes: 5 additions & 1 deletion Shaders/Unlit_WF_UnToon_Tess_Transparent3Pass.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent3Pass" {

/*
* authors:
* ver:2019/06/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -43,6 +43,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent3Pass" {
[NoScaleOffset]
_AL_MaskTex ("[AL] Alpha Mask Texture", 2D) = "white" {}
_AL_Power ("[AL] Power", Range(0, 2)) = 1.0
_AL_Fresnel ("[AL] Fresnel Power", Range(0, 2)) = 0
_AL_CutOff ("[AL] Cutoff Threshold", Range(0, 1)) = 0.9
[Enum(OFF,0,ON,1)]
_AL_ZWrite ("[AL] ZWrite", int) = 0
Expand Down Expand Up @@ -207,6 +208,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent3Pass" {
#pragma target 5.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _HL_ENABLE
#define _MT_ENABLE
Expand Down Expand Up @@ -242,6 +244,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent3Pass" {
#pragma target 5.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _MT_ENABLE
#define _NM_ENABLE
Expand Down Expand Up @@ -276,6 +279,7 @@ Shader "UnlitWF/UnToon_Tessellation/WF_UnToon_Tess_Transparent3Pass" {
#pragma target 5.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _HL_ENABLE
#define _MT_ENABLE
Expand Down
5 changes: 4 additions & 1 deletion Shaders/Unlit_WF_UnToon_Transparent.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Shader "UnlitWF/WF_UnToon_Transparent" {

/*
* authors:
* ver:2019/06/26 whiteflare,
* ver:2019/07/13 whiteflare,
*/

Properties {
Expand All @@ -43,6 +43,7 @@ Shader "UnlitWF/WF_UnToon_Transparent" {
[NoScaleOffset]
_AL_MaskTex ("[AL] Alpha Mask Texture", 2D) = "white" {}
_AL_Power ("[AL] Power", Range(0, 2)) = 1.0
_AL_Fresnel ("[AL] Fresnel Power", Range(0, 2)) = 0
[Enum(OFF,0,ON,1)]
_AL_ZWrite ("[AL] ZWrite", int) = 0

Expand Down Expand Up @@ -193,6 +194,7 @@ Shader "UnlitWF/WF_UnToon_Transparent" {
#pragma target 3.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _ES_ENABLE
#define _MT_ENABLE
Expand Down Expand Up @@ -226,6 +228,7 @@ Shader "UnlitWF/WF_UnToon_Transparent" {
#pragma target 3.0

#define _AL_ENABLE
#define _AL_FRESNEL_ENABLE
#define _CL_ENABLE
#define _ES_ENABLE
#define _HL_ENABLE
Expand Down
Loading

0 comments on commit 7d2b3cd

Please sign in to comment.