GameMaker and Culling

Posted
I want to talk about a few quirks with how GameMaker handles culling.
Share
GameMaker and Culling by MattyAlanEstock

After spending far too much time confused as to why nothing was drawing on screen in a recent GameMaker project of mine, I wanted to make very clear notes on my findings.

Obviously, a quick choice if you're worried you'll cull the wrong side of your triangles is to default to showing all of them. A smart choice for folks looking to iterate extra fast.

Not me, I optimize first and ask questions later.

gpu_set_cullmode(cull_noculling)

No culling is fine for testing, but not optimal for a final product, so we "cull" the back sides of triangles to help improve the speed of rendering.

I like to make my 3D models using Blender, export them using the .obj format, and load them into my games using a script like this one by DragoniteSpam. It should be noted that Blender considers counter-clockwise triangles to be "frontfacing", such that "backface culling" means to cull clockwise triangles.

gpu_set_cullmode(cull_clockwise)

Consequently (and this is the important nugget of knowledge), I've learned that non-3D draw calls such as draw_surface can also be culled (almost certainly by accident). To avoid this, make sure you only cull counter-clockwise when drawing your HUD or other elements to the screen.

gpu_set_cullmode(cull_counterclockwise)

Hopefully my observations help you on your journey through making 3D games using GameMaker.