Skip to content

Commit d84aa2a

Browse files
KarlBKentKarl Kent
authored andcommitted
Xp vfx user keywords (#49)
* User Keywords initial work * Update ShaderInputPropertyDrawer.cs Prevent shadergraph from adding nodes if limit is exceeded, so it doesnt serialize and cause UI Issues. * Update ShaderGraphImporter.cs Bring the Importer versioning up to latest * Adding Missing shader keyword util, from PR Missed this due to workflow issues Co-authored-by: Karl Kent <[email protected]>
1 parent 0e5aa02 commit d84aa2a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

com.unity.shadergraph/Editor/Data/Util/KeywordUtil.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,34 @@ public static string ToDefineString(this KeywordDescriptor keyword, int value)
9797
}
9898
}
9999

100+
public static int GetKeywordPermutationCount(this GraphData graph)
101+
{
102+
// Gather all unique keywords from the Graph including Sub Graphs
103+
IEnumerable<ShaderKeyword> allKeywords = graph.keywords;
104+
var subGraphNodes = graph.GetNodes<SubGraphNode>();
105+
foreach (SubGraphNode subGraphNode in subGraphNodes)
106+
{
107+
if (subGraphNode.asset == null)
108+
{
109+
continue;
110+
}
111+
allKeywords = allKeywords.Union(subGraphNode.asset.keywords);
112+
}
113+
allKeywords = allKeywords.Distinct();
114+
115+
// Get permutation count for all Keywords
116+
int permutationCount = 1;
117+
foreach (ShaderKeyword keyword in allKeywords)
118+
{
119+
if (keyword.keywordType == KeywordType.Boolean)
120+
permutationCount *= 2;
121+
else
122+
permutationCount *= keyword.entries.Count;
123+
}
124+
125+
return permutationCount;
126+
}
127+
100128
public static string GetKeywordPermutationSetConditional(List<int> permutationSet)
101129
{
102130
StringBuilder sb = new StringBuilder();

0 commit comments

Comments
 (0)