14 ms·
VoxelSpace: Terrain rendering algorithm in less than 20 lines of code (2020)
- khedoros1 2y ago[2020] could go in the title (or even [2017], looking at other comments in the thread in the following discussion link). There was also a discussion in 2021 of the same repository: https://news.ycombinator.com/item?id=26631995 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.
- deleted 2y ago[deleted]
- louthy 2y agoVoxels was an interesting technique for about five minutes in the early 90s, but they could never really be rendered at a high enough resolution for them to look good imho.
- parlortricks 2y agoJohn Lins https://youtu.be/8ptH79R53c0?si=33yYWMbfNAiJw0X8 https://youtu.be/8ptH79R53c0?si=33yYWMbfNAiJw0X8 Crystal Island looks amazingly detailed and smooth. Wish he would continue or share how.
- mllev 2y agoYou should check out the game Teardown and then perhaps you will modify your perspective
- elpocko 2y agoOr maybe not, because it looks really bad compared to other, more or less state of the art engines. The most remarkable thing about Teardown is its physics, not its graphics.
- big_paps 2y agoOutcast was such a beautiful looking game !
- qingcharles 2y agohttps://news.ycombinator.com/item?id=42590568 https://news.ycombinator.com/item?id=42590568
- harha_ 2y agoIt looks really good for such a simple algorithm. I love this!
- thewanderer1983 2y ago>It looks really good for such a simple algorithm. I love this! If you like that, you should check out Inigo Quilez https://www.youtube.com/watch?v=BFld4EBO2RE https://www.youtube.com/watch?v=BFld4EBO2RE Here is the shadertoy link with code https://www.shadertoy.com/view/4ttSWf https://www.shadertoy.com/view/4ttSWf
- NKosmatos 2y agoI remember reading about this somewhere (could be from an older HN post), but this time I decided to add a comment so that I don’t lose it. Being a flight sim fan, I still remember playing Comanche for the first time and the wow factor. It was something from the future or from the movies, you got the feeling that you were leaving in the computer era :-)
- karmakaze 2y agoI remember Commanche and how it reminded me of being wowed by "Rescue on Fractalus"[0] (aka Behind Jaggi Lines pre-release) procedural generation on the 8-bit Atari. [0] https://www.youtube.com/watch?v=FbZ-chrOgGg https://www.youtube.com/watch?v=FbZ-chrOgGg (landing on planet is at 1:00)
- purple-leafy 2y agoAmazing graphics and movement for the time
- pcblues 2y agoBehind Jaggi Lines also gave me the biggest jump-scares of any video game before or after. Shattered my nerves late at night with headphones on.
- rzzzt 2y agoNovalogic used this technique for terrain rendering for quite a while, my favorite is the first episode of Delta Force. It looks like Comanche 4 and the original Black Hawk Down did away with this method and switched to a polygonal engine: https://en.wikipedia.org/wiki/Comanche_4#Reception https://en.wikipedia.org/wiki/Comanche_4#Reception
- mthoms 2y agoI have such fond memories of building a terrain viewer like this (first in Pascal, then in C & Assembly) in the 1990's at the same time I was learning the requisite trigonometry in high school. 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.
- layer8 2y agoI’d love to live in an alternative timeline where GPUs are voxel-based.
- kimixa 2y agoDespite the name, there's not really much here that has much to do with "voxels" - it's a heightmap and raycasting. 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.
- layer8 2y agoIt has been generalized to stuff like what is linked in https://news.ycombinator.com/item?id=42590154 https://news.ycombinator.com/item?id=42590154. 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.
- kimixa 2y agoThe issue with voxels is sparseness - to have any hope of storing a world in the ram we have available it pretty much needs to have some variable length encoding, which makes it extremely difficult to use in a parallel manner as required by hardware. 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.
- 2y ago
- davrosthedalek 2y agoI just say mars.com (no, not a domain. A program. A video: https://www.youtube.com/watch?v=_zSjpIyMt0k https://www.youtube.com/watch?v=_zSjpIyMt0k) Edit: Pouet has it: https://www.pouet.net/prod.php?which=4662 https://www.pouet.net/prod.php?which=4662
- Grosvenor 2y agoand to be clear mars.com ran /smoothly/ on an 8Mhz 286.
- kragen 2y agoThe readme says, "If you have a 386 or better with VGA graphics, run mars and use the mouse to move around the landscape." Are you sure it will run on a 286?
- Grosvenor 2y agoYes. It was 16bit code. I ran it on my 8mhz 286, it ran smoothly. On a 386 like my AMD 386/DX-40mhz it ran smoother than butter, with a 486/66 is was essentially too fast.
- imiric 2y agoThis is very neat. I miss the era when novel and elegant algorithms like this delivered magical experiences. 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.
- binary132 2y agoI’ll never forget my disappointment when I discovered that the higher resolution offered by a better GPU meant more display pixels, not more triangles. I thought it would make all the models in Descent 3 smoother. :)
- idiotsecant 2y agoThis is mostly rose colored 1/4" thick welding goggles, I think. There are some mind-bendingly good moments in modern AAA video games. Sure there is some repeat sequelitus but there's original stuff too, and the tech definitely enables it. I can remember a lot of old really, really, really bad videos games too!
- mouse_ 2y agoThat magic is still there, it's just overshadowed by capital. It's hard to find magic in a sea of marketing. Try Noita, it's quite fun.
- imiric 2y agoI enjoy Noita, and interesting games like it, but I wouldn't describe it as "magical". Indies certainly are more enjoyable to play, but very few evoke that same feeling of awe like when you first experienced Doom or Mario 64 in the 90s. In a way I pity newer generations that have grown up in a digitally overstimulated world and missed the era when technology truly felt magical. 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.
- Sleaker 2y agoIts a neat way to render, but I don't think it qualifies as voxel, it can't render arbitrary volumes, and the data storage can't contain more than a single position for a given x,y. It's just a neat implementation of a heightmap renderer no?
- kragen 2y agoYes, the name they gave the algorithm is misleading.
- cubefox 2y agoI would say it clearly counts as a voxel engine. Heightmaps don't support overhangs like octrees do, but the heights are in the end stacks of voxels. An octree without overhang would look exactly the same.
- hyperman1 2y agoAfaik, voxel means something like volume element, (cfr pixel as picture elemen, with x for coolness). As every column is a 3D box in this rendering method, I have no issue with describing it as a 2x2 matrix of voxels.
- int_19h 2y agoHeighmap renderers like this were definitely called "voxel" at the time.
- a1o 2y agoHey, I made a game using this technique here https://eri0o.itch.io/i-rented-a-boat 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.
- Yoric 2y agoYou can do that in AGS? I'm impressed!
- IAmGraydon 2y agoEvery time I see a voxel landscape it reminds me of this: https://en.wikipedia.org/wiki/Comanche_(video_game_series) https://en.wikipedia.org/wiki/Comanche_(video_game_series)
- kragen 2y agoThat's what this GitHub repository is about, as it explains at the top of its README.md. No voxels are involved either in Comanche or in this repo.
- namuol 2y agoHighly recommend doing software renderer stuff like this for fun. Raytracers are a popular sort of project but this sort of retro realtime rendering code makes for a great weekend project too. I implemented basically the same algorithm ages ago (actually I ported some SDL code as an exercise to learn canvas2d): http://namuol.github.io/earf-html5/ http://namuol.github.io/earf-html5/ 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…
- jchook 2y agoThis is so cool. 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 >:)
- dang 2y agoRelated. Others? VoxelSpace – Terrain rendering algorithm in less than 20 lines of code - https://news.ycombinator.com/item?id=38051859 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 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 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 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 https://news.ycombinator.com/item?id=15339016 - Sept 2017 (2 comments)
- sota_pop 2y agoVery cool project and nice work! While I'm not very experienced with graphics rendering, I use a lot of computational geometry for work. I also implemented the Diamond-Square algorithm in matlab to generate randomized landscape terrains for a grad school project. Combining my generator with this rendering algorithm would be pretty fun to create and explore digital landscapes!
- stevefan1999 2y agoThis reminds me of how Wolfenstein 3D and to some extents how Doom works
- jesterswilde 2y agoI built a web version based on your post: https://jesterswilde.dev/vertrend.html https://jesterswilde.dev/vertrend.html