VoxelSpace: Terrain rendering algorithm in less than 20 lines of code (2020)
github.com
github.com
This could just be from getting old, but I feel like games have lost the magic they had when availability of hardware resources was limited. Back in the 80s, 90s and early 2000s we saw games push the medium forward practically every year, and certainly every generation. Developers squeezed all the performance they could from the hardware, using novel techniques and pure wizardry. Hardware advancements certainly helped, but it was never in abundance as it is today, so developers couldn't get complacent. Necessity is indeed the mother of invention.
These days I find fantasy platforms like the PICO-8 much more interesting than the latest rehashed release from any AAA studio. I don't understand how games that are essentially asset flips can be so successful year after year.
I can remember a lot of old really, really, really bad videos games too!
The only game that triggered this feeling for me in the past ~decade was Breath of the Wild. Many other games are fun and enjoyable, but very few have that same magic. Whereas in the 90s this was much more common.
I do concede that growing old could be part of the reason for losing that feeling, but I also think that the oversaturated market and lack of technical constraints play a role.
This was one of the prototypes: https://media.discordapp.net/attachments/953383695908216843/...
This was one of the prototypes: https://youtu.be/9Z8Bm8ZmWKI
There is also lots of cool tech happening at the more foundational levels in engines and frameworks, for example Epic’s Nanite/Lumen/MegaLights in UE5.
It is just that it is much more complex and much less obvious. Before, an advance could going from flat triangles to textures, using a clever maths trick. Now an advance is better shading in the corners of a room, using a clever maths trick. The difference is that people will be able to tell immediately how an improvement the textures are, but unless they are in the field, they won't be able to point out the shadows in the corner of the room. These shadows are not useless though, it adds up to better graphics overall, but it is not as impressive.
About the AAA gaming industry, the thing is that this is big business, these games are awfully expensive, financed by investors who want to see a return on their investment. Usually, it means that they study the market, see what sell, and do something along these lines. Not very original, but less risky.
The indie game industry is the opposite. There are thousands of studios, they can't beat AAA on content and polish, and they need to come out of the pack, so they need something else, like original ideas. But overcoming technical limitations is usually not the driving force anymore, as there are not that many limitations anymore. In fact, they usually underperform compared to AAA productions because it would be unaffordable otherwise.
I don't know much about the PICO-8 scene, how much of it is about overcoming the (artificial) technical limitations and how much is about using the platform "as intended" and focus on gameplay.
The CPU speed is also limited but it's a different kind of challenge to try to make a game be so complicated that there's enough math to even do to challenge the available CPU allocation given how few permutations of screen space are available to try to alter.
Depending on your game, RAM limitation and program space limitation might also come into play.
But the artificial limitations are only one element to why the platform is popular, the other element is the tooling.
Much like using Unity, Unreal, Roblox, etc you have loads of primitives and coding features (and music and SFX creation suites) at your fingertips built right into the platform, and how the limitations help here is to cap how subtle and complicated a person's goals are liable to be in order to help refocus the developer's attention back onto the gameplay loop.
It was a lot of fun to try to squeeze a game into 4 kB but I can definitely also admit that part of it was being able to use the extreme limit as an excuse for making things simpler and not have to worry about the game being ugly or not having sounds or not having a title screen and all the other 90% of stuff that would have been expected to turn it into a complete game.
I play around a bit with TIC-80. Some say it is just an open source PICO-8 and I guess it is to some extent. I paid for both but I have not spent as much time with PICO-8. I like that TIC-80 supports quite many different programming languages, but maybe PICO-8 does as well these days? There is no super obvious reason to use one or the other, so I go with the one with free source code.
Real retro gamedev is tempting, but it is difficult to find a real console that were heavily restricted while also being convenient to develop for. The fantasy consoles cheat a bit in being restricted like some early 1980's hardware while running code like some 2010's game engine. It's like the best of both worlds, but also a bit boring compared to writing something actually limited to what some old console could do.
If it does, then it doesn't show. It feels as though most major game engines have completely given up on performance-as-a-default in favour of simplifying (sometimes marginally) art workflows, and the frame rendering breakdown articles/videos I consume now and then entail baffling, utterly ridiculous and unnecessary drawcall counts, unoptimized geometry, poorly optimized shaders that give marginal graphical improvements, huge overdraw, etc.
It's gotten bad enough that resolution upscaling is becoming commonplace because of how ridiculous the per-fragment rendering costs are getting. That has no right to happen in games without high-fidelity subsurface scattering, volumetric effects, indirect lighting, raytraced reflections, etc. And yet it does. This is something nobody resorted to even in the 90s.
I recommend videos from the YT channel Threat Interactive, where they break down a lot of the horrifying rendering performance regressions that have become the norm in recent times.
And honestly, I'm not very impressed by volumetric clouds when games like Assassin's Creed Unity from 2014 had enormous, sprawling open worlds with high-quality visuals comparable to much more recent games that struggle to run on hardware with several times the juice.
Very often, modern games look straight up worse for much higher resource cost because they stop looking better once you're forced to drop from maximum settings(and you are). There's blurry AA techniques, resolution upscaling(ew), or the fact that lowering texture resolution often degrades graphics way, way harder than in older titles using similar texture fidelity.
We had plenty of shovelware like that ever since the Atari 2600 era too. People point to that (capped off by pacman and ET) as the cause of the console market crash of '83.
Later there were a lot of specialized game review magazines, though it wasn't easy to get hold of a review for a non-current game if you didn't have past magazine issues laying around. Then there was the Internet with increasingly many free reviews, especially once online advertising took off and game magazines moved to the Web, and finally we got accessible average user ratings from Steam or Metacritic.
If a game is bad today, everyone will know it. There are no bad movie tie-ins anymore. Games are at most bland, similar to an action movie sequel, or exploitative, by using addicting game mechanics. But they are rarely bad in the old sense. I've read that the new Indiana Jones game is better than most of the Indy movies.
Seriously? Have you seen the Nintendo and Steam stores? I mean, it's great that game development is so accessible now, but the amount of low quality and half-baked or abandoned Early Access games is staggering.
> Then there was the Internet with increasingly many free reviews, especially once online advertising took off and game magazines moved to the Web, and finally we got accessible average user ratings from Steam or Metacritic.
Reviews don't mean much when publishers enforce embargos, or when they invest in marketing to create hype and drive preorders, only to deliver a broken game at launch with promises to patch it over time. Or when they're gamed by review bombing one way or the other, depending on some internet drama. Or when review sites are given different weights in calculating the overall score, leading to alternatives like OpenCritic. So, yeah, reviews can be helpful, but they're far from reliable.
> If a game is bad today, everyone will know it.
Ehh, highly doubtful, as I mentioned above. And even if there are negative reviews, companies have many different ways of hiding how bad a game is, and still profiting from them despite of it. They can launch a broken/unfinished game, patch it over time, and still end up with good will from consumers because of the work they put into it. See No Man's Sky, Cyberpunk 2077, etc. This way they profit from preorders, take as much time as they want to deliver the experience they advertised (while continuing to sell a half-baked product), and ultimately end up with an unscathed reputation so they can do it again. Then there are outright scams like The Day Before, countless asset flips, lazy ports, etc. Mobile gaming is infested with this garbage.
However you define "bad game", these products are certainly hostile to the consumer and there should be regulation in place to prevent them. This situation is far worse than the one that led to the 1983 crash, yet gaming has never been as popular as it is today.
You can check it out here: https://store.steampowered.com/app/3133060/Gnomes/ ;)
In my opinion, whether a game is enjoyable or not doesn't really rely on whether or not they were technically challenging to make. I don't know any successful games that are in fact "asset flips", but I do know that a lot of the games that I really enjoy are not technologically "pushing the envelope" at all: caves of qud, cube chaos, kenshi, rift wizard, just to name a few.
I agree, but that's not what I'm saying. I was referring to cookie cutter games released by Ubisoft, the CoD franchise, and most sports games. They essentially use the same formula, sometimes even the same engine, year after year, and just upgrade the assets, and do some minor tweaks. Yet these releases are incredibly popular and people keep buying them every year. Similarly for lazy "remasters" for games released not even a decade ago. Now with AI upscaling it's even easier to just increase the texture resolution and charge half or even full price for it. It's practically a scam.
> I do know that a lot of the games that I really enjoy are not technologically "pushing the envelope" at all: caves of qud, cube chaos, kenshi, rift wizard, just to name a few.
Sure, and I enjoy many of those as well. A game doesn't have to be technically impressive to be enjoyable. But IMO these don't have the "magic"/"wow" factor that was so common back in the 90s. If you played Doom or Mario 64 when they were released, you were _mesmerized_ by what you were seeing. Yes, these were great games, but the technical wizardry was what made them stand out from everything else. The jump from 2D to 3D and hardware accelerated graphics certainly played a role in that, but it was also due to very clever algorithms than ran on the same hardware as other games that weren't as impressive.
Today VR can arguably deliver that "wow" factor, but that's mostly due to the technology rather than the games themselves. Even nearly a decade into the modern VR wave, there are only a handful of games that deliver an experience close to what many games in the 90s did.
I can basically think of only one example of a modern game that delivered that same feeling: Breath of the Wild. We were used to open world games, we were used to Zelda games, but we hadn't seen such design ingenuity and technical polish, especially on a handheld system. Tears of the Kingdom is arguably a better game, but it didn't deliver that same experience for me.
I agree that VR tech in general is just "wow" at lot of the time, even if the games are not that great. But I think that "Hello Puppets", "Scanner Sombre" and "Superhot" were all really cool and innovative, even within the VR scene. I think there's still some technological innovations possible that to deliver more "wow" moments.
Haha sure, there are also cases where a game is technically impressive but not actually good/enjoyable. The real magic is when both of these come together.
I think it's still too early for VR games to be both (with a few exceptions). We haven't quite solved major problems like locomotion, motion sickness, and comfort, of course. Maybe a few generations from now we'll start to see truly mesmerizing experiences that are both technically brilliant and enjoyable to play.
If you aim for the broad mobile market - then you will have some serious limitations, as the majority of humans do not have flagship smartphones.
And even AAA games for the PC market - the better your game runs, the bigger the audience you can reach. Like the other poster said, bigger textures are far from the only thing that is happening behind the scenes.
In other words, I wish I would have unlimited hardware ressources.
I always wonder if aliens are interacting with us through the anonymity of the internet. Things like this give me a (facetious) hope that they are. We can take from this that all aliens have flagship smartphones, but the majority of humans don’t.
VoxelSpace – Terrain rendering algorithm in less than 20 lines of code - https://news.ycombinator.com/item?id=38051859 - Oct 2023 (2 comments)
Voxel Space: Comanche's terrain rendering in less than 20 lines of code (2020) - https://news.ycombinator.com/item?id=26631995 - March 2021 (71 comments)
Terrain rendering algorithm in less than 20 lines of code - https://news.ycombinator.com/item?id=21944573 - Jan 2020 (116 comments)
Terrain rendering in fewer than 20 lines of code - https://news.ycombinator.com/item?id=15772065 - Nov 2017 (93 comments)
Show HN: Voxel Space – terrain rendering in less than 20 lines of code - https://news.ycombinator.com/item?id=15339016 - Sept 2017 (2 comments)
Edit: Pouet has it: https://www.pouet.net/prod.php?which=4662
Here's the author describing how it was done. Note the 64K data sizes. So they fit into one 16bit segment.
Back then, all kinds of low-level optimizations were necessary to make it work.
Figuring out how to do it, and optimize it with no books or internet to reference is one of the most personally rewarding things I've ever done.
https://eri0o.itch.io/i-rented-a-boat
It's made in Adventure Game Studio. It was made in a previous version of the engine that we hadn't optimized yet and I was too lazy to update it on itch page (but will one day). I have a write up there explaining how I made it but there are more details in the AGS forums.
There was also a discussion in 2021 of the same repository:
https://news.ycombinator.com/item?id=26631995
(and that thread links to other discussions too)
It's not quite the same, but I remember when I was first learning programming, I wrote a program that would generate a terrain heightmap, and do an isometric-style rendering using similar techniques. It was in QBasic, running on my middle school's 386-era DOS machines, and used graphics memory as its scratch space. Slow as heck, but I was fascinated with the output. It's one of the things that encouraged me to keep going with programming.
[0] https://www.youtube.com/watch?v=FbZ-chrOgGg (landing on planet is at 1:00)
In most contemporary games, you can occasionally see the mountains are hollow (from weird camera angles, clipping issues, etc).
However, with this method, your mountains are solid >:)
Obviously the linked implementation is way more performant and far simpler than mine, so if you’re looking for a reference I wouldn’t recommend my old coffeescript code…
It's kinda similar to Parallax mapping in a way.
I'd also be interested in what a "voxel-based" GPU would look like, they already support sampling 3d volumes in 3d textures, and the issues they have (namely memory use) seem pretty fundamental and I'm not sure how they can be overcome to match the scale of 3d environments expected today.
Clearly (?) the way the math works out, the polygon-oriented GPUs we have make more sense for 3D graphics. But one can imagine a universe where things would be different.
It's why for display pretty much every modern voxel engine processes the sparse voxel world into a dense surface list - which then maps (reasonably) well to triangles.
I'd argue this difficulty in parallelization is a bigger hurdle than "just" engineering effort.
Much of the way a GPU functions isn't because we decided we loved triangles, but we found things that parallelize well and worked backwards. And then on modern GPUs don't actually devote that much area to dealing with "triangles" - so little is gained that it's often not worth redesigning to remove that capability from data centre "GPUs" that will never see a single triangle in their lives.
Signed Voxel Octrees, and SVO Directed Acyclic Graphs in particular solve this pretty well. Most megavoxel engines are an implementation of this paper: https://graphics.tudelft.nl/Publications-new/2020/CBE20/Modi...
The term VPU is already taken though: https://en.wikipedia.org/wiki/Vision_processing_unit
Plenty of examples on https://www.shadertoy.com/
The principle that image generation methods are dictated by available bandwidth goes all the way back to the first graphical computers (for instance the weird color-attribute encoding in the ZX Spectrum is essentially an image compression method to get more graphical fidelity out of a very limited memory bandwidth).
Here is the shadertoy link with code https://www.shadertoy.com/view/4ttSWf