Skip to content

Commit 9ebdde7

Browse files
Refactor: Add more shader properties and improve regex
This commit adds numerous new shader properties to enhance visual control and refines the regex used for property extraction in the shader generator. Co-authored-by: sindharta.tanuwijaya <sindharta.tanuwijaya@unity3d.com>
1 parent f62d5bf commit 9ebdde7

File tree

4 files changed

+139
-5
lines changed

4 files changed

+139
-5
lines changed

com.unity.toon-graphics-test/Editor/ShaderGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace UnityEditor.Rendering.Toon
1616
/// </summary>
1717
public class ShaderGenerator : EditorWindow
1818
{
19-
private static readonly Regex PropertyNameRegex = new Regex(@"([A-Za-z_][A-Za-z0-9_]*)\s*\(", RegexOptions.Compiled);
19+
private static readonly Regex PropertyNameRegex = new Regex(@"(?:\]\s*|^)([A-Za-z_][A-Za-z0-9_]*)\s*\(", RegexOptions.Compiled);
2020
private const string COMMON_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/CommonPropertiesPart.shader";
2121
private const string TESSELATION_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/TessellationPropertiesPart.shader";
2222
private const string UNITY_TOON_SHADER_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader";

com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Wed Nov 05 06:07:09 UTC 2025
1+
//Auto-generated on Wed Nov 05 06:16:34 UTC 2025
22
//Unity Toon Shader
33
//nobuyuki@unity3d.com
44
//toshiyuki@unity3d.com (Intengrated)
@@ -48,6 +48,7 @@ Shader "Toon" {
4848
//
4949
[Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0
5050
_Clipping_Level("Clipping_Level", Range(0, 1)) = 0
51+
_Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0
5152
// ClippingMask paramaters to Here.
5253

5354
// Base Color Properties
@@ -76,62 +77,90 @@ Shader "Toon" {
7677

7778
// Normal Map Properties
7879
_NormalMap ("NormalMap", 2D) = "bump" {}
80+
_BumpScale ("Normal Scale", Range(0, 1)) = 1
7981
[Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0
8082
//v.2.0.4.4
8183
[Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1
84+
_Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0
8285

8386
// Shading Properties
8487
//v.2.0.6
88+
_BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5
89+
_BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001
90+
_ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0
91+
_1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001
92+
_1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5
93+
_1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001
94+
_2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0
95+
_2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001
8596
//v.2.0.5
97+
_StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0
8698
[Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1
8799

88100
// Shading Grade Map Properties
89101
_Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {}
90102
_Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {}
91103
_ShadingGradeMap("ShadingGradeMap", 2D) = "white" {}
92104
//v.2.0.6
105+
_Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0
106+
_BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0
93107

94108
// High Color Properties
95109
_HighColor ("HighColor", Color) = (0,0,0,1)
96110
//v.2.0.4 HighColor_Tex
97111
_HighColor_Tex ("HighColor_Tex", 2D) = "white" {}
98112
[Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1
99113
[Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0
114+
_HighColor_Power ("HighColor_Power", Range(0, 1)) = 0
100115
[Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0
101116
[Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0
102117
[Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0
118+
_TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0
103119
//HiColorMask
104120
_Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {}
121+
_Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0
105122

106123
// Rim Light Properties
107124
[Toggle(_)] _RimLight ("RimLight", Float ) = 0
108125
_RimLightColor ("RimLightColor", Color) = (1,1,1,1)
109126
[Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1
110127
[Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0
128+
_RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1
129+
_RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001
111130
[Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0
112131
//RimLight
113132
[Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0
133+
_Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0
114134
[Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0
115135
_Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1)
116136
[Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1
137+
_Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1
117138
[Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0
118139
//RimLightMask
119140
_Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {}
141+
_Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0
120142

121143
// MatCap Properties
122144
[Toggle(_)] _MatCap ("MatCap", Float ) = 0
123145
_MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {}
124146
//v.2.0.6
147+
_BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0
125148
_MatCapColor ("MatCapColor", Color) = (1,1,1,1)
126149
[Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1
127150
[Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1
151+
_Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0
152+
_Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0
128153
//v.2.0.6
129154
[Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0
130155
[Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0
131156
_NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {}
157+
_BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1
158+
_Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0
132159
[Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0
160+
_TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0
133161
//MatcapMask
134162
_Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {}
163+
_Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0
135164
[Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0
136165
//v.2.0.5
137166
[Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0
@@ -142,6 +171,8 @@ Shader "Toon" {
142171
_AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {}
143172
_AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1)
144173
[Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1
174+
_AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0
175+
_AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3
145176
[Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0
146177

147178
// Emissive Properties
@@ -150,6 +181,8 @@ Shader "Toon" {
150181
_Emissive_Tex ("Emissive_Tex", 2D) = "white" {}
151182
[HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1)
152183
_Base_Speed ("Base_Speed", Float ) = 0
184+
_Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0
185+
_Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0
153186
_Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0
154187
[Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0
155188
[Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0
@@ -178,11 +211,15 @@ Shader "Toon" {
178211
[Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0
179212
_BakedNormal ("Baked Normal for Outline", 2D) = "white" {}
180213
//GI Intensity
214+
_GI_Intensity ("GI_Intensity", Range(0, 1)) = 0
181215
//For VR Chat under No effective light objects
216+
_Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0
182217
//v.2.0.5
183218
[Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1
184219
//Built-in Light Direction
185220
[Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0
221+
_Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05
222+
_Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09
186223
[Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1
187224

188225
// HDRP Matte Properties
@@ -236,6 +273,8 @@ Shader "Toon" {
236273
_BaseColorMap("BaseColorMap", 2D) = "white" {}
237274
[HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0)
238275

276+
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
277+
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
239278
_MaskMap("MaskMap", 2D) = "white" {}
240279
_SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0
241280
_SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0
@@ -247,6 +286,7 @@ Shader "Toon" {
247286
// Normal Maps
248287
////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map
249288
_NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value
289+
_NormalScale("_NormalScale", Range(0.0, 8.0)) = 1
250290

251291
_BentNormalMap("_BentNormalMap", 2D) = "bump" {}
252292
_BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {}
@@ -256,6 +296,7 @@ Shader "Toon" {
256296
// Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01
257297
// Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change.
258298
[HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI.
299+
[HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space
259300

260301
[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0
261302
// These parameters are for vertex displacement/Tessellation
@@ -265,32 +306,43 @@ Shader "Toon" {
265306
_HeightMax("Heightmap Max", Float) = 1
266307
// Amplitude mode
267308
_HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters
309+
_HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space
268310

269311
// These parameters are for pixel displacement
270312
_HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters
271313

272314
// Detail Maps
273315
_DetailMap("DetailMap", 2D) = "linearGrey" {}
316+
_DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1
317+
_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1
318+
_DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1
274319

275320
// Tangent Maps
276321
_TangentMap("TangentMap", 2D) = "bump" {}
277322
_TangentMapOS("TangentMapOS", 2D) = "white" {}
323+
_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0
278324
_AnisotropyMap("AnisotropyMap", 2D) = "white" {}
279325

280326
// Diffusion Profile
281327
[HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0
282328
[HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0)
283329
[HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0
330+
_SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0
284331
_SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {}
332+
_TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0
333+
_Thickness("Thickness", Range(0.0, 1.0)) = 1.0
285334
_ThicknessMap("Thickness Map", 2D) = "white" {}
286335
_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0)
287336

288337
// Iridescence
338+
_IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0
289339
_IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {}
290340
_IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0)
341+
_IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0
291342
_IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {}
292343

293344
// Coat
345+
_CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0
294346
_CoatMaskMap("CoatMaskMap", 2D) = "white" {}
295347

296348
// Specular
@@ -312,6 +364,7 @@ Shader "Toon" {
312364
[HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0
313365
[ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0
314366
_EmissiveIntensity("Emissive Intensity", Float) = 1
367+
_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0
315368

316369
// Distortion
317370
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
@@ -333,6 +386,10 @@ Shader "Toon" {
333386
// Alpha and Transparency
334387
[ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0
335388
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
389+
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
390+
_AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5
391+
_AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5
392+
_AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5
336393
[ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0
337394
[ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0
338395
[ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0
@@ -341,6 +398,7 @@ Shader "Toon" {
341398
// Transparency
342399
[Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0
343400
[Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0
401+
_Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0
344402
_ThicknessMultiplier("Thickness Multiplier", Float) = 1.0
345403
_TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0)
346404
_TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {}
@@ -406,7 +464,12 @@ Shader "Toon" {
406464
[ToggleUI] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
407465

408466
[ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0
467+
_SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1
468+
_SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2
409469

470+
_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5
471+
_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15
472+
_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5
410473
_PPDPrimitiveLength("Primitive length for POM", Float) = 1
411474
_PPDPrimitiveWidth("Primitive width for POM", Float) = 1
412475
[HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0)
@@ -428,6 +491,7 @@ Shader "Toon" {
428491

429492
// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes.
430493
////////// _MainTex("BaseMap", 2D) = "white" {}
494+
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
431495

432496
[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0
433497
[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0

0 commit comments

Comments
 (0)