You can:
- read/export wavefront files (files used for 3d objects with .obj extension)
- do basic transformations on objects such as rotation, scale and translation
- render object with simple local renderer
- Clone the repository in desired directory
git clone https://github.com/ttcpavle/Raytracer-in-c.git
- Navigate to build directory
- Run
cmake ..
After those steps:
- If you are using windows, open the
Raytracer.sln
solution (if visual studio was selected compiler). Select the Raytracer as startup project and run. Header files should appear in solution explorer under Header files. - If you are using linux, run generated files for building a project. If cmake generated makefile, run
make
and than run the executable./Raytracer
Required software:
Cmake installation: https://www.youtube.com/watch?v=8_X5Iq9niDE
Git installation: https://www.youtube.com/watch?v=JgOs70Y7jew
Everything is controlled in main()
function, there is no console or windows interface, this is only a simple rendering software. You can see in the example how things are set up:
- Adjust settings in config.h accoring to your preferences
- Read object, set material, transform it and export it if you want
- Set up objects array and lights array (currently rendering supports a single object and light)
- Set up camera (point look_at which is where camera is looking, eye which is camera location, fov and aspect ratio ideally set to
(float)WIDTH/HEIGHT
- Render the scene (Color* is image which is array or flat memory matrix of colors)
- Export image with
stbi_image_write()
which is available in stb_image_write.h library from Sean Barrett
- Info about functions is available in .h or .c files
- More render examples in Raytracer/renders/
- REMEMBER TO EDIT CONFIG.H
- Faces are triangulated while reading wavefront (fan triangulation)
- Exported object will maintain triangulated faces
- Moller Trumbore algorighm is used for ray triangle intersection
- Gauss-Jordan algorithm is used for inverse matrix
- You can follow render progress on console
- Smooth shaded object (Gouraud shading)
- Project is tested on windows (visual studio) and linux fedora
- preserving group information in .obj files
- reading .mtl files
- rendering multiple objects/lights and shadows
- preserving n-gon faces
- using isGlass property
- undo transforms
- Render multiple objects/lights
- Better shading with isGlass information (reflection and refraction)
- Rendering equation (Monte Carlo integration)
- Origin of object fixes
- OpenGL or windows.h for GUI