Patashu

vertex buffers in GMS2

Sep 28th, 2026 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. But tl;dr in case this is new stuff to them:
  2. - A vertex buffer is basically just a gigantic data stream of draw information that you can add a bunch of primitives to in a "batch", then do a draw call and have GameMaker process every primitive in the batch all in one go.
  3. - A vertex format allows you to specify exactly what sort of data you want to encode in a vertex buffer, especially as far as shaders are concerned. Are you working with flat colors? If so, maybe you don't need texture coordinates. Do you want to do normal mapping? Maybe you want two texture coordinates. Stuff like that.
  4. - Normally GameMaker automatically handles all the batching for you in the Draw Event. What's important to keep in mind is that a batch *must* necessarily be processed with only one shader, vertex format, and blend mode. If you want to switch any of these around, that means either encoding more data and writing a more complicated shader to process each case, or doing separate batches entirely (again, GameMaker automatically handles this internally when calling these functions). More batches means more performance cost and an implicit depth order (one batch necessarily is "on top" of the previous), so keep that in mind.
  5. - One very handy feature that batching allows you to do is to utilize the depth buffer, which basically lets the graphics pipeline know not to process a pixel in the batch *unless* its depth is further in front. Naturally you'll want to look through the docs and include something in the vertex format that allows you to take advantage of this.
Advertisement
Add Comment
Please, Sign In to add comment