User Tools

Site Tools


unity_point_cloud

This is a work in progress tutorial of how to render point clouds of 3D models in Unity using its Visual Effects Graph. When inside the main project folder (picture #1). Open the Assets folder and then the Models folder. In order to render these point clouds, 3D scans must be convered to point caches which can be done within Unity. The VFX graph was favored over using traditional particle systems in Unity due to its ability to render millions of particles with little load on the computer.

Picture #1

Drag and drop any 3D scans into the Models folder (file types must be .dae file types, .obj and .fbx files do not export the colors, more research must be done to see what other extensions of 3D files work).

Open the Unity project within the Unity Hub. To do this, go open Unity Hub and click into the Projects panel. Click on the Add button and locate the project folder. Then, click Select Folder. The project is only tested using Unity version 2019.1.10 and it is not known whether other versions will run the project. Next, click on the project to open Unity.

Navigate to Window > Visual Effects > Utilities > Point Cache Bake Tool.

A pCache Tool popup will appear. In here select the Mesh. Once you drag and drop .dae files into the Models, the models should be accessible within the mesh finder. Once you have selected the mesh, set the Point Count to the number of vertices that the model has. This is simply to make many points to make the model appear fuller, this number probably should be changed in the future to alter the style of the point cloud models. Make sure that the Export Colors option is also checked. Click the Save To pCache File…button, and this will save the 3D model as a pcache.

Next, click on the Original Render object on the side panel, and select the DemoEffect gameobject, this is one instance of the VFX graph with the point cloud. The ParticleEffectForDuneParticles contains the point cloud for a slightly different point cloud style from that of the original render. The current object that I am working with is the Original Render, so this documentation will focus on that. In the Inspector panel on the right, click on Edit under the Asset Template tab. This will open up the VFX Graph window and in here the point cache used in the project can be changed. At the moment, there are two point clouds rendered with a simple interaction script to allow the particles to transform into the other with the press of the spacebar key.

pointcloudunity12.jpg

When in the VFX Graph, the point cache can be accessed in the Point Cache node connecting to the Set Position from Map node. When the selection button is clicked, a popup will appear with different pcaches linked to the file. Click on the pcache you want, and the effects system should update accordingly. A connection should also be made between the Attribute Map : color of the point cache to a new Set Color From Map node in the initialize section. To do this, click on the Initialize section and search for the Set Color From Map node.

Here is a screenshot of all the nodes and connections to render the pointcloud as seen in the images. The Set Target From Position block within Initialize simply sets the target position for the particles, which in this case are just added to be below the rendered model. Once the spacebar is pressed, this gives the model its “collapsing” effect as it moves towards that target position. In terms of the interactivity, the script simply alternates between these two states of being collapsed and disaplayed (when one model is rendered the other is collapsed in the target positions).

Here are the screenshots of the VFX graph for both the jeep and the Watchtower.

At the moment, the first pcache being rendered into a point cloud is set to the Delma Watchtower and the other point cloud is set to the Jeep.

The Terrain:

The terrain was created using a heightmap with GIMP and Photoshop. Along with the terrain tool used to turn this map into a terrain mesh, I also played around with turning this sand-like heightmap into a point cloud using the VFX. There is a a tutorial to converting the terrain into a .obj file, which I in turn ran through the pcache baking tool to become a pointcloud. This sand gameobject was just positioned to where the objects would stand. In the SandMapRaw scene, the particles of the sand dunes can be accessed in the SandDuneTerrainRender gameobject in the hierarchy. The solid terrain mesh can be selected and deselected on the left panel under the gameobject called SandTerrain.

Here is a screenshot of the models with the pointcloud sand dunes.

unity_point_cloud.txt · Last modified: 2023/10/19 09:08 by 127.0.0.1