The subgraph can be processed without affecting the original graph.
Both the subgraph and the original graph are processed correctly with their own given parameters.
Both graphs' internal states, inputs and outputs are separated from each other.
Solution:
The subgraph is cloned using Instantiate.
The subgraph's exposed parameters are cloned using Clone.
The subgraph's output render textures are cloned using Instantiate.
The subgraph's output render textures are named exactly like the original textures. This ensures that output textures can be looked up by name.
Every CustomRenderTexture output ports in all nodes are marked as System.NonSerializable. This ensures the the cloned subgraph doesn't hold CustomRenderTexture references of the original graph.
Material in ShaderNode and OutputTextureSettings is cloned using Instantiate for the same reason.
Behaviour:
Solution:
Instantiate
.Clone
.Instantiate
.CustomRenderTexture
output ports in all nodes are marked asSystem.NonSerializable
. This ensures the the cloned subgraph doesn't holdCustomRenderTexture
references of the original graph.Material
inShaderNode
andOutputTextureSettings
is cloned usingInstantiate
for the same reason.