Basic Geometry Processing Using The Compute Pipeline
- Jeremy Baldwin

- Aug 24, 2024
- 2 min read
Updated: May 16
Overview : Written in UE5.4
In this article, we will look at how to greatly speed up complex and / or costly geometry processing operations by building a system that leverages compute shaders at editor time.
Result
Build data such as curvature, convexity, concavity, etc. for dense geometry in short order.
Mesh Statistics:
Vertex Count For Frog Model : 382,611
Triangle Count For Frog Model : 765,210


Let's Begin
Step 1: Plugin Module Structure
Our plugin will require two separate modules which are as follows:
Step 2: Prerequisites
Open the .plugin file and switch type from Runtime to Editor for both modules. Secondarily, switch the Loading Phase on ComputationalShaders to PostConfigInit instead of Default.
Open the Build.cs file for the ComputationalGeometry module and match the following private dependencies:
Open the Build.cs file for the ComputationalShaders module and match the following private dependencies:
Step 3: Module Setup .h / .cpp
The ComputationalGeometry .h / .cpp files are standard boiler plate module code (empty StartupModule() and ShutdownModule()). However, there is a simple addition we need to make to the ComputationalShaders.cpp file in the StartupModule() method. Follow the code comments for breakdowns, notes, and suggestions.
Step 4: CGPreProcessor .h/.cpp --- ComputationalShaders Module
The CGPreProcessor source file implements a geometry scraper and data initializer. Follow the code comments for breakdowns, notes, and suggestions.
CGPreProcessor.h
CGPreProcessor.cpp
Step 5: CGProcessor .h/.cpp /.usf --- ComputationalShaders Module
The CGProcessor source file implements an compute pipeline stage where data is sent to the GPU for faster processing, then read back to the CPU for use in building a new static mesh. Follow the code comments for breakdowns, notes, and suggestions.
CGProcessor.h
CGProcessor.cpp
CGProcessor.usf - Located in Shaders/Private
Step 6: CGBuilder .h/.cpp --- ComputationalGeometry Module
The CGBuilder source file implements the front end API for collecting, pre-processing, dispatching and building static mesh data. Follow the code comments for breakdowns, notes, and suggestions.
CGBuilder.h
CGBuilder.cpp
Step 7: CGEditorSubsystem .h/.cpp --- ComputationalGeometry Module
The CGEditorSubsystem source file implements a basic class which extends UEditorSubsystem and enables the ability to call a function from cmd that runs the geometry processor on a selected actor. Follow the code comments for breakdowns, notes, and suggestions.
CGEditorSubsystem.h
CGEditorSubsystem.cpp
Step 8: Build and Run
Build the project and run the editor. Once the project is loaded, select an actor in the level which has a dense triangle count and evenly spaced triangles for best results. If desired, this system can be modified to work on lower poly meshes with uneven triangle distribution.
Run the following command:
ComputationalGeometry.BuildData
Upon finishing, the data should be output and stored in the uv channel 0. Simply make a new material and follow the setup below:

Example of Concavity (red) / Convexity (green)

Models are modified versions of two template projects provided by Zbrush. The meshes had modeling changes and the topology resampled to fit the criteria of this demonstration. These assets are owned by Pixologic and used for educational purposes only.
Additional References





