GithubHelp home page GithubHelp logo

liotta's Introduction

Liotta

A simple path tracer for MacOS written in Swift, based on the book "Ray Tracing in One Weekend" by Peter Shirley.

Example scene from Chapter 12 of the book, after 25 minutes on my 2020 M1 MacBook Pro.

Notes:

Except for some small differences the code is is mostly a direct port of the C++ code in the book:

  • SIMD instructions are used for some vector operations, e.g. simd_dot, simd_cross, simd_normalize, simd_reflect, simd_refract.
  • The renderer in the book renders a single image at once. This renderer produces the image in multiple passes, outputting the result from each pass so that the progress can be observed.
  • This renderer runs multiple raytracers concurrently in separate threads, and averages the output images produce the final image. Averaging two separate images with M + N samples is equivalent to averaging M + N samples from a single renderer - this property allows rendering to be parallelized relatively easily. Multi-threaded performance scales linearly according to the number of CPU cores. On my 2020 M1 MacBook Pro, the renderer casts ~280k rays per second per CPU core with the sample scene from chapter 12. Using two CPU cores is twice as fast at about 560k rays per second, and so on as more cores are used. When three or more cores are used, the MacBook starts to heat up within a few seconds, as evidenced by the audible increase in the fan speed. Two cores seems to be the practical sustainable limit, exhibiting only mild increases in fan whooshing. For now, multi-threading is implemented with Thread and os_unfair_lock. Initial experiements with using actor and Task for concurrency were hampered by thread locking issues - I intend to revisit this at some point in the future.
  • The book uses drand48() to produce random numbers. This app only uses this random number generator for creating scenes. Rendering noise is generated using a variant of Gold Noise, for extra raw performance and to avoid locking with multi-threading.

liotta's People

Contributors

lukevanin avatar

Watchers

 avatar James Cloos 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.