Skip to content

Commit 65e1dc7

Browse files
Refactor shader generation paths and templates
This commit updates file paths and template names used in the shader generation process. It also removes unused template files and adjusts paths in test scripts to match the new structure. Co-authored-by: sindharta.tanuwijaya <sindharta.tanuwijaya@unity3d.com>
1 parent 52e64f1 commit 65e1dc7

File tree

10 files changed

+20
-20
lines changed

10 files changed

+20
-20
lines changed

com.unity.toon-graphics-test/Editor/README_ShaderGenerator.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ This tool helps maintain consistency between `UnityToon.shader` and `UnityToonTe
44

55
## Files
66

7-
- **CommonPropertiesPart.shader**: Plain text list of shared property definitions (no Shader wrapper) with original comments preserved (`Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/`)
8-
- **TessellationPropertiesPart.shader**: Plain text list of tessellation-only property definitions (no Shader wrapper) (`Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/`)
7+
- **CommonPropertiesPart.shader**: Plain text list of shared property definitions (no Shader wrapper) with original comments preserved (`Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/`)
8+
- **TessellationPropertiesPart.shader**: Plain text list of tessellation-only property definitions (no Shader wrapper) (`Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/`)
99
- **ShaderGenerator.cs**: Unity Editor script (now located in the graphics test package) that generates the shader files from the property assets
1010

1111
## How to Use
1212

1313
1. **Edit Properties**:
14-
- Modify the plain-text part files under `Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/`
14+
- Modify the plain-text part files under `Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/`
1515
- The files contain only property declarations, so standard ShaderLab property syntax applies
1616

1717
2. **Generate Shader Files**:
@@ -68,7 +68,7 @@ com.unity.toon-graphics-test/
6868
├── ShaderGeneratorTest.cs # Editor test harness
6969
└── README_ShaderGenerator.md # This file
7070
71-
com.unity.toonshader/Runtime/Shaders/Common/Parts~/
71+
com.unity.toonshader/Runtime/Shaders/Common/Parts/
7272
├── CommonPropertiesPart.shader # Shared properties (plain text)
7373
└── TessellationPropertiesPart.shader # Tessellation-specific properties (plain text)
7474

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ namespace UnityEditor.Rendering.Toon
1717
public static class ShaderGenerator
1818
{
1919
private static readonly Regex PropertyNameRegex = new Regex(@"(?:\]\s*|^)([A-Za-z_][A-Za-z0-9_]*)\s*\(", RegexOptions.Compiled);
20-
private const string COMMON_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/CommonPropertiesPart.shader";
21-
private const string TESSELATION_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/TessellationPropertiesPart.shader";
20+
private const string COMMON_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/CommonPropertiesPart.shader";
21+
private const string TESSELATION_PROPERTIES_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/TessellationPropertiesPart.shader";
2222
private const string UNITY_TOON_SHADER_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader";
23-
private const string UNITY_TOON_SHADER_TEMPLATE_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/UnityToon.shader.template";
23+
private const string UNITY_TOON_SHADER_TEMPLATE_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/UnityToon_template.shader";
2424
private const string UNITY_TOON_TESSELATION_SHADER_PATH = "Packages/com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader";
25-
private const string UNITY_TOON_TESSELATION_SHADER_TEMPLATE_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/UnityToonTessellation.shader.template";
25+
private const string UNITY_TOON_TESSELATION_SHADER_TEMPLATE_PATH = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/UnityToonTessellation_template.shader";
2626

2727
[MenuItem("Toon Shader/Generate Shader Files")]
2828
public static void GenerateShaderFilesMenu()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void TestShaderGeneration()
1818
try
1919
{
2020
// Test reading the common properties file
21-
string commonPropertiesPath = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/CommonPropertiesPart.shader";
21+
string commonPropertiesPath = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/CommonPropertiesPart.shader";
2222
string commonPropertiesShader = File.ReadAllText(commonPropertiesPath);
2323

2424
if (string.IsNullOrEmpty(commonPropertiesShader))
@@ -36,7 +36,7 @@ public static void TestShaderGeneration()
3636
Debug.Log($"Successfully extracted common properties. Length: {commonProperties.Length} characters");
3737

3838
// Test reading the tessellation properties file
39-
string tessellationPropertiesPath = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts~/TessellationPropertiesPart.shader";
39+
string tessellationPropertiesPath = "Packages/com.unity.toonshader/Runtime/Shaders/Common/Parts/TessellationPropertiesPart.shader";
4040
string tessellationPropertiesShader = File.ReadAllText(tessellationPropertiesPath);
4141

4242
if (string.IsNullOrEmpty(tessellationPropertiesShader))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Wed Nov 05 09:32:04 UTC 2025
1+
//Auto-generated on Wed Nov 05 09:53:53 UTC 2025
22
Shader "Toon" {
33
Properties
44
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Wed Nov 05 09:32:04 UTC 2025
1+
//Auto-generated on Wed Nov 05 09:53:53 UTC 2025
22
Shader "Toon(Tessellation)" {
33
Properties
44
{

generate_UnityToon.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ def load_properties_from_shader(shader_path, descriptor):
137137
def generate_shader_files():
138138
try:
139139
# Read the common properties shader
140-
common_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts~/CommonPropertiesPart.shader"
140+
common_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts/CommonPropertiesPart.shader"
141141
common_properties = load_properties_from_shader(common_properties_path, "common")
142142
if not common_properties:
143143
return False
144144

145145
# Read the tessellation properties shader
146-
tessellation_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts~/TessellationPropertiesPart.shader"
146+
tessellation_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts/TessellationPropertiesPart.shader"
147147
tessellation_properties = load_properties_from_shader(tessellation_properties_path, "tessellation")
148148
if tessellation_properties is None:
149149
return False
@@ -155,7 +155,7 @@ def generate_shader_files():
155155
print("\nGenerating UnityToon.shader...")
156156
success1 = generate_shader(
157157
"com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader",
158-
"com.unity.toonshader/Runtime/Shaders/Common/Parts~/UnityToon.shader.template",
158+
"com.unity.toonshader/Runtime/Shaders/Common/Parts/UnityToon_template.shader",
159159
common_properties,
160160
"",
161161
auto_comment_line,
@@ -165,7 +165,7 @@ def generate_shader_files():
165165
print("\nGenerating UnityToonTessellation.shader...")
166166
success2 = generate_shader(
167167
"com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader",
168-
"com.unity.toonshader/Runtime/Shaders/Common/Parts~/UnityToonTessellation.shader.template",
168+
"com.unity.toonshader/Runtime/Shaders/Common/Parts/UnityToonTessellation_template.shader",
169169
common_properties,
170170
tessellation_properties,
171171
auto_comment_line,

test_generate_UnityToon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static void Main()
1010
try
1111
{
1212
// Test reading the common properties shader
13-
string commonPropertiesPath = "com.unity.toonshader/Runtime/Shaders/Common/Parts~/CommonPropertiesPart.shader";
13+
string commonPropertiesPath = "com.unity.toonshader/Runtime/Shaders/Common/Parts/CommonPropertiesPart.shader";
1414
string commonPropertiesShader = File.ReadAllText(commonPropertiesPath);
1515

1616
if (string.IsNullOrEmpty(commonPropertiesShader))
@@ -28,7 +28,7 @@ static void Main()
2828
Console.WriteLine($"Successfully extracted common properties. Length: {commonProperties.Length} characters");
2929

3030
// Test reading the tessellation properties shader
31-
string tessellationPropertiesPath = "com.unity.toonshader/Runtime/Shaders/Common/Parts~/TessellationPropertiesPart.shader";
31+
string tessellationPropertiesPath = "com.unity.toonshader/Runtime/Shaders/Common/Parts/TessellationPropertiesPart.shader";
3232
string tessellationPropertiesShader = File.ReadAllText(tessellationPropertiesPath);
3333

3434
if (string.IsNullOrEmpty(tessellationPropertiesShader))

test_generate_UnityToon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def test_shader_generation():
1313
try:
1414
# Test reading the common properties shader
15-
common_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts~/CommonPropertiesPart.shader"
15+
common_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts/CommonPropertiesPart.shader"
1616
with open(common_properties_path, 'r') as f:
1717
common_properties_shader = f.read()
1818

@@ -28,7 +28,7 @@ def test_shader_generation():
2828
print(f"Successfully extracted common properties. Length: {len(common_properties)} characters")
2929

3030
# Test reading the tessellation properties shader
31-
tessellation_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts~/TessellationPropertiesPart.shader"
31+
tessellation_properties_path = "com.unity.toonshader/Runtime/Shaders/Common/Parts/TessellationPropertiesPart.shader"
3232
with open(tessellation_properties_path, 'r') as f:
3333
tessellation_properties_shader = f.read()
3434

0 commit comments

Comments
 (0)