I’ve learned that video game ‘clipping’ is caused by high velocity, thin colliders, and too-slow physics updates. Why are terrain surfaces in most 3D video games paper-thin? Why isn’t terrain given extra fill/thickness inside and under it to prevent ‘falling through the map into the void’?

2.79K views

I could see why you might not want to fill under the terrain in a game that features things like underground caves, but thin terrain seems to be present in a huge majority of 3D games (even those without underground features) and is not engine-specific. Why is terrain almost always a fragile piece of origami that’s so easily punctured?

In: Technology

39 Answers

Anonymous 0 Comments

In short, “because it’s expensive”. I’ve written some software that needed to do it “right”, and it’s a lot slower.

The correct way to avoid clipping is an algorithm that looks like this:

– Draw a line from my position last frame, to my position now
– For every triangle of every surface, calculate if the line crosses the triangle. (Note: this is surprisingly inexpensive if you do out the linear algebra. Still costs a few dozen mathematical operations though).
– If no triangles were hit, you’re fine. If one triangle was hit, collide with it. If more than one triangle was hit, choose whichever one was hit *first*, and collide with that one.
– Depending on your collision algorithm (i.e. if you bounce off and still are moving), do the whole thing again based on your new start-point and velocity.

Now, the problem is that this is insanely expensive for decently complex terrain. So, to make something functional, game engine designers need to cut some corners. The biggest one is to limit the area in which we look for triangles. The more triangles we can ignore, and the more efficiently we can ignore them, the faster it will be. The problem, of course, is that if we should have collided with something we ignored, we clip.

The second thing we can do is cut down on how much math is involved. Instead of calculating the intersection between our previous and current position with the triangle, we just check if we’re near (and on the wrong side of) the triangle. It’s a lot faster, but can (in some cases) cause somewhat weird artifacts.

You will note that both of these methods include tunable parameters: the designers need to pick the correct balance between better game performance, and the edge-case of clipping. Usually this is set so that in normal gaming, you don’t have clipping problems; those only come up when a player does something extremely weird.

You are viewing 1 out of 39 answers, click here to view all answers.