A basic 3D renderer made in Python, using the library Pillow.
These instructions will guide you through the installation and usage of Rendeer.
This project was made using Python 3.6. You need to go to the official Python website and install Python 3.6 or a newer version. You also need the Pillow and the tqdm library, which you can install with the command:
pip install pillow tqdm
You should be able to run the program by simply opening rendeer.py
.
It will probably take up to a minute for the mesh to be rendered.
If you want to import a mesh from an .obj file, you now can! Simply open wavefront_importer.py
and specify the path to the .obj file.
Note: Please triangulate your mesh before importing it unless you want it to look like this
If, for example, you want to import a mesh called tree.obj
which is in the same folder as wavefront_importer.py
, you would need to type
tree.obj
If it's in a folder called "Trees" that's in the same folder as wavefront_importer.py
, you would need to type
Trees\tree.obj
Note: The four files (rendeer.py
, meshes.py
, settings.py
, intersection.py
and wavefront_importer.py
) have to be all in the same directory for everything to work properly.
The data from the .obj file will be saved in a file called meshes.py
. You can now run the renderer and it will display your mesh in an image. You might have to move/rotate your mesh in order to display it as you like.
- Special thanks to tweakimp for doing a lot of optimization and making the rendering time significantly shorter.
- ALAN (Animation Language) has been added: you can now create animations with ease! (no pun intended)
Biggest update yet! Here are some key features:
- You can now set the resolution so you can go Ultra HD (default resolution is 100)
- calculating hard vertex normals is now up to 1000 times faster
- Gouraud shading! Now your meshes are as smooth as they can get
- many parts of the code have been rewritten, others are just gone
- shading modes! choose between
flat diffuse
,unlit
andwireframe
! - progress bars! stop staring into the void for a minute straight, now you can watch the program doing things
- variables that the user should modify are in a separate file now (
settings.py
) - fixed problem with the mesh being too bright where light doesn't touch it
- now it has a Wavefront importer for your 3D models
- it sorts faces by distance so it can now render them in the (almost) correct order.
- it can now calculate hard vertex normals
- I've fixed some of the 0x0BADC0DE.