Skip to content

Commit 8699729

Browse files
committed
Fix Shader.SetGlobalX
1 parent da14e9a commit 8699729

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

com.unity.shadergraph/Editor/Data/Graphs/AbstractShaderProperty.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ public bool gpuInstanced
2525
internal virtual string GetHLSLVariableName(bool isSubgraphProperty, GenerationMode mode)
2626
{
2727
if (mode == GenerationMode.VFX)
28-
return $"PROP.{referenceName}";
28+
{
29+
// Per-element exposed properties are provided by the properties structure filled by VFX.
30+
if (overrideHLSLDeclaration)
31+
return $"PROP.{referenceName}";
32+
// For un-exposed global properties, just read from the cbuffer.
33+
else
34+
return referenceName;
35+
}
2936

3037
return referenceName;
3138
}

com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ public void CollectShaderProperties(PropertyCollector collector, GenerationMode
12201220
{
12211221
// For VFX Shader generation, we must omit exposed properties from the Material CBuffer.
12221222
// This is because VFX computes properties on the fly in the vertex stage, and packed into interpolator.
1223-
if (generationMode == GenerationMode.VFX)
1223+
if (generationMode == GenerationMode.VFX && prop.isExposed)
12241224
{
12251225
prop.overrideHLSLDeclaration = true;
12261226
prop.hlslDeclarationOverride = HLSLDeclaration.DoNotDeclare;

0 commit comments

Comments
 (0)