What is the standard way to generate a double-sided quad in code?

I’ve been following this tutorial on procedural mesh generation:


In the part where they generate the house, there’s an issue where the eaves on the opposite side of the roof are invisible because of backface culling. They remedy this by generating an identical quad in the same spot and changing the triangle indices so it will be visible. But this causes issues with depth since they’re in the same spot, so their solution is to move one mesh slightly apart from the other.

Whenever I see a solution like this I can’t help but feel it’s a little bit of a hack, and I feel a little OCD about avoiding it. But in this case I’m not experienced enough to say if this is the best way or if there is a better alternative.

So what is the best way to generate geometry that is double sided?

Typically, doubling the geometry is the best way to do it. Some people suggest using a shader that disables backface culling. This method works too, but isn’t typically recommended because it introduces more complexity than really is necessary for handling the lighting correctly on the backside, where the normals face away from the surface. So the most robust way is to just double it CPU-side like in your example.

I’m a little confused about the relevance of the depth issue though. I searched through the article you linked to for references to depth, and the area where they treat this talks about the issue being between the house’s roof and its walls (the very top of the walls would Z-fight the rooftop where they connect). This is to do with two different bits of the geometry for the house, and not related to doubling geometry to achieve two-sidedness.

Unless I found the wrong section, you shouldn’t need to worry about that.