Skip to content

Commit cff0c13

Browse files
committed
ver 0.21.1-alpha
1 parent cac0a73 commit cff0c13

File tree

7 files changed

+131
-30
lines changed

7 files changed

+131
-30
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [0.21.1] - 2022-04-10
4+
- Fixed environement reflections flag not working.
5+
36
## [0.21.0] - 2022-04-09
47
- Supports URP 2019.4.
58
- Supports URP 2019.3.

Documents/documents.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ <h2>マテリアルプロパティ</h3>
212212
</td>
213213
</tr>
214214
<tr>
215-
<th class="is-vcentered"></th>
216-
<th class="is-vcentered">Spherical Normal Correct</th>
215+
<th class="is-vcentered">Spherical Normal Correction (Experimental)</th>
216+
<th class="is-vcentered">Factor</th>
217217
<td class="is-vcentered">
218218
<p>球面法線補正の割合を指定します。主に顔の陰影をアニメ調にしたい場合に使用します。</p>
219219
</td>
@@ -223,7 +223,7 @@ <h2>マテリアルプロパティ</h3>
223223
</tr>
224224
<tr>
225225
<th class="is-vcentered"></th>
226-
<th class="is-vcentered">Spherical Normal Correct Origin</th>
226+
<th class="is-vcentered">Origin</th>
227227
<td class="is-vcentered">
228228
<p>球面法線補正のオブジェクト座標の中心点を指定します。</p>
229229
</td>
@@ -232,8 +232,8 @@ <h2>マテリアルプロパティ</h3>
232232
</td>
233233
</tr>
234234
<tr>
235-
<th class="is-vcentered">Shadow Correction (Experimental)</th>
236-
<th class="is-vcentered">Spherical Shadow Correct</th>
235+
<th class="is-vcentered">Spherical Shadow Correction (Experimental)</th>
236+
<th class="is-vcentered">Factor</th>
237237
<td class="is-vcentered">
238238
<p>球面影座標補正の割合を指定します。主にReceiveShadowが有効な時に顔に変なセルフシャドーが入るのを防ぎます。</p>
239239
</td>
@@ -243,7 +243,7 @@ <h2>マテリアルプロパティ</h3>
243243
</tr>
244244
<tr>
245245
<th class="is-vcentered"></th>
246-
<th class="is-vcentered">Spherical Shadow Correct Origin</th>
246+
<th class="is-vcentered">Origin</th>
247247
<td class="is-vcentered">
248248
<p>球面影座標補正のオブジェクト座標の中心点を指定します。</p>
249249
</td>
@@ -253,7 +253,7 @@ <h2>マテリアルプロパティ</h3>
253253
</tr>
254254
<tr>
255255
<th class="is-vcentered"></th>
256-
<th class="is-vcentered">Spherical Shadow Correct Radius</th>
256+
<th class="is-vcentered">Radius</th>
257257
<td class="is-vcentered">
258258
<p>球面影座標補正のオブジェクト座標の中心点からどの位の半径離れた位置を影座標とみなすかを指定します。</p>
259259
</td>

Editor/ShaderGUI/LitShader.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class LitShader : ShaderGUI
1212
SavedBool fo_workflow;
1313
SavedBool fo_baseColor;
1414
SavedBool fo_shading;
15+
SavedBool fo_normalCorrection;
1516
SavedBool fo_shadowCorrection;
1617
SavedBool fo_physicalProperty;
1718
SavedBool fo_surface;
@@ -20,12 +21,16 @@ class LitShader : ShaderGUI
2021
SavedBool fo_postprocessing;
2122
SavedBool fo_advanced;
2223

