Friday, September 20, 2019

Branching Out: the Growth in Tree Quality

Ah, trees... Believe it or not, they've been in Mary's Magical Adventure since its development began, in World of Kirbycraft v0.75! There's some cool things to talk about that I've been developing just within the last couple days, but first, let me tell you a story about the history of these leafy things...
(This post has an AI-generated voice reading video available. To hear it, play this video and read along!)

Out of Place Cutouts

In the beginning, trees were pretty basic. In fact, they were just like the trees in Doom, a game from over 20 years ago at this point! Just like in that game, they were paper-thin images that rotated to face you. The only thing that made these trees unique was the code ran upon each tree spawning, which gave it a random tree image. I would say these trees were fine, but really, there were two problems with them...

Ripped from Reality

World of Kirbycraft, even back in those days when the game looked pretty bad, still had some form of a cartoony "art style" in it. These trees completely contradicted that, looking like pictures of real trees cut out and glued to the ground, like the game's world is just something a kid and their parent threw together by cutting out pages of magazines... I don't believe I was going for that style, but looking back, it's like looking at early 3D games that intended to look realistic. They were fine then, but now look like a joke compared to unrealistic games.

No Originality

You may think I was just experimenting, seeing what worked and what didn't, but no. I started development of World of Kirbycraft while I was still making Doom II: The Monster Invasion's last iteration (which in my opinion was the worst).

When I needed things like objects and code, I'd grab it from that mod and slap it into World of Kirbycraft, and that's exactly what happened with the trees and grass.

While the "realistic" trees worked mostly fine in Doom II: The Monster Invasion, they completely clashed with World of Kirbycraft's style. Unfortunately, I didn't know any better until years later...

The Crappy Image Legacy


In World of Kirbycraft v1.4, Hell City was introduced. As it was a complete ripoff of Kirby Air Ride's City Trial map, one area was a forest with many trees. Predictably, those were the same exact trees used in every previous version. There's not much to say other than just how out of place they still look.
Just when World of Kirbycraft got renamed to Mary's Magical Adventure in v1.6, the trees were thankfully changed to use better images. Mind you, they still didn't completely fit, but were more cartoony. The best one was the one on the right in the screenshot above, which came from a Terry WAD. It was just too pretty of a tree sprite for me to let it get wasted in a stupid waste of time like that!

Despite getting these new, better images, unfortunately these trees were only used in two places:
  • Hell City's island - In the park
  • City Street Run - Around road corners
Apologies for the short section, but I really thought I did more with these better trees. However, neither version can beat what I've done to the trees lately!

The Perfect Trim

Am I...seeing things? Are these really 3D? Nature finally looks right!
When Mary's Magical Adventure's next version is released, oh, are people in for a massive tree upgrade! For once, trees actually feel like they belong in the game's world, with more 3D, detailed designs that are actually interactive! Let's show what makes these new trees really cool, one point at a time!

"3D Graphics!"

Only a video could do this justice, so...just watch this video of both new trees and admire how 3D and believable they are now. Don't question the weird music, I like messing with Guitar Hero songs' individual channels.
Yes, you're not seeing things. Mary's Magical Adventure's trees are made like more modern games now; The tree itself is a 3D (voxel) model and 2D leaf cluster sprites are placed on top of parts of it, giving it a 3D look voxels alone couldn't give. This is seemingly the same thing a lot of games do for trees, like Oblivion and Sims 3(?), bringing Mary's Magical Adventure into a more modern time, unlike...some things.

I said these are interactive above, and you might not expect all that you can do with these trees. For one, you can knock leaves off of the trees with nearly any attack. If you hit leaves with a hammer, they will scatter and float through the air, but hitting them with a fireball will catch them on fire, making the leaves turn brown, drop to the ground, then turn into flames. It looks good in motion and is satisfying to do. In the future, there will be more of a reason to randomly become a pyro.
Only you can prevent wildfires...if you can resist the urge!
If burning leaves isn't good enough, how about the whole tree? Yes, if you damage the tree itself enough, it'll lose all of its leaves at the same time then collapse. Burn it enough and instead, every single leaf will start burning, then the tree dramatically falls down. If either of these events happen, the tree stays gone, even if you leave the area.

Now, don't worry if you like trees; You don't have to destroy fictional vegetation, but if you want to force all leaves off of a tree without permanently destroying it, just hit it with a cold attack like an Ice Ball and it'll start shaking then jump as it loses all leaves. When this happens, the tree survives and will re-grow its leaves back when you move far enough away from it.

This video shows all three tree deaths:
Now, all of this interaction comes with a cost, and that's a sprite render time increase of 0.02 per tree rendered in "high quality", which is what was seen in the videos. To counter this potential beauty turning into a lag source, all trees are drawn as a single image at far distances, just like the older trees. This results in the game rendering a single image instead of many leaf clusters plus a 3D model, and this is what saves the 0.02 sprite render time mentioned above.

This is actually something games do, more common on games with a continuous open world like Oblivion. I came up with the idea to do this before watching that video, so I had no clue it handled things the same way as my game. Oh well, I guess I can say I did something like Bethesda now. Whether that's good or bad's up to you, because...oh no, does this mean now I'll leave many game-breaking bugs in the final release? I hope not!

Anyways, if you don't like the trees abruptly changing between images and 3D models, you can adjust the distance by changing the r_objdrawdistance CVAR, which is a multiplier that defaults at 1.0. Increasing this will change the distances at which many decorative objects switch to lower quality, though it changes everything, not just trees. If on a lower-end system, it's recommended to decrease this to 0.5 or similar, given you can tolerate more obvious object pop-in.

Anyways, that's the latest update! There's more changes, but the new trees deserved their own blog post.

No comments:

Post a Comment