1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// SPDX-License-Identifier: CC-BY-SA-4.0
// Copyright © Paweł Redman
#import "/common.typ": post, static, img, link-self
#show: post.with(
title: "ray",
date: datetime(year: 2020, month: 8, day: 15),
)
#figure(
img(static("software/rrt_1.jpg")),
caption: [A render of the bundled scene (gamma corrected).],
)
Ray is a multi-threaded, real-time #link("https://en.wikipedia.org/wiki/Path_tracing")[path tracer], written in C. Paths are traced through an octree, which can be edited at run-time, giving it sort of an "early Minecraft prototype" feel. Being my first "serious" program, it's rather primitive and can't work with complicated geometry or surface models.
= Background
#figure(
img(static("software/rrt_2.jpg")),
caption: [A render of a default random octree (gamma corrected).],
)
I wrote the program as a part of my presentation titled "A physically accurate computer light model" for the finale of the 10th edition of the "Open Interschool Physics Contest" in 2013. I didn't win as there was way too much programming and too little physics involved. I wasn't great at presenting back then either. Nevertheless this was the first step toward choosing Optics as my field of study. And I did much better two years later with #link-self("software/cem")[cem].
= Compiling and running
The source code is available here at #link("https://redman.xyz/git/ray")[ray]. Because this is a very old program, written back when I wasn't too experienced, compiling and running it can be a bit of a challenge. You'll probably have to figure it out yourself.
At start the program loads a world from "world" in the working directory. If it's not present, it'll generate a fractal-looking random octree. The repository includes a weird Pripyat-looking scene. Sometimes camera physics bug out, removing the world fixes the issue.
The controls are listed below.
- Use the mouse to look around, WASD to move around, space to fly up, C to fly down.
- *F1 releases/locks the cursor.*
- The mouse wheel adjusts the focal length (zoom level).
- Left and right mouse buttons destroy and place blocks, respectively.
- Keys Z, X, R, T, Y and U select the block type to place. In order: concrete, dirt, metal, mirror, light and banner.
- Keys 1 through 7 change the render quality (7 being the best).
- Press Q to launch a bouncy light source, F to toggle the flashlight.
- F11 renders to "offline.bmp" at a much higher resolution.
|