Post news RSS Half-Craft: Dreaming about GPU and RAM sheeps

In this article, I describe what happened in the last 3 months, and show you what have I done in the last 3 months.

Posted by on

Hey everyone!

So I didn't post in 3 months, which is an unusual amount of time to be off. It can mostly be attributed to demotivation and winter break, since optimization is hella boring and I don't want to do anything during the break. However, I got back into business and I have some impressive stuff to show to you guys.

Hiring (for free)

To make this notice clear, I decided to put it here. If you are proficient in C++, know what you are doing, and want to volunteer for this project, then hit me up on Discord in DM (b4n4n4#3701), or in the channel #hiring at the server down below.


Alright, so to set it straight, I have been and am using unefficient ways to generate chunks, render the game, and store chunks. You see, all of the chunks get generated at the initialization. This is quite bad, since the player most likely won't visit all of them.

The second problem is rendering the blocks. Blocks are just cubes, 8 vertices, 6 faces, they are not that big. They are easy to render for the GPU if their number is around 100-200. However, if I create 10000-20000, it easily becomes a big load for the GPU, since the PCI bus bottlenecks the GPU and the driver overhead is really high. Enter the VBO. It's an object on the GPU that only needs to be uploaded twice and is rendered everytime the game asks to. However, the calls still have PCI and driver overhead, so the FPS gets stable, but not stable enough to be 60 FPS.

The memory problem, for me, is the most fascinating one. The problem here is that the (sub)chunks in the memory get stored no matter if they have something in them or not. The VBOs of blocks have a similar problem, and I resolved this by creating a new object everytime it had something unique in it (this could partially be called Copy-on-Writing (COW) btw, which is heavily used in the memory management of some OSes). This made Half-Craft needing 500 MB of memory to 100 MB of memory for a 256*256 pregenerated world. For the VBOs, this further stabilized FPS.

Half-Craft memory consumption

New blocks

I added 28 new blocks, most of them are from the alpha game, but not the textures, which are from the 1.* games. 16 of them are wool, the rest is just miscellaneous blocks. I added them because hecks and shits and giggles, and I didn't want this update to look so empty on the outside.

Color palette

Using the

At last, an appetizer for the horrible lands of the world

Miscellaneous things

I also added some things which I thought didn't belong to any common category. Here are they:

  • The default weapon is the hand (as demonstrated in the picture above).
  • The sound that the stepping makes is 50% Windows XP Error Sound and 50% Minecraft Grass stepping. Yeah, I came up with this one randomly lol on one morning.

  • Block breaking no longer works (due to the Copy-on-Writing mechanism).

Coming up

I really want to improve on:

  • World generation of the world, like add trees, beaches, oceans, just general Minecraft stuff.
  • the Crafting part of Minecraft, as I don't want to bother with that later.
  • Optimizations? Meh, I think I will do them later on, however, I really want to try to optimize the VBOs even further by grouping the cubes into large VBOs.

TL;DR about the article

Discord server if you want to talk with me:

discord embed

Until then, cya later in a few months :))))))))))))))))))))))))

- b4n4n4


Nice to see progress! One recommendation is that you should make blocks their true resolution (16x16) and just enable point filtering by default (gl_texturemode gl_nearest_mipmap_nearest). Right now they have some weird artifacting.

I would offer to help if I wasn't so busy, but at the very least I wish you luck on this project, it's looking really cool.

Reply Good karma Bad karma+4 votes
b4n4n4 Author

Yeah, that artifacting is dithering, I enabled it since GoldSrc only allows 8-bit sprites, the image format that the blocks are using, and I forgot to turn on the filtering option by default.

Reply Good karma+4 votes

Definitely interesting, I wonder if it's possible to implement more advanced stuff like a proper block breaking mechanic, break time dependent on the type, and other stuff like more advanced world generation like caves.

I know this is goldsrc we're talking about but you've already done a good bit of stuff I never thought possible.

Reply Good karma Bad karma+2 votes

This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Related Games
Half-Life First Person Shooter