ssloy/tinyraytracer 封面
好玩项目
3d3d-graphicsc-plus-plus

ssloy/tinyraytracer

A brief computer graphics / rendering course

5391语言:C++来源:GitHub收录于 2026年10月27日

站内导读

中文 这是计算机图形学课程的配套代码,用256行纯C++实现光线追踪,不依赖第三方库,便于看清渲染流程的每一步。它不追求物理真实或成品级渲染,而是以简洁结构讲解原理,并配有wiki逐章说明。适合想从零理解光线追踪的学生和自学者,也可作为教学示例。

README · 详细文档

来源 · 查看原文

Understandable RayTracing in 256 lines of bare C++

This repository is a support code for my computer graphics lectures. It is not meant to be the ultimate rendering code or even physically realistic. It is meant to be simple. This project is distributed under the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE.

Check the wiki that accompanies the source code. The second raytracing chapter is available in the tinykaboom repository. If you are looking for a software rasterizer, check the other part of the lectures.

In my lectures I tend to avoid third party libraries as long as it is reasonable, because it forces to understand what is happening under the hood. So, the raytracing 256 lines of plain C++ give us this result:

compilation

git clone https://github.com/ssloy/tinyraytracer.git
cd tinyraytracer
mkdir build
cd build
cmake ..
make

You can open the project in Gitpod, a free online dev evironment for GitHub:

0

On open, the editor will compile & run the program as well as open the resulting image in the editor's preview. Just change the code in the editor and rerun the script (use the terminal's history) to see updated images.

同类项目 · 好玩项目