Skip to content

Kaldrass/ray-tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ray-Tracer (C++)

Projet C++ minimal mais complet contenant :

  • un ray tracer (ombrage direct avec ombres dures)
  • un path tracer (Monte Carlo avec rebonds)
  • primitives sphere + triangle
  • BVH pour accelerer les intersections
  • multithreading CPU sur les lignes d'image
  • backend GPU OpenCL (modes ray et path, optionnel selon machine)
  • antialiasing via --samples sur ray et path
  • sortie PPM et PNG

Prerequis

  • CMake >= 3.20
  • Compilateur C++17 (MSVC, clang, gcc)
  • Runtime OpenCL installe (pilote GPU) pour activer --backend gpu

Build (Windows PowerShell)

cmake -S . -B build
cmake --build build --config Release

Utilisation

Ray tracing direct :

.\build\Release\ray_tracer.exe --mode ray --width 1280 --height 720 --samples 8 --threads 12 --backend auto --output ray.png

Path tracing :

.\build\Release\ray_tracer.exe --mode path --width 1280 --height 720 --samples 128 --depth 16 --threads 12 --output path.png

Path tracing GPU force :

.\build\Release\ray_tracer.exe --mode path --width 1280 --height 720 --samples 64 --depth 8 --backend gpu --output path_gpu.png

Ray tracing GPU force :

.\build\Release\ray_tracer.exe --mode ray --backend gpu --output ray_gpu.png

Image de sortie au format PPM ou PNG (PNG actif sur Windows).

Options principales :

  • --threads <int> : nombre de threads CPU
  • --backend <auto|cpu|gpu> : selection backend
  • --samples <int> : antialiasing / samples per pixel (ray + path)
  • --output <fichier.ppm|fichier.png>

Structure

  • include/rt/ : coeur math/geo/camera/materials
  • src/ray_tracer.cpp : rendu ray tracer
  • src/path_tracer.cpp : rendu path tracer
  • src/gpu_ray_tracer_opencl.cpp : rendu GPU OpenCL (ray + path)
  • src/scene.cpp : scene de demo
  • src/main.cpp : CLI

Notes

  • Le backend GPU est optimise avec contexte OpenCL persistant et generation des rayons cote kernel.
  • Le mode path est multithread CPU et plus couteux en temps de rendu.
  • Le BVH est applique avant rendu pour reduire le cout des tests d'intersection.
  • La scene de demo contient maintenant des triangles en plus des spheres.

Benchmark

Script de benchmark:

powershell -ExecutionPolicy Bypass -File .\scripts\benchmark.ps1 -Threads 12

Options utiles du script:

  • -Runs 5 (ou plus) pour moyenne + ecart-type
  • -OutDir .\bench_outputs

Sorties:

  • Images dans bench_outputs/
  • CSV dans bench_outputs/benchmark_results.csv avec avg_ms, std_ms, min_ms, max_ms, speedup_vs_cpu

Remarque importante:

  • Sur cette scene de demo, le backend GPU peut etre plus lent que le CPU a cause des transferts host/device et d'un kernel encore simple.

About

This is a personnal project to develop a ray-tracer and a path-tracer, optimized to run on GPU.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors