A real-time interactive Monte Carlo path tracer created as a vibe coding experiment generated with "Optimus Alpha" on openrouter, with additional assistance from Sonnet-3.7.
This project implements a Monte Carlo path tracer using OpenGL shaders to achieve real-time performance. Path tracing is a rendering technique that simulates realistic lighting by tracing the path of light rays as they bounce through a scene.
The renderer handles:
- Multiple material types with varying reflectivity and refraction
- Soft shadows
- Fresnel effects for realistic glass
- Procedural textures and bump mapping
- Tone mapping for improved visual quality
- WASD: Move camera position
- Mouse: Look around
- Z/X: Decrease/Increase aperture (depth of field effect)
- C/V: Decrease/Increase focal distance
- R: Reset camera to default position
- F10: Take high-quality screenshot
- ESC: Exit application
- Install the required dependencies:
pip install -r requirements.txt
- Run the main script:
python main.py
- Python 3.6 or higher
- Dependencies (listed in requirements.txt):
- PyOpenGL
- PyOpenGL_accelerate
- glfw
- numpy
- PIL (Pillow)
- Clone the repository:
git clone https://github.com/yourusername/mcpt_shade.git
cd mcpt_shade
- Create a virtual environment (optional but recommended):
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
- Install the dependencies:
pip install -r requirements.txt
- Run the application:
python main.py
The path tracer uses a fragment shader to perform all ray tracing calculations on the GPU. Each frame:
- A full-screen quad is rendered
- For each pixel, multiple sample rays are cast
- Each ray is traced through the scene with multiple light bounces
- Results are accumulated and tone-mapped for display
The implementation uses adaptive sampling to maintain interactive frame rates - when the camera is moving, fewer samples are used per pixel, and when stationary, the sample count gradually increases for better quality.
Take high-quality screenshots at any time by pressing F10. Screenshots are saved to the screenshots folder with a timestamp and sample count in the filename.
This project is open source and available for educational and personal use.
This project was generated as a vibe coding experiment with "Optimus Alpha" on openrouter, with some help from Sonnet-3.7. This readme was written mostly by Sonnet-3.7.
