Not colorblind

Posted on 23/02/2015

Eww! What is that?! OK, I know it isn't pretty... I didn't spend time prettying it up. But this is the engine running in colored block mode, as opposed to textured block mode. This is designed to create worlds like in the game; Cube World. Now, you could have achieved this with textures, and the cool gradient color thing spread over the world that Cube World does could also be applied to textures. So, why bother doing this? Well, it's also handy for saving memory. For a texture to be applied to a vertex it needs to have 2 floating-point numbers, whereas a colored only block doesn't need them at all! For comparison; the world you see above (around 33m voxel spaces) when textured takes up 220,000K memory, and when it's NOT textured it only takes 170K. Now those numbers represent the whole program's memory usage, which means that 50,000K was used to hold texture coordinates alone! That's nearly 25%. And at the moment, the world isn't that complex, when we start adding trees, caves and things like that, that difference becomes exponential. So it's safe to say, that a color only world has more leg-room for sheer size. And that's why it's a mode worth having.

Switching between these modes is currently being done via constants. This is because GameMaker: Studio now has a cool little feature where the compiler checks against constants and won't compile anything from the following block if that constant isn't flagged. You could have 100 if statements checking against constants and it'd have no effect on performance in the final build if none of the constants were true as that code wouldn't be there at all! Nifty. This does however mean you can't switch mode mid-game, but I don't consider that an issue, as you'd make a game one way or the other. Though if you did want it for some reason, you can simply go through and replace that constant with a variable, however you will lose the optimization.

Another thing I worked on is progressive generation. I already had done this for modelling. What I mean by progressive is that a chunk's data or mesh can be created over several steps, which will help the engine maintain a playable frame rate. It's helpful for big worlds and testing as now I don't need to wait for generation to finish before it runs. I just run it and the world builds, still needs optimization though.