Skip to content

快速开始

本指南将帮助你在 5 分钟内运行第一个渲染。

环境要求

组件版本要求
CUDA Toolkit11.0+
C++ 编译器C++17 支持
CMake3.18+
GPUCompute Capability 7.5+ (Turing+)

安装步骤

1. 克隆仓库

bash
git clone https://github.com/AICL-Lab/ray-tracer.git
cd ray-tracer

2. 构建项目

bash
# 配置构建
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

# 编译
cmake --build build -j$(nproc)

3. 运行渲染

bash
# Blinn-Phong 着色模式(快速预览)
./build/bin/ray_tracer -o output.ppm

# 路径追踪模式(高质量渲染)
./build/bin/ray_tracer --scene cornell -p -s 128 -o cornell.ppm

查看结果

渲染输出为 PPM 格式,可使用以下方式查看:

bash
# 使用 ImageMagick 转换
convert output.ppm output.png

# 或使用 Python
python -c "from PIL import Image; Image.open('output.ppm').save('output.png')"

下一步

常见问题

CUDA 版本不匹配

确保系统安装的 CUDA Toolkit 版本与 GPU 驱动兼容:

bash
nvcc --version
nvidia-smi

找不到 CUDA

确保 CUDA_PATH 环境变量已设置:

bash
export CUDA_PATH=/usr/local/cuda
export PATH=$CUDA_PATH/bin:$PATH

内存不足

降低渲染分辨率或采样数:

bash
./build/bin/ray_tracer -w 640 -h 480 -s 32 -o output.ppm

Technical Whitepaper · Built with VitePress