Skip to content

husseinhafez1/rustraster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rustraster

A software rasterizer written from scratch in Rust, built as a learning project for the language.

No GPU, no unsafe shortcuts — triangles are rasterized on the CPU using barycentric coordinates, with a z-buffer for depth and texture mapping from .obj/.tga model data.

screenshot

Features

  • OBJ model loading (positions, UVs)
  • Look-at camera + perspective projection
  • Triangle rasterization via barycentric coordinates
  • Z-buffering for depth/occlusion
  • TGA texture mapping
  • Backface culling

How it works

Each vertex is transformed from model space through a model-view matrix, a perspective projection matrix, and finally a viewport matrix to reach screen space. Each triangle is then rasterized by computing barycentric coordinates for every pixel in its bounding box; pixels outside the triangle are skipped, and a per-pixel depth test against the z-buffer resolves occlusion. A fragment stage samples the diffuse texture using UVs interpolated from the triangle's vertices.

Loosely inspired by tinyrenderer.

Run

cd renderer
cargo build
cargo run

Not implemented

Lighting, anti-aliasing, shadows, multithreading — single-threaded CPU rasterization only, for now.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages