[C Bel] teaches Excel and he has a problem. Most of us — especially us Hackaday types — immediately write a VBA (Visual Basic for Applications) macro to do tough things in Excel. Not only is this difficult for non-technical users, but it also isn’t as efficient, according to [C Bel]. To demonstrate that VBA macros are not always needed, he wrote a 3D game engine using nothing but Excel formulae. He did have to resort to VBA to get user input and in a very few cases to improve the performance of large algorithms. You can see his result in the video below or download it and try it yourself.
The game is somewhat Doom-like. Somewhat. As you might expect it isn’t blindingly fast, and the enemy is a big red blob, but as the old Russian proverb goes, “The marvel is not that the bear dances well, but that the bear dances at all.” (And thanks to [Sean Boyce] for recalling that quote.)
You can download the spreadsheet with or without VBA if you want to try it or dig into the internals. It is really pretty impressive, including:
- An infinite procedurally-generated maze map
- Real-time ray tracing
- Occlusion calculation
- Basic illumination rendering
- Illumination and compute shader
- Natural displacement engine
Do we agree this is better than macros? We aren’t sure, but we were impressed you could pull all this off with formula manipulation.
Not that we haven’t abused spreadsheets ourselves (look at CARDIAC in a spreadsheet and — although not ours — Little Man). We’ve even used them for circuit analysis.
It is quite easy to get almost photorealistic images in Excel:
http://fs1.directupload.net/images/180218/gwoesnle.png
Well, I can say for certain that Gnumeric 1.12.32 doesn’t like it… and I shudder to think how complicated it was to debug that.
It *does* work in LibreOffice 5.4.2.2.0… in that it renders, haven’t figured out how to move yet.
Does anybody have any suggestions on how to better render 100+ photos in an Excel sheet? Excel has to save every photo in the file, which is fine but it does a horrible job of rendering them or allowing you to even view a worksheet with more than a few dozen shown at a time. It just cannot really keep up and is not even close to optimized for that. Even trying to use VBA tricks doesn’t really get you anywhere unless you use VBA to hide the photos not on screen or do other tricks that are also not much better.
Obligatory Excel roller coaster.
https://www.youtube.com/watch?v=IrVA1BBHFHw
There was a similar Easter egg
https://www.youtube.com/watch?v=c6nY0QkG9nQ
As cool as it was, I do believe that egg had nothing to do with using the Excel sheet to make a rendered world…
this was a beta 3d engine based of terminal velocity and was used in Fury,
https://www.youtube.com/watch?v=VTd4e2jia7s
Ok, I see this as an interesting exercise, but the approach is flat out wrong.
The top reasons to use vba are
1) it is much much easier to get right first time than compared to complex cell formulae
2) if it isn’t right, it’s much easier and faster to find and fix vba
3) If you go back and change your own spreadsheet, it’s much easy to find and modify the right bit of vba code
4) If another person is trying to do things to it, vba is far easier to follow.
I have seen (more than one) companies go close to bankrupt due to complex excel spreadsheets with interlinked formulas..
Just about anything complex (ie requiring more than 3 or 4 nested commands) should be done with vba.
And finally, vba is easy to learn and use – I have taught 6yo and board members simple vba, and it greatly enhances their productivity..
Aside from personally feeling that VBA is satanic spawn, too many people default to it out of lazy inclination vs getting a more elegant solution running. I’ve worked on tracking 6 points of activity for 12 macro-like sets of data and correlated this to fiscal year quarters for over 400 people. The file is under 1 MB. My predecessor has been trying to replicate the work with VBA and without a years worth of data, has a file 4x larger that doesn’t work.
Even when done correctly, you’ll have to jump between two different editors to work with VBA vs just one without it.
An elegant solution would probably require a few statements in R. No one cares how big the file is. But then too many default to Excel out of a lazy inclination.
By-the-by what are “macro-like sets of data?” Even Google doesn’t seem to know that one.
A better description is actually the reverse: 12 sets of data per individual and 6 parts of metadata per each set.
Essentially doing small database work in Excel. I knew this was a job suited for a database, but my peers have a hard enough time knowing how to enter a formatted date, let alone using Access of a SQL variant.
I think some of these responses miss the point – yes, you don’t want to build a large scale database system with excel if you have multiple users updating the same data etc etc..
But if you have some data sitting somewhere, excel is quite good at getting it out and presenting results to people, and can have very fast turn around times…
It’s also good on small amounts of data, or when data is only be updated from one source..
I often use vba to access mysql, or even to access large transaction files through a C addon I wrote over 20 years ago (that still works with the current version of excel!) that directly load results into vba. The user can then do quite a lot with the results WITHOUT going back to the original data..
Of course, sometimes I just do it all in php and on a web site. And other times I do it all in C++ as god intended. However excel/vba is great for certain jobs, where just excel (without vba) would be more than an order of magnitude more limited…
> And finally, vba is easy to learn and use
That may be so; however it’s important to keep in mind that VBA causes eye cancer. It’s worse than a nuclear war.
This would have been a lot easier to implement in powerpoint. There you could just port opengl to the powerpoint turing machine https://www.youtube.com/watch?v=uNjxe8ShM-8 and run the graphix on the virtual machine
Not related to 3D rendering, but there is a Japanese artist painting in Excel.
https://www.youtube.com/watch?v=OrwBc6PwAcY
its ray casting not tracing
GAH
It also has ray tracing for reflections and transparency. It’s in the actual article.
Looks like Berserk: 3D. Put a smiley face on the blob. Back in the 80’s I told many people that a 3D version of Berserk would be cool. The response from them all? “That would be stupid.”. Forward a few years and John Carmack and friends produced Catacomb Abyss, followed by two sequels, the founding of Id Software and the release of Castle Wolfenstein.
You can also do QR codes in Excel with no VB at all. http://blog.ambor.com/2013/03/create-qr-codes-in-excel-or-any.html
Next stop, emulation of doom
I find it amazing that after 19 comments thus far, no one has complimented this guy on his fine work.
Kudos to [C Bel] for thinking all that out; researching, creating, implementing, testing, debugging, re-testing, debugging, …. Wow! How much time was spent on all that??
Peace and blessings.
Thank you ! :)
Is there away of rendering atmospheric scattering in excel
Hi! OK it’s a good test for Excel spreadsheet formulas. Excellent work really. But I disagree that VBA is less fast/powerful (even if used by novice like me). Here is my own game made entirely in VBA Excel:
3D Engine (written in early 2016): https://youtu.be/7GJ5t-yELHI
Game “Dave vs Ziggy” (1st level playthrough): https://youtu.be/eU4KNLtWme0
Game “Dave vs Ziggy” (2st level playthrough – shootout with the boss): https://youtu.be/jaZL-1EEeM0