A tiny Minecraft-style voxel engine for the ESP32-S3, written in plain C on ESP-IDF. No Arduino, no GUI library, no 3D library. A software renderer draws a 64×32×64 block world into a PSRAM framebuffer and pushes it to an ILI9341 over SPI.
Aimed at the ESP32-S3 (N16R8 dev boards) today, with the ESP32-S31 as the next target.
- Procedural world: 64×32×64 blocks (128 KiB, held in PSRAM), generated at boot with layered 3D Perlin noise. Stone, dirt, grass, a single water layer, and trees (wood + leaves).
- Software renderer: view transform, near-plane polygon clipping, frustum culling, back-face culling, hidden-face removal against neighbouring blocks, then barycentric triangle fill with black edge outlines. Far-to-near painter's algorithm, no z-test.
- First-person player (2 blocks tall) with gravity, jumping and AABB collision against solid blocks;
ftoggles a free-fly mode. Yaw and pitch, ~103° horizontal FOV. - Break and place blocks via a DDA raycast from the crosshair (5 block reach). Placing is refused if the block would overlap the camera.
- Controls over USB serial (Serial/JTAG), plus three spare GPIO buttons.
- Textures.
spritesheet.h/spritesheet.bmp(8×8 tiles of 16×16 px, RGB565) are in the repo but not wired into the renderer; faces use flat per-block colours with top/side/bottom shading. - Block selection. Placing always places stone.
- Greedy meshing and LOD. Render distance is a fixed 10 blocks, with a 2048-voxel draw list, which is the main performance knob.
- Touch input. The XPT2046 driver (
main/touch.c) is in the tree but not built or initialised. See the note below.
| Part | Notes |
|---|---|
| ESP32-S3 | N16R8 (16 MB flash, 8 MB octal PSRAM). PSRAM is required for the framebuffer and world. |
| ILI9341 TFT | 320×240, landscape, RGB565, on SPI2 |
| Backlight | Wired to 3V3. No GPIO control by default (PIN_NUM_LCD_BL = -1) |
| ILI9341 | GPIO |
|---|---|
| CS | 10 |
| RESET | 8 |
| DC | 9 |
| MOSI / SDI | 11 |
| SCK | 12 |
| MISO / SDO | 13 |
All display pins, the SPI clock and the resolution can be changed in idf.py menuconfig. Check the pin map against your board's schematic before powering up.
Needs ESP-IDF (the project was developed against 6.x) with its environment sourced.
. $IDF_PATH/export.sh
export IDF_CMAKE_GENERATOR=Ninja # optional
idf.py set-target esp32s3
idf.py build
idf.py -p /dev/ttyACM0 flash monitorThe board's native USB port enumerates as /dev/ttyACM*, not ttyUSB*, because input and output go through the USB Serial/JTAG peripheral.
If you change sdkconfig.defaults, delete the generated sdkconfig first, otherwise the old values stay in force:
rm sdkconfig && idf.py reconfigureThe defaults enable octal PSRAM at 80 MHz with CONFIG_SPIRAM_USE_CAPS_ALLOC=y. The last option is needed for heap_caps_malloc(..., MALLOC_CAP_SPIRAM) to work, so don't drop it. The display SPI clock defaults to 20 MHz in sdkconfig.defaults (40 MHz in Kconfig.projbuild); lower it if you see corruption on long jumper wires.
Open a terminal on the board's USB serial port and type. Serial has no key-up events, so movement only continues while your terminal's key auto-repeat is firing.
| Key | Action |
|---|---|
w s |
Forward / back |
a d |
Strafe left / right |
space |
Jump |
f |
Toggle free-fly |
q e |
Up / down (free-fly only) |
| Arrow left / right | Yaw |
| Arrow up / down | Pitch |
b |
Break the block under the crosshair |
p |
Place a block against the face under the crosshair |
main/
app_main.c init, then the per-frame loop: input -> physics -> render -> flush
display.c ILI9341 driver (SPI2, DMA) and the PSRAM framebuffer
input.c USB Serial/JTAG key parsing, GPIO buttons
camera.c view transform, movement, AABB collision
world.c block definitions, Perlin terrain, tree placement, voxel accessors
renderer.c culling, clipping, triangle fill, raycast, break/place
config.h compile-time defaults (falls back if Kconfig doesn't set them)
touch.c XPT2046 driver, currently unused
Kconfig.projbuild menuconfig options (pins, clocks, resolution, touch calibration)
sdkconfig.defaults target, PSRAM, watchdog, pin defaults
spritesheet.bmp/.h programmer-art texture atlas (not yet used)
generation_lut/ old sin/cos LUT generator from the Arduino prototype (archival)
PLAN.md porting notes and remaining work
| Where | Setting | Effect |
|---|---|---|
renderer.c |
RENDER_DIST |
Blocks drawn around the camera. Biggest FPS lever. |
renderer.c |
MAX_DRAW_LIST |
Cap on voxels per frame. |
renderer.h |
FOV |
Focal length in pixels. Higher = narrower view. |
renderer.c |
BLOCK_REACH |
Break/place distance. |
world.h |
WORLD_X/Y/Z, SEA_LEVEL |
World size and water level. |
menuconfig |
SPI_LCD_HZ |
Display bus speed. |
main/touch.c drives an XPT2046 on SPI3 (CS 17, CLK 18, MOSI 16, MISO 15, IRQ 14), with averaging, smoothing, axis swap/invert and per-panel calibration through CAL_* options. It is left over from the original display/touch test and isn't listed in main/CMakeLists.txt, so it isn't compiled. To use it, add touch.c to SRCS and call touch_init() from app_main. Set TOUCH_DEBUG in menuconfig to read raw ADC values for calibration.
The S31 target is still to come. The KiCad symbol, footprint and 3D model for the ESP32-S31 QFN package were contributed upstream in espressif/kicad-libraries#233.