All projects

A Case study

HexaCraft

A voxel sandbox written from scratch in C++17 and OpenGL 3.3, in which every block is a hexagonal prism instead of a cube.

Overhead view of HexaCraft terrain. Hexagonal tiles form a pond, contoured sand and a castle wall.

Why hexagons

Every block is a hexagonal prism on an offset grid. Each block has six neighbours instead of four, so terrain steps and biome edges curve instead of forming staircases, and water pools into hexagonal outlines. At eye level it reads as ordinary voxel terrain. The tiling shows from above or along a cliff edge.

A grass and sand biome boundary, with ground scatter and drifting clouds behind it

World

  • A 200 × 200 × 32 grid generated at startup from layered value noise.
  • Five biomes (sand, grass, stone, water and snow) with blended edges, plus prebuilt structures such as a castle, a village and a pyramid.
  • Trees are grown by a recursive fractal routine, then baked into one vertex buffer per variant, so a forest costs one draw call per variant instead of a fractal walk every frame.

The castle gatehouse, with twin towers flanking a crenellated wall

Rendering

  • Phong (per-fragment) and Gouraud (per-vertex) shading, switchable at runtime.
  • A directional sun and moon, point lights and a spot light, each toggled independently, as are the ambient, diffuse and specular terms.
  • Nearest-N light selection, so torches and fireplaces light their surroundings without exceeding the shader’s uniform budget.
  • Frustum and occlusion culling, 4× MSAA, a seamless skybox, distance fog, and a deferred pass for transparent water.

A terraced ridge lit per fragment with Phong shading

The same ridge lit per vertex with Gouraud shading, visibly flatter

A night scene in which a torch and a fireplace light the snow around them

Gameplay

  • Walk, sprint, jump and fly, with health, stamina and hunger.
  • Break and place blocks, and sculpt terrain.
  • A 36-slot inventory with a 3 × 3 crafting grid and a searchable recipe book.
  • Chickens, pigs, sheep, zombies and skeletons, each with idle, wander, chase, attack and flee states.
  • A drivable car with suspension that follows the terrain.

Stack

C++17, OpenGL 3.3 core profile, hand-written GLSL, GLFW, GLAD, GLM and stb_image.