What causes clipping and why is it such a common bug in video games?

548 views

I’m playing *Cyberpunk 2077* right now, and it’s a beautifully rendered visual masterpiece of a game, but the clipping issues are ubiquitous to an almost absurd degree.

You see this in “finished” games as well (particularly the Soulsborne series where I can’t count how many deathblows have come by way of an enemy’s attack landing right through a wall or floor).

I’m curious as to why it’s so common. Thanks in advance!

In: Technology

4 Answers

Anonymous 0 Comments

Everything visible in a computer game is made up of a mesh of small triangles. Triangles are made up of three corners known as nodes. The face of the triangle has an “inside” and an “outside” face. On a properly meshed item in the game, all the outside faces should face outwards on the object.

If you take a single point and want to work out if it’s inside or outside a 3D object, you need to work out whether that point is on the inside or outside side of every single triangle making up the 3D object. To be inside the object the inside face of every face must face the point.

Now to truly check if two 3D objects (A and B) are overlapping – you check every single node on one object A against every triangle on object B and then do that again but compare every node on B against triange on A. In a game where everything is comprised of millions of triangles with hundreds of objects, very quickly this is computationally infeasible. (Not to mention self-collision, working out if a flexible thing like a player character is intersecting with itself is an even bigger headache!).

So the games cheat.

Lots of objects in the game have another simpler set of geometry that’s not rendered, but used for collision. This geometry, primarily made of cylinders, spheres and cubes allows you to use a load of mathematical tricks such that you can check if any of these shapes are overlapping way easier. For example, two spheres, you just measure the distance between their centres and work out if it’s less than the sum of the two radii. The problem is, these shapes don’t match the 3D mesh perfectly so some clipping is inevitable.

With thin things like walls, it’s easy to make some optimizations that means collisions aren’t always detected. For example, you might simply not allow the enemy characters’ centre within a certain distance of the walls. That way the enemy character should never be able to move through the wall, and you don’t even have to bother to do a collision check – excellent! Except this shortcut doesn’t stop part of the enemy moving through the wall – like a sword!

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