Skip to content

Commit 6e321cc

Browse files
committed
fix: fix alpha clipping for ShaderGraph
1 parent f317af9 commit 6e321cc

File tree

5 files changed

+130
-5
lines changed

5 files changed

+130
-5
lines changed

Packages/src/Runtime/UIEffectProjectSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ private static void InitializeOnLoadMethod()
111111
("Hidden/TextMeshPro/Mobile/Distance Field (UIEffect)", tmpSupport, version),
112112

113113
// ShaderGraph Support
114-
("Shader Graphs/UISample (UIEffect)", "ShaderGraph Support (Unity 6 BuiltIn)", "v5.7.0"),
115-
("Shader Graphs/UISampleURP (UIEffect)", "ShaderGraph Support (Unity 6 URP)", "v5.7.0")
114+
("Shader Graphs/UISample (UIEffect)", "ShaderGraph Support (Unity 6 BuiltIn)", "v5.8.0"),
115+
("Shader Graphs/UISampleURP (UIEffect)", "ShaderGraph Support (Unity 6 URP)", "v5.8.0")
116116
});
117117
ShaderSampleImporter.RegisterShaderAliases(new[]
118118
{

Packages/src/Samples~/ShaderGraph Support (Unity 6 BuiltIn)~/UIEffectForShaderGraph.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ half4 frag_override(PackedVaryings packedInput) : SV_TARGET
6060
// ==== SOFTMASKABLE END ====
6161

6262
#if defined(_ALPHATEST_ON) || defined(_BUILTIN_ALPHATEST_ON)
63-
clip(color.a - surfaceDescription.Alpha);
63+
clip(color.a - surfaceDescription.AlphaClipThreshold);
6464
#endif
6565

6666
#if UNITY_UI_ALPHACLIP

Packages/src/Samples~/ShaderGraph Support (Unity 6 BuiltIn)~/UISample (UIEffect).shadergraph

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
},
2727
{
2828
"m_Id": "867db961355a4c1ea898b69d9e6549b0"
29+
},
30+
{
31+
"m_Id": "a76cdcf36ae243e5a5ea033c7d40d34f"
32+
},
33+
{
34+
"m_Id": "23e0b7c820e7452ab73c3bec44cf0e48"
2935
}
3036
],
3137
"m_GroupDatas": [],
@@ -92,6 +98,12 @@
9298
},
9399
{
94100
"m_Id": "d326ef5f90af4c7996e7e0c915e57983"
101+
},
102+
{
103+
"m_Id": "a76cdcf36ae243e5a5ea033c7d40d34f"
104+
},
105+
{
106+
"m_Id": "23e0b7c820e7452ab73c3bec44cf0e48"
95107
}
96108
]
97109
},
@@ -168,6 +180,85 @@
168180
"m_CustomEditorGUI": ""
169181
}
170182

183+
{
184+
"m_SGVersion": 0,
185+
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
186+
"m_ObjectId": "23e0b7c820e7452ab73c3bec44cf0e48",
187+
"m_Group": {
188+
"m_Id": ""
189+
},
190+
"m_Name": "SurfaceDescription.AlphaClipThreshold",
191+
"m_DrawState": {
192+
"m_Expanded": true,
193+
"m_Position": {
194+
"serializedVersion": "2",
195+
"x": 0.0,
196+
"y": 0.0,
197+
"width": 0.0,
198+
"height": 0.0
199+
}
200+
},
201+
"m_Slots": [
202+
{
203+
"m_Id": "3c6f2af22741431faed8a2606630029a"
204+
}
205+
],
206+
"synonyms": [],
207+
"m_Precision": 0,
208+
"m_PreviewExpanded": true,
209+
"m_DismissedVersion": 0,
210+
"m_PreviewMode": 0,
211+
"m_CustomColors": {
212+
"m_SerializableColors": []
213+
},
214+
"m_SerializedDescriptor": "SurfaceDescription.AlphaClipThreshold"
215+
}
216+
217+
{
218+
"m_SGVersion": 0,
219+
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
220+
"m_ObjectId": "3c6f2af22741431faed8a2606630029a",
221+
"m_Id": 0,
222+
"m_DisplayName": "Alpha Clip Threshold",
223+
"m_SlotType": 0,
224+
"m_Hidden": false,
225+
"m_ShaderOutputName": "AlphaClipThreshold",
226+
"m_StageCapability": 2,
227+
"m_Value": 0.009999999776482582,
228+
"m_DefaultValue": 0.5,
229+
"m_Labels": []
230+
}
231+
232+
{
233+
"m_SGVersion": 0,
234+
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
235+
"m_ObjectId": "5891f1777feb46cdbd85b489f87bfc69",
236+
"m_Id": 0,
237+
"m_DisplayName": "Emission",
238+
"m_SlotType": 0,
239+
"m_Hidden": false,
240+
"m_ShaderOutputName": "Emission",
241+
"m_StageCapability": 2,
242+
"m_Value": {
243+
"x": 0.0,
244+
"y": 0.0,
245+
"z": 0.0
246+
},
247+
"m_DefaultValue": {
248+
"x": 0.0,
249+
"y": 0.0,
250+
"z": 0.0
251+
},
252+
"m_Labels": [],
253+
"m_ColorMode": 1,
254+
"m_DefaultColor": {
255+
"r": 0.0,
256+
"g": 0.0,
257+
"b": 0.0,
258+
"a": 1.0
259+
}
260+
}
261+
171262
{
172263
"m_SGVersion": 0,
173264
"m_Type": "UnityEditor.ShaderGraph.Texture2DMaterialSlot",
@@ -402,6 +493,40 @@
402493
"m_Labels": []
403494
}
404495

496+
{
497+
"m_SGVersion": 0,
498+
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
499+
"m_ObjectId": "a76cdcf36ae243e5a5ea033c7d40d34f",
500+
"m_Group": {
501+
"m_Id": ""
502+
},
503+
"m_Name": "SurfaceDescription.Emission",
504+
"m_DrawState": {
505+
"m_Expanded": true,
506+
"m_Position": {
507+
"serializedVersion": "2",
508+
"x": 0.0,
509+
"y": 0.0,
510+
"width": 0.0,
511+
"height": 0.0
512+
}
513+
},
514+
"m_Slots": [
515+
{
516+
"m_Id": "5891f1777feb46cdbd85b489f87bfc69"
517+
}
518+
],
519+
"synonyms": [],
520+
"m_Precision": 0,
521+
"m_PreviewExpanded": true,
522+
"m_DismissedVersion": 0,
523+
"m_PreviewMode": 0,
524+
"m_CustomColors": {
525+
"m_SerializableColors": []
526+
},
527+
"m_SerializedDescriptor": "SurfaceDescription.Emission"
528+
}
529+
405530
{
406531
"m_SGVersion": 0,
407532
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",

Packages/src/Samples~/ShaderGraph Support (Unity 6 BuiltIn)~/UISample (UIEffect).shadergraph.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/src/Samples~/ShaderGraph Support (Unity 6 URP)~/UISampleURP (UIEffect).shadergraph.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)