• Stars
    star
    1,058
  • Rank 43,617 (Top 0.9 %)
  • Language
    C++
  • License
    The Unlicense
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Toy path tracer for my own learning purposes (CPU/GPU, C++/C#, Win/Mac/Wasm, DX11/Metal, also Unity)

Toy Path Tracer Build Status

Toy path tracer I did in 2018 for my own learning purposes. Somewhat based on Peter Shirley's Ray Tracing in One Weekend minibook (highly recommended!), and on Kevin Beason's smallpt.

Screenshot

I decided to write blog posts about things I discover as I do this:

Note: it can only do spheres, no bounding volume hierachy of any sorts, a lot of stuff hardcoded.

Performance numbers in Mray/s on a scene with ~50 spheres and two light sources, running on the CPU:

Language Approach Ryzen 5950 AMD TR1950 MBP 2021 MBP 2018 MBA 2020 iPhone 11 iPhone X iPhone SE
C++ SIMD Intrinsics 281.0 187.0 105.4 74.0 32.3 26.4 12.9 8.5
Scalar 141.2 100.0 84.8 35.7 15.9
WebAssembly (no threads, no SIMD) 8.4 5.0 8.1 5.6
C# Unity Burst "manual" SIMD 227.2 133.0 103.7 60.0 29.7
Unity Burst 82.0 36.0
Unity (Editor) 6.5 3.4
Unity (player Mono) 6.7 3.5
Unity (player IL2CPP) 39.1 63.8 17.2
.NET 6.0 91.5 53.0 40.9
.NET Core 2.0 86.1 53.0 23.6
Mono --llvm 35.1 22.0
Mono 23.6 3.6 6.1

More detailed specs of the machines above are:

  • Ryzen 5950: AMD Ryzen 5950X (3.4GHz, 16c/32t), Visual Studio 2022.
  • AMD TR1950: AMD ThreadRipper 1950X (3.4GHz, SMT disabled - 16c/16t), Visual Studio 2017.
  • MBP 2021: Apple MacBook Pro M1 Max (8+2 cores), Xcode 13.2.
  • MBP 2018: Apple MacBook Pro mid-2018 (Core i9 2.9GHz, 6c/12t).
  • MBA 2020: Apple MacBook Air 2020 (Core i7 1.2GHz, 4c/8t).
  • iPhone 11: A13 chip.
  • iPhone X: A11 chip.
  • iPhone SE: A9 chip.

Software versions:

  • Unity 2021.3.16. Burst 1.6.6 (safety checks off). C# testing in editor, Release mode.
  • Mono 6.12.

And on the GPU, via a compute shader in D3D11 or Metal depending on the platform:

GPU Perf
D3D11
GeForce RTX 3080Ti 3920
GeForce GTX 1080Ti 1854
Metal
MBP 2021 (M1 Max) 1065
MBP 2018 (Radeon Pro 560X) 246
MBA 2020 (Iris Plus) 201
iPhone 11 Pro (A13) 80
iPhone X (A11) 46
iPhone SE (A9) 20

A lot of stuff in the implementation is totally suboptimal or using the tech in a "wrong" way. I know it's just a simple toy, ok :)

Building

  • C++ projects:
    • Windows (Visual Studio 2017) in Cpp/Windows/ToyPathTracer.sln. DX11 Win32 app that displays result as a fullscreen CPU-updated or GPU-rendered texture. Pressing G toggles between GPU and CPU tracing, A toggles animation, P toggles progressive accumulation.
    • Mac/iOS (Xcode 10) in Cpp/Apple/ToyPathTracer.xcodeproj. Metal app that displays result as a fullscreen CPU-updated or GPU-rendered texture. Pressing G toggles between GPU and CPU tracing, A toggles animation, P toggles progressive accumulation. Should work on both Mac (Test Mac target) and iOS (Test iOS target).
    • WebAssembly in Cpp/Emscripten/build.sh. CPU, single threaded, no SIMD.
  • C# project in Cs/TestCs.sln. A command line app that renders some frames and dumps out final TGA screenshot at the end.
  • Unity project in Unity. I used Unity 2021.3.16.

More Repositories

1

UnityGaussianSplatting

Toy Gaussian Splatting visualization in Unity
C#
2,025
star
2

glsl-optimizer

GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.
C++
1,729
star
3

ClangBuildAnalyzer

Clang build analysis tool using -ftime-trace
C++
979
star
4

hlsl2glslfork

HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.
C++
558
star
5

dod-playground

Sample OOP/ECS/DOD project (C++) for an internal Unity lecture in 2018
C++
366
star
6

smol-v

SMOL-V: like Vulkan/Khronos SPIR-V, but smaller.
C++
296
star
7

sizer

Win32/64 executable size reporting
C++
252
star
8

ToyMeshPathTracer

Toy Mesh Path Tracer that I used as a base for job interview tasks
C++
119
star
9

UnityGPUTexCompression

How to do DXT/BCn texture compression in Unity using compute shaders
C#
66
star
10

gamedev-emojis

128x128 sized icons of various game development things
Python
60
star
11

miniexr

Small code to write OpenEXR images
C++
58
star
12

demo-pd-cranktheworld

A real-time rendering demo for Playdate console
C
56
star
13

smol-atlas

2D rectangular bin packing with option for item removal
C++
53
star
14

UnityStbEasyFont

C#
47
star
15

HashFunctionsTest

Little test of various hash functions
C++
46
star
16

header_hero

Fork of Bitsquid's Header Hero tool
C#
41
star
17

BlackHoleDemo

C#
27
star
18

smol-compute

A tiny library for launching compute shaders on D3D11, Metal and Vulkan
C
26
star
19

markdeep-docs-style

Documentation CSS style for Markdeep
CSS
25
star
20

dingus

engine used in some nesnausk! demos
C++
23
star
21

glsl-load-speed

Quick test of GLSL shader loading speed
C++
17
star
22

obj_parse_tester

Comparing various C++ OBJ parsing libraries
C
17
star
23

bcn_decoder_tester

Testing various BCn texture format decoding libraries
C++
16
star
24

jobtask2019-trimesh-tracer

A programming task for job interviews I did in 2019 Q2
C++
16
star
25

bc7e-on-gpu

An attempt to port BC7E texture compressor to a GPU compute shader
HLSL
15
star
26

float_compr_tester

Testing various libraries/approaches for compressing floating point data
HTML
14
star
27

aras-p.hugo

This is just my website, content & Hugo bits
HTML
9
star
28

oklab_gradient_test

C++
6
star
29

sprint-fuuu

C++
6
star
30

sideshooter50

A game in 50 lines of code
4
star
31

twod_coverage_raster

Super simplistic 2D triangle coverage rasterizer
C
4
star
32

SoftRenderBlogProject

C
3
star
33

trianglomator

C#
3
star
34

dod-lecture-2018

C#
3
star
35

ggj19-rumba

A small game during Global Game Jam 2019
C#
3
star
36

filteression

C++
2
star
37

hgext

misc hg extension stuff
Python
1
star
38

website

PHP
1
star
39

image-formats-testbed-hack

C++
1
star