I want to generate an image as shown in the picture:
I selected Sort clusters by size in Cluster lysis, and then selected Cluster in the Input property of Color coding, but the generated image did not render particles according to the size of the clusters. The legend I generated also shows Cluster instead of Cluster Size. How can I generate the above image?
Color coding particles based on the size of the cluster they belong to involves the following steps:
-
Add a Cluster Analysis Modifier:
This step generates the following information:- a particle property called
Cluster
, which assigns each particle a unique cluster identifier and - a data table called
Cluster list
, which provides the size of each cluster along with its corresponding cluster ID.
- a particle property called
-
Create a custom particle property using a Python Script modifier:
Generate a new particle property calledCluster size
, which maps the size of each cluster to particles based on theirCluster
ID, e.g.:
def modify(self, data: DataCollection, *, frame: int, **kwargs):
cluster_sizes = data.tables['clusters']['Cluster Size']
data.particles_.create_property("Cluster size", data=cluster_sizes[data.particles.cluster-1])
- Apply a Color Coding Modifier:
Use theCluster size
property created in the previous step as the input for the Color Coding modifier to visually differentiate particles by cluster size. - (Optional) Add a Color Legend Overlay:
Add a Color Legend visual overlay to your viewport to display the color map in the rendered image, making the representation more informative.
Please also refer to the linked manual entries for further information.