3
$\begingroup$

I'm learning to make some game assets for Unity using Blender, and in an effort to keep models low poly and reduce the number of vertexes, I've found that in some cases I can bypass vertexes and create a larger face that lies adjacent to the vertexes but doesn't connect to them. In the screenshot below, I've created a face by connecting the vertexes circled in red, and I've ignored the vertexes that are below this face (example circled in yellow).

enter image description here

There is a side effect to this approach, I can grab one of the window vertexes and pull it away and that indicates that perhaps this isn't the correct way to make a model:

enter image description here

Alternatively I can subdivide the top edge of A and use the vertexes to create multiple faces, essentially connecting up all the vertexes around the original idea of face A:

enter image description here

Should I be doing the latter, even if I want to keep the face count low, particularly for game assets? Is there a downside to the first more economical approach in terms of the game engine rendering or maybe creating unwanted artifacts perhaps?

$\endgroup$
3

1 Answer 1

3
$\begingroup$

The technique you're describing is similar to one used extensively in gamedev, intersection:

(taken from Stylized 3D Production Guide by Alexander Kuznetsov )

However, in your case it's not an intersection, the elements are touching exactly. The problem is, 3D world is implemented on floating point numbers, which are infamous for failing to be exact.

Let's create a bright, white plane, and slightly above a smaller, black plane.

Boring. Let's cut the plane in half on a diagonal. Still boring, looks the same. Let's separate the two faces. Still boring, we aren't punished for having the geometry separate. This is because each edge is defined by an interpolation between two vertices. And since both edges are built on vertices in same exact spots, regardless of how inaccurate the interpolation is, it is consistently inaccurate for both edges, as the same input is given to the same interpolation algorithm.

But what if I cut off fragments of the plane? Surely, the remaining part of the edge that had no problems a moment ago, still won't produce any problems? It's the same edge, right?

After recording the GIF, turned out I was (un)lucky - I still couldn't see any artifacts. But moving the view around, quickly revealed a problem:

What the f...irefly? The edges still overlap, but not perfectly, because they are defined by interpolations based on different vertices. And even though Blender tried as hard as possible to keep the interpolation same (that's why the edge isn't in a completely different place with a completely different orientation), due to the limits of floats, it couldn't do it perfectly. The camera rays now have a chance to pass through a very tiny hole between the edges. You can see it better if you increase the sample size, as more and more rays happen to go through:

The colors are chosen for high contrast, and so the effect is more visible than usually. However, in games, typically the camera angle to the object changes, because either the camera or the object moves. This results in blinking pixels that are quite visible despite similar colors of the front texture and the leaking texture.

You could deal with this problem by overlapping your faces a little instead, but then you get a similar effect of z-fighting (also caused by the infamous floats). You could add an additional triangle to one of the overlapping objects, going inside the other object, so that the z-fighting occurs in that triangle, but it's set to have the exact same colors as the geometry it overlaps with, so z-fighting is not visible...

... I think it is a moot point, though: you're designing something that seems to be a bus. Probably you're about to extrude it to a side. Once you have a truly three-dimensional object, you should be able to easily intersect objects without z-fighting.

$\endgroup$
1
  • $\begingroup$ Thank you so much, this is really helpful and answers my question fully. $\endgroup$
    – Isometric
    Dec 6, 2021 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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