A simple 3D engine written in Lua using using lua-fenster.
Some time ago I wanted to learn more about 3D engines, so I read this tutorial series by David Rousset and then translated the TypeScript code from the tutorial series into Lua: Tutorial series: learning how to write a 3D soft engine from scratch in C#, TypeScript or JavaScript
This 3D engine is obviously not production-ready or really anything to be taken
seriously, but I had a lot of fun writing it!
It runs completely on the CPU and doesn't utilize any sort of hardware
acceleration or graphics library like OpenGL, therefore the term "soft engine".
This is actually a rework of a very old project of mine, which used
LÖVE2D instead of
lua-fenster (my own GUI library).
If you want to see the old version, check out the
old-love2d-version
tag.
The code is a bit messy though.
- LuaJIT 2.1 (highly recommended) or Lua 5.1 (newer Lua versions might work but not tested)
💡 Tip: On Arch Linux, you can easily install both with
pacman -S luajit lua51
. - LuaRocks
💡 Tip: On Arch Linux, you can easily install it with
pacman -S luarocks
.💬 Important: Make sure you configure LuaRocks to use Lua 5.1 (even when you use LuaJIT 2.1) by either using the
--lua-version=5.1
flag every time, or by configuring it withluarocks config lua_version 5.1
.
Download the repository and install the dependencies with luarocks
:
$ luarocks install --only-deps 3d-soft-engine-dev-1.rockspec
# OR, manually install dependencies:
$ luarocks install fenster
$ luarocks install dkjson
Afterwards, run main.lua
:
$ luajit ./main.lua
# OR, slower:
$ lua5.1 ./main.lua
Feel free to play around with the main.lua
file,
trying out different models and such.