Skip to content

Commit cf67162

Browse files
Regression introduced by #5416 We should also include texture internally declared in SG -_-'
1 parent 1feb3b7 commit cf67162

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

com.unity.visualeffectgraph/Editor/ShaderGraph/VFXSubTarget.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,23 @@ static void GenerateVFXAdditionalCommands(VFXContext context, VFXSRPBinder srp,
175175
//Texture used as input of the shaderGraph will be declared by the shaderGraph generation
176176
//However, if we are sampling a texture (or a mesh), we have to declare them before the VFX code generation.
177177
//Thus, remove texture used in SG from VFX declaration and let the remainder.
178-
var filteredTextureInSG = context.inputSlots.Where(o =>
178+
var shaderGraphOutput = context as VFXShaderGraphParticleOutput;
179+
if (shaderGraphOutput == null)
180+
throw new InvalidOperationException("Unexpected null VFXShaderGraphParticleOutput");
181+
var shaderGraphObject = shaderGraphOutput.GetOrRefreshShaderGraphObject();
182+
if (shaderGraphObject == null)
183+
throw new InvalidOperationException("Unexpected null GetOrRefreshShaderGraphObject");
184+
var texureUsedInternallyInSG = shaderGraphObject.textureInfos.Select(o =>
185+
{
186+
return o.name;
187+
});
188+
var textureExposedFromSG = context.inputSlots.Where(o =>
179189
{
180190
return VFXExpression.IsTexture(o.property.type);
181191
}).Select(o => o.property.name);
182192

193+
var filteredTextureInSG = texureUsedInternallyInSG.Concat(textureExposedFromSG).ToArray();
194+
183195
// Parameter Cbuffer
184196
VFXCodeGenerator.BuildParameterBuffer(contextData, filteredTextureInSG, out var parameterBuffer);
185197
parameterBufferDescriptor = new AdditionalCommandDescriptor("VFXParameterBuffer", parameterBuffer);

0 commit comments

Comments
 (0)