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.


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.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.