Git Product home page Git Product logo

raytracingweekend's Introduction

Ray Tracing in (More Than) One Weekend

A attempt at the Ray Tracing in One Weekend book, in C.

Usage

$ make
$ ./main > cover.ppm

The resulting image is the cover image of the book: 1200x675px, 500 samples/pixel.

Spheres of different size, color and material

The original, single-threaded implementation ran in 18m 41s with optimization flags enabled. Further optimizations reduced the time to 3m 31s, a 5.3x speedup. Here's a summary of optimizations with a smaller test image (./main -small) - 400x225px, 100 samples/pixel.

Optimization real user sys cpu%
Optimization flags (-O2, -flto) 24.568 24.52 0.01 99
Multi-threaded pixel rendering (4 threads) 13.817 33.93 8.31 305
Multi-threaded scanline rendering 9.459 36.43 0.02 385
Multi-threaded scanlines rendering 9.261 36.68 0.01 396
Changing function pointer to enums + union 7.855 31.10 0.01 396
Use custom inline random instead of stdlib rand() 7.690 30.40 0.01 395
Change raycolor() to be iterative instead of recursive 7.519 29.72 0.01 395
Use ARM Neon SIMD instructions in vector functions 7.066 27.91 0.01 395
Use SIMD instructions to calculate 4 spheres at once 6.085 24.01 0.01 394
Improved data loading for "4 spheres at once" 5.847 23.09 0.01 395
Vectorized discrimiant check in spherelisthit() 4.902 19.32 0.01 394
Small improvements in spherelisthit() 4.743 18.70 0.01 394

Resources

raytracingweekend's People

Contributors

pjg11 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.