Skip to content

maxpoletaev/gorender

Repository files navigation

gorender

A purely software (no OpenGL or DirectX) realtime 3D renderer, that I built to learn some math and magic behind 3D graphics. It uses raylib for window management and framebuffer access, but all the rendering is done from scratch in Go without relying on third-party libraries.

While the project is fairly simple overall, it includes some nifty optimizations, such as parallel tiled rendering, optimal use of CPU caches, and leveraging SIMD operations on AMD64 via some assembly code. On my laptop (MBP Intel machine), it can deliver about 10 million untextured triangles per second at 1280×720 resolution. This results in frame rate of 95-105 FPS for a single object scene composed of 200k triangles.

demo.mp4

Building

For this, you may need a C compiler and additional dependencies required by raylib. See https://github.com/gen2brain/raylib-go#requirements for details.

make build

For no-assembly version:

make build_noasm

Running

$ ./gorender models/suzanne.obj

Camera uses WASD + mouse to move around (like in most first-person games). ESC key closes the window. There is also a bunch of keys to toggle different rendering options like wireframe, texturing, backface culling, etc.

Features

  • Wireframe rendering
  • Backface culling
  • Affine texture mapping
  • Perspective correct texture mapping
  • Flat shading
  • Gouraud shading
  • Z-buffering
  • View frustum clipping
  • OBJ file support (with MTL files) - only triangulated
  • Parallel tile-based rendering
  • Multi-object scenes

Resources

Assets