24+
private Transform normalCorrectOriginTrans;
25+
private Transform shadowCorrectOriginTrans;
26+
2327
void OnOpenGUI()
2428
{
2529
var prefix = "UniToonLitShaderGUI";
2630
fo_workflow = new SavedBool($"{prefix}.Workflow", true);
2731
fo_baseColor = new SavedBool($"{prefix}.BaseColor", true);
2832
fo_shading = new SavedBool($"{prefix}.Shading", true);
33+
fo_normalCorrection = new SavedBool($"{prefix}.NormalCorrection", true);
2934
fo_shadowCorrection = new SavedBool($"{prefix}.ShadowCorrection", true);
3035
fo_physicalProperty = new SavedBool($"{prefix}.PhysicalProperty", true);
3136
fo_surface = new SavedBool($"{prefix}.Surface", true);
@@ -56,7 +61,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
5661
EditorGUILayout.Space();
5762

5863
// version
59-
GUILayout.Label("UniToon ver 0.21.0-alpha");
64+
GUILayout.Label("UniToon ver 0.21.1-alpha");
6065

6166
EditorGUILayout.Space();
6267
changed = MaterialGUI.Enum<UniToonVersion>("Version", FindProperty("_UniToonVer", properties));
@@ -111,17 +116,28 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
111116
if (BeginSection("Shading", fo_shading))
112117
{
113118
changed |= MaterialGUI.Slider("Toony Factor", FindProperty("_ToonyFactor", properties), 0.001f, 1.0f);
114-
changed |= MaterialGUI.Slider("Spherical Normal Correct", FindProperty("_NormalCorrect", properties), 0.0f, 1.0f);
115-
changed |= MaterialGUI.Vector3("Spherical Normal Correct Origin", FindProperty("_NormalCorrectOrigin", properties));
119+
}
120+
changed |= EndSection();
121+
122+
if (BeginSection("Spherical Normal Correction (Experimental)", fo_normalCorrection))
123+
{
124+
changed |= MaterialGUI.Slider("Factor", FindProperty("_NormalCorrect", properties), 0.0f, 1.0f);
125+
changed |= MaterialGUI.Vector3("Origin", FindProperty("_NormalCorrectOrigin", properties));
126+
// normalCorrectOriginTrans = (Transform)EditorGUILayout.ObjectField("[Editor Only] Origin Transform", normalCorrectOriginTrans, typeof(Transform), true);
127+
// if (normalCorrectOriginTrans != null && GUILayout.Button("Calc From Origin Transform"))
128+
// {
129+
// FindProperty("_NormalCorrectOrigin", properties).vectorValue = normalCorrectOriginTrans.localPosition;
130+
// changed = true;
131+
// }
116132
}
117133
changed |= EndSection();
118134

119135
// shadow correction
120-
if (BeginSection("Shadow Correction (Experimental)", fo_shadowCorrection))
136+
if (BeginSection("Spherical Shadow Correction (Experimental)", fo_shadowCorrection))
121137
{
122-
changed |= MaterialGUI.Slider("Spherical Shadow Correct", FindProperty("_ShadowCorrect", properties), 0.0f, 1.0f);
123-
changed |= MaterialGUI.Vector3("Spherical Shadow Correct Origin", FindProperty("_ShadowCorrectOrigin", properties));
124-
changed |= MaterialGUI.Slider("Spherical Shadow Correct Radius", FindProperty("_ShadowCorrectRadius", properties), 0.0f, 2.0f);
138+
changed |= MaterialGUI.Slider("Factor", FindProperty("_ShadowCorrect", properties), 0.0f, 1.0f);
139+
changed |= MaterialGUI.Vector3("Origin", FindProperty("_ShadowCorrectOrigin", properties));
140+
changed |= MaterialGUI.Slider("Radius", FindProperty("_ShadowCorrectRadius", properties), 0.0f, 2.0f);
125141
}
126142
changed |= EndSection();
127143

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UniToon
22

3-
ver 0.21.0-alpha
3+
ver 0.21.1-alpha
44

55
Physically-based Toon Shader for game applications. Compliant with Unity standard rendering functions. It is not targeted to be multifunctional in order to keep performance, but to be universally usable.
66

Runtime/MaterialConverter.cs

Lines changed: 95 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,75 @@ public enum RenderFace
4848

4949
public class MaterialConverter
5050
{
51+
enum RenderPipelineType
52+
{
53+
Builtin = 0,
54+
URP = 1,
55+
HDRP = 2,
56+
}
57+
5158
public static UniToonVersion GetCurrentVersion()
5259
{
60+
if (GraphicsSettings.currentRenderPipeline?.GetType().Name == "UniversalRenderPipelineAsset")
61+
{
62+
#if UNITY_2021_2
63+
return UniToonVersion.URP_2021_2;
64+
#elif UNITY_2021_1
65+
return UniToonVersion.URP_2021_1;
66+
#elif UNITY_2020_3
67+
return UniToonVersion.URP_2020_3;
68+
#elif UNITY_2020_2
69+
return UniToonVersion.URP_2020_2;
70+
#elif UNITY_2020_1
71+
return UniToonVersion.URP_2020_1;
72+
#elif UNITY_2019_4
73+
return UniToonVersion.URP_2019_4;
74+
#elif UNITY_2019_3
75+
return UniToonVersion.URP_2019_3;
76+
#else
77+
return UniToonVersion.Unknown;
78+
#endif
79+
}
80+
else if (GraphicsSettings.currentRenderPipeline?.GetType().Name == "HDRenderPipelineAsset")
81+
{
82+
#if UNITY_2021_2
83+
return UniToonVersion.Unknown;
84+
#elif UNITY_2021_1
85+
return UniToonVersion.Unknown;
86+
#elif UNITY_2020_3
87+
return UniToonVersion.Unknown;
88+
#elif UNITY_2020_2
89+
return UniToonVersion.Unknown;
90+
#elif UNITY_2020_1
91+
return UniToonVersion.Unknown;
92+
#elif UNITY_2019_4
93+
return UniToonVersion.Unknown;
94+
#elif UNITY_2019_3
95+
return UniToonVersion.Unknown;
96+
#else
97+
return UniToonVersion.Unknown;
98+
#endif
99+
}
100+
else
101+
{
53102
#if UNITY_2021_2
54-
return UniToonVersion.URP_2021_2;
103+
return UniToonVersion.Unknown;
55104
#elif UNITY_2021_1
56-
return UniToonVersion.URP_2021_1;
105+
return UniToonVersion.Unknown;
57106
#elif UNITY_2020_3
58-
return UniToonVersion.URP_2020_3;
107+
return UniToonVersion.Unknown;
59108
#elif UNITY_2020_2
60-
return UniToonVersion.URP_2020_2;
109+
return UniToonVersion.Unknown;
61110
#elif UNITY_2020_1
62-
return UniToonVersion.URP_2020_1;
111+
return UniToonVersion.Unknown;
63112
#elif UNITY_2019_4
64-
return UniToonVersion.URP_2019_4;
113+
return UniToonVersion.Unknown;
65114
#elif UNITY_2019_3
66-
return UniToonVersion.URP_2019_3;
115+
return UniToonVersion.Unknown;
67116
#else
68-
return UniToonVersion.Unknown;
117+
return UniToonVersion.Unknown;
69118
#endif
119+
}
70120
}
71121

72122
private static Texture GetTexture(Material mat, string propertyName)
@@ -76,6 +126,8 @@ private static Texture GetTexture(Material mat, string propertyName)
76126

77127
public static void MaterialChanged(Material mat, UniToonVersion version, bool updateRenderQueue = false)
78128
{
129+
var rp = (RenderPipelineType)((int)version / 1000);
130+
79131
// clear keywords
80132
mat.shaderKeywords = new string[0];
81133

@@ -85,19 +137,36 @@ public static void MaterialChanged(Material mat, UniToonVersion version, bool up
85137
// workflow mode
86138
if ((WorkflowMode)mat.GetFloat("_WorkflowMode") == WorkflowMode.Specular)
87139
{
88-
SetKeyword(mat, "_METALLICSPECGLOSSMAP", GetTexture(mat, "_SpecGlossMap"));
89-
SetKeyword(mat, "_SPECULAR_SETUP", true);
140+
if (rp == RenderPipelineType.Builtin)
141+
{
142+
SetKeyword(mat, "_METALLICGLOSSMAP", GetTexture(mat, "_SpecGlossMap"));
143+
}
144+
else if (rp == RenderPipelineType.URP)
145+
{
146+
SetKeyword(mat, "_METALLICSPECGLOSSMAP", GetTexture(mat, "_SpecGlossMap"));
147+
SetKeyword(mat, "_SPECULAR_SETUP", true);
148+
}
90149
}
91150
else
92151
{
93-
SetKeyword(mat, "_METALLICSPECGLOSSMAP", GetTexture(mat, "_MetallicGlossMap"));
152+
if (rp == RenderPipelineType.Builtin)
153+
{
154+
SetKeyword(mat, "_METALLICGLOSSMAP", GetTexture(mat, "_MetallicGlossMap"));
155+
}
156+
else if (rp == RenderPipelineType.URP)
157+
{
158+
SetKeyword(mat, "_METALLICSPECGLOSSMAP", GetTexture(mat, "_MetallicGlossMap"));
159+
}
94160
}
95161

96162
// parallax map
97163
SetKeyword(mat, "_PARALLAXMAP", GetTexture(mat, "_ParallaxMap"));
98164

99165
// occlusion map
100-
SetKeyword(mat, "_OCCLUSIONMAP", GetTexture(mat, "_OcclusionMap"));
166+
if (rp == RenderPipelineType.URP)
167+
{
168+
SetKeyword(mat, "_OCCLUSIONMAP", GetTexture(mat, "_OcclusionMap"));
169+
}
101170

102171
// detail map
103172
SetKeyword(mat, "_DETAIL_MULX2", GetTexture(mat, "_DetailAlbedoMap") || GetTexture(mat, "_DetailNormalMap"));
@@ -111,8 +180,21 @@ public static void MaterialChanged(Material mat, UniToonVersion version, bool up
111180
// specular highlights
112181
SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", mat.GetFloat("_SpecularHighlights") < 0.5f);
113182

183+
// environment reflections
184+
if (rp == RenderPipelineType.Builtin)
185+
{
186+
SetKeyword(mat, "_GLOSSYREFLECTIONS_OFF", mat.GetFloat("_EnvironmentReflections") < 0.5f);
187+
}
188+
else if (rp == RenderPipelineType.URP)
189+
{
190+
SetKeyword(mat, "_ENVIRONMENTREFLECTIONS_OFF", mat.GetFloat("_EnvironmentReflections") < 0.5f);
191+
}
192+
114193
// receive shadow
115-
SetKeyword(mat, "_RECEIVE_SHADOWS_OFF", mat.GetFloat("_ReceiveShadow") < 0.5f);
194+
if (rp == RenderPipelineType.URP)
195+
{
196+
SetKeyword(mat, "_RECEIVE_SHADOWS_OFF", mat.GetFloat("_ReceiveShadow") < 0.5f);
197+
}
116198

117199
// blend mode
118200
SetBlendMode(mat, updateRenderQueue);

Runtime/RendererFeatures/DeferredOutlineRendererFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
#if UNITY_2021_2_OR_NEWER
12
using System.Linq;
23
using System.Reflection;
34
using UnityEngine;
45
using UnityEngine.Rendering;
56
using UnityEngine.Rendering.Universal;
67

7-
#if UNITY_2021_2_OR_NEWER
88
namespace UniToon
99
{
1010
public class DeferredOutlineRendererFeature : ScriptableRendererFeature

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.yoship1639.unitoon",
3-
"version": "0.21.0",
3+
"version": "0.21.1",
44
"displayName": "UniToon",
55
"description": "Physically-based Toon Shader for game applications. Compliant with Unity standard rendering functions. It is not targeted to be multifunctional in order to keep performance, but to be universally usable.",
66
"unity": "2019.3",

0 commit comments

Comments
 (0)