<p>Describing a full CSG algorithm in a forum post is something really hard, and probably you will not find a complete answer to what you are asking here, but I can give you some suggestions.</p>

<p>First of all, CSG on polygon meshes is not usually employed on real-time graphics, because the algorithms are still considered to be too much resource-intensive. If you are looking for these kinds of algorithms, I would suggest reading books on computational geometry, of which Mark De Berg's is commonly considered a good introduction to the topic. If you are planning to pre-compute everything, then classic CSG algorithms are the way to go.</p>

<p>However, for just adding craters on a field, CSG seems to be too much overkill to me, and I would suggest some completely different approaches. If you want just a visual result (i.e., your player won't be able to go into the crater), you could use techniques such as z-buffer carving or parallax occlusion mapping, combined with some sort of decal system (preferably, using some deferred-like rendering system). Otherwise, if you need proper collision detection, you will actually need to change your mesh. You can easily apply some vertex modification operators around the center of each crater, such as pushing them down according to a radial-basis function (i.e., spheres, gaussians, etc). To accomplish this in realtime graphics, I would suggest using compute shaders or vertex feedback transforms, instead of computing everything in the CPU. These techniques will even allow you to add craters dynamically. Think of some really nice meteor strikes taking place.</p>

<p>I'm sorry for not being too descriptive, but I hope that some of the keywords that I have put here may help you out on finding a solution to your problem.</p>

CC BY-SA 4.0
2019-05-03T14:01:49.637Z
2019-05-03T14:07:56.703Z
2019-05-03T14:07:56.703Z
vgs
<p>What I would like to do is to create a crater on a field. To do so, I thought that creating a universal crater object (something cone-shaped) and then subtracting it from the field on a specified point might be a good idea. </p>

<p>So I would specify a "middle point" on the field, take the lowest point of the crater and move the crater by its lowest point onto the middle point of the field and then push it by its size of the crater into the field. Then apply said subtracting operation.</p>

<p>My question is: Are there any techniques/libraries which help me accomplish this? They should be either openGL-compatible or work on .obj file format.</p>

CC BY-SA 4.0
2019-04-20T19:59:30.250Z
BTW, the term you're looking for is CSG: [Constructive solid geometry.](https://en.wikipedia.org/wiki/Constructive_solid_geometry)
Nicol Bolas
<opengl>
How to do CSG on 3D triangulated objects, originally stored as a .obj file, using openGL or other libraries?
topkek
# How to do CSG on 3D triangulated objects, originally stored as a .obj file, using openGL or other libraries?

(Asked by: username_0 on 2019-04-20)

What I would like to do is to create a crater on a field. To do so, I thought that creating a universal crater object (something cone-shaped) and then subtracting it from the field on a specified point might be a good idea.

So I would specify a "middle point" on the field, take the lowest point of the crater and move the crater by its lowest point onto the middle point of the field and then push it by its size of the crater into the field. Then apply said subtracting operation.

My question is: Are there any techniques/libraries which help me accomplish this? They should be either openGL-compatible or work on .obj file format.

**Tags:** opengl

> **Comments:**
> **username_1**: BTW, the term you're looking for is CSG: [Constructive solid geometry.](https://en.wikipedia.org/wiki/Constructive_solid_geometry)  

---

## 1 answers

### Answer by username_2 on 2019-05-03. Score: 2 | Accepted answer

Describing a full CSG algorithm in a forum post is something really hard, and probably you will not find a complete answer to what you are asking here, but I can give you some suggestions.

First of all, CSG on polygon meshes is not usually employed on real-time graphics, because the algorithms are still considered to be too much resource-intensive. If you are looking for these kinds of algorithms, I would suggest reading books on computational geometry, of which Mark De Berg's is commonly considered a good introduction to the topic. If you are planning to pre-compute everything, then classic CSG algorithms are the way to go.

However, for just adding craters on a field, CSG seems to be too much overkill to me, and I would suggest some completely different approaches. If you want just a visual result (i.e., your player won't be able to go into the crater), you could use techniques such as z-buffer carving or parallax occlusion mapping, combined with some sort of decal system (preferably, using some deferred-like rendering system). Otherwise, if you need proper collision detection, you will actually need to change your mesh. You can easily apply some vertex modification operators around the center of each crater, such as pushing them down according to a radial-basis function (i.e., spheres, gaussians, etc). To accomplish this in realtime graphics, I would suggest using compute shaders or vertex feedback transforms, instead of computing everything in the CPU. These techniques will even allow you to add craters dynamically. Think of some really nice meteor strikes taking place.

I'm sorry for not being too descriptive, but I hope that some of the keywords that I have put here may help you out on finding a solution to your problem.


---

