Skip to content

An exercise on the inner workins of 3d graphical engines, with support for orthographic and perspective projections

Notifications You must be signed in to change notification settings

oPisiti/Py3dRender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D renderer based on python

3d-renderer

Description

This is an exercise on the inner workings of 3d engines.

All the transformations (3D to NDC to screen space) are built from scratch. Also, triangles rasterization with z depth buffer and shading were built from the ground up.

Dependencies

Pygame is only used to create a window and render the individual pixels.

Numpy is used for matrix transformations.

Numba provides a great boost on performance by compiling the most inefficient functions, due to python loops. It requires scipy for functions which rely heavily on linear algebra.

Numpy-stl is used to importthe stl files to a Mesh object.

Setup

Clone the repo and cd into it.

Optional

Create a venv: python -m venv venv

Tap into it: source venv/bin/activate

Required

Install dependencies via pip:

pip install -r requirements.txt

Usage

Just run python3 src/main.py

If you are NOT using a venv, you may also call the script directly, with ./src/main.py.

Beware it may take a few seconds to start, as some functions are being compiled with numba.

About

An exercise on the inner workins of 3d graphical engines, with support for orthographic and perspective projections

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages