Skip to content

littlecube8152/icg-term-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

144 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Special Relativistic Ray Tracer

This is the term project for NTU Computer Graphics (Spring 2025) by PixelCat31415 and me. We implemented a ray tracing engine supporting special relativistic effects in C++ with OpenGL.

Demo Video Demo

License

This repository is licensed under the MIT License, except for:

  • The model files under /model/ directory are not covered by the license; they are a part of the course materials. If you would like to use the models, please contact the instructor of the course for permission.

Prerequisites

  • C++ compiler supporting C++20 standard.
    Notably, many compilers does not support full C++20 features even if they do have the option.
    It is recommended to use GCC (the GNU Compiler Collection) version 13 or above.
  • Python 3 and xxd.
    They are required for preprocessing the shader files.
  • OpenGL 4.5 (or above), GLM, GLFW 3, and FFmpeg Libraries.
    For Debian-based distributions, the dependencies can be installed by
    apt install libopengl-dev libglfw3-dev libglm-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev

As a side note, we have tested the program on NTU CSIE workstation meow1. Since it is a server designed for computation, please refer to the Windowless Mode subsection for running the program without opening a window.

Running the Program

Run the Makefile via make. The compiled binary will be produced at build/bin/main. The available options can be obtained via the --help command. For windowed mode (the default without -n or --no-window option), the escape key can be used to close the program.

Output

By default, the program saves the first frame as screen.png and the whole simulation as video.mkv under the directory output. The FPS, quality, and resolution can be adjusted with command-line arguments.

When the program is closed or killed during the simulation, the video might not contain all frames it has rendered. When the console prints "Done!", it is safe to close the program.

Windowless Mode

For machines without window server, there is a -n (shorthand --no-window) option for only computing the output. However, since GLFW requires an active window server to allocate related contexts including OpenGL context, a virtual frame buffer is required. We recommend using XVFB as the virtual frame buffer. An example of it would be:

xvfb-run ./build/bin/main -n

Common Issues

GLFW Error Code 65550 (Failed to Detect Any Supported Platform)

It is most likely that the machine has no window server supported by GLFW. Please refer to Windowless Mode about how to run the program without an active window.

The Program is not Using Nvidia Graphics Cards!

If you have Nvidia graphics card but OpenGL is not using it, set these environment variables before running the program:

export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia

You can use glxinfo -B to find out which graphics card the OpenGL is using.

Credits

Thanks to Ray Traching in One Weekend for providing a brilliant tutorial — our ray tracing engine took it as a starting point. We also thank our professor, Ming Ouhyang, for permitting us to use the 3D models in the course resources.

About

Special Relativistic Ray Tracer in OpenGL and C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages