# What is better to use for real-time computing Mesh - Plane intersection points, GPU or CPU?

I want to write plugin (library) for Unity3d (it doesn't matter which framework I will choose for this, question is ), for cutting arbitrary mesh with plane (for simplicity it will be plane for beginning).

There are following steps:

1) check every triangle whether it lies above, under plane or intersected by plane, assign all vertices to VER_ABOVE or VER_UNDER lists, recalculate triangles, put them in TRI_ABOVE or TRI_UNDER lists

2) Split intersected triangles into triangle and quadrilateral, triangulate last one and put them in corresponding lists (TRI_ABOVE or TRI_UNDER)

3) Triangulate slice surface, assign it to TRI_ABOVE and TRI_UNDER

And now the question:

Where it is better to calculate intersections, triangulation (for example I will use Constrained Delaunay Triangulation or Sweep Line Non-Convex Polygonal Triangulation cutting into monotone polygonals) and other stuff: on CPU or on GPU (using Shaders), if someone could explain me general pipeline from loading cashing mesh to memory and so on on GPU and on CPU, so I can better understand the most time consuming actions and can optimize some stuff.

I will also be thankful for sharing link on code examples calculating similar stuff.

• In general it's about 10 times harder to get your code correct on the GPU than on the CPU, so regardless of where it's faster, I'd recommend you start by getting everything working on the CPU. – Dan Hulme Jun 16 '17 at 9:07
• Thanks, Dan, you are quite right, I do not have enough experience writing for GPU, I just want to understand general performance ideas. – Ivan Yakovlev Jun 16 '17 at 16:37
• It really depends on what your goals are. Is this something you want to do in real time? During runtime of your game? During "real time" editing in the editor? How complex are the meshes you intend on splitting? – Alan Wolfe Jun 16 '17 at 21:57