Skip to content

Commit cdd6063

Browse files
gabrieldelacruzEvergreen
authored andcommitted
[VFX] Incorrect mesh rendered when using multimesh output and exposed submesh mask
When implementing instancing support for exposed meshes and textures, we missed one specific case. If we use a multimesh output with a exposed submesh mask that comes from a expression tree that can be optimized, the expression will not be registered properly in runtime mode. if the VFX is compiled in edition mode, the issue will not be visible.
1 parent bf85837 commit cdd6063

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Packages/com.unity.visualeffectgraph/Editor/Data/VFXDataParticle.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,9 @@ int GetBufferIndex(VFXTask task, string baseName)
13681368
VFXEditorTaskDesc singleMeshTaskDesc = taskDesc;
13691369
singleMeshTaskDesc.parameters = VFXMultiMeshHelper.PatchCPUMapping(taskDesc.parameters, multiMeshOutput.meshCount, j).ToArray();
13701370
singleMeshTaskDesc.buffers = VFXMultiMeshHelper.PatchBufferMapping(taskDesc.buffers, j).ToArray();
1371-
VFXMultiMeshHelper.PatchInstancingSplitValues(instancingSplitDescValues, expressionGraph, context.inputSlots, multiMeshOutput.meshCount, j);
1372-
singleMeshTaskDesc.instanceSplitIndex = AddInstanceSplitDesc(instanceSplitDescs, instancingSplitDescValues);
1371+
var instancingSplitDescValuesMesh = new List<uint>(instancingSplitDescValues);
1372+
VFXMultiMeshHelper.PatchInstancingSplitValues(instancingSplitDescValuesMesh, expressionGraph, context.inputSlots, multiMeshOutput.meshCount, j);
1373+
singleMeshTaskDesc.instanceSplitIndex = AddInstanceSplitDesc(instanceSplitDescs, instancingSplitDescValuesMesh);
13731374
AddTaskDesc(taskDescs, singleMeshTaskDesc, context);
13741375
}
13751376
}

Packages/com.unity.visualeffectgraph/Editor/Models/Contexts/VFXMultiMeshHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public static void PatchInstancingSplitValues(List<uint> instancingSplitDescValu
103103
var exp = inputSlots.First(s => s.name == name).GetExpression();
104104
if (exp != null && !exp.IsAny(VFXExpression.Flags.Constant))
105105
{
106+
// Obtain reduced version of the expression
107+
exp = expressionGraph.CPUExpressionsToReduced.First(kvp => kvp.Key == exp).Value;
108+
106109
int index = expressionGraph.GetFlattenedIndex(exp);
107110
if (index >= 0)
108111
{

0 commit comments

Comments
 (0)