Coder Social home page Coder Social logo

skyzh / raytracer.rs Goto Github PK

View Code? Open in Web Editor NEW
99.0 3.0 3.0 274 KB

⚡ A high-performance path tracer implemented in Rust based on "Ray Tracing in One Weekend" featuring static dispatch, multi-threaded rendering and a variety of preset scenes.

License: MIT License

Rust 100.00%
rust raytracer raytracing raytracing-one-weekend computer-graphics

raytracer.rs's Introduction

Raytracer.rs

"Ray Tracing in One Weekend (Amazon)" implemented in Rust 2018

This is the new branch implemented in Rust 2018. For previous version, refer to legacy branch.

UPDATE This project is part of the PPCA 2020 course, where I assisted several students to build their own ray-tracer with the Rust programming language. Here's the showcase.

UPDATE By using static dispatch (generics in Rust) and code generation, we achieved a 2x speedup in rendering most scenes.

Usage

Write your specifications in main.rs:

use self::renderer::utils::render_high_quality as render;
use self::scenes::simple_scene::simple_scene_perlin_noise as scene;

Here you can change render_high_quality to render_preview to render faster. And you can select from examples scenes by changing self::scenes::****::****.

render(hitable_list, camera, "scene.png", true, pdf)?;

The third parameter indicates that with these rendering settings, the image will be rendered to output/scene.png.

The fourth parameter indicates whether to enable ambient light or not.

Finally run:

cargo run --release

Note that since the latest commit, some functionalities may be broken due to new features.

Showcases

Cornell Box

Cornell Box support mixture pdf for reducing noise scenes/cornell_box.rs:cornell_box

Cover Scene

The scene from the cover of "Ray Tracing in One Weekend". It takes ~450 secs to render.

scenes/legacy_scene.rs:legacy_scene

Sphere Sea

Generate 300 spheres (no overlap) in the space with different materials and settings.

It takes ~560 secs to render.

scenes/complex_scene.rs:complex_scene_2

Textures

Light Scene scenes/legacy_scene.rs:legacy_scene_light
Perlin Noise scenes/simple_scene.rs:simple_scene_PERLIN_NOISE
Checker Texture scenes/legacy_scene.rs:legacy_scene_texture

Run Tests and Benchmarks

cargo bench
cargo test

raytracer.rs's People

Contributors

skyzh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

raytracer.rs's Issues

What are the new features?

This looks great and I ran the new version and legacy version of ray tracer, this version of the deployment is significantly faster, so what is the difference between the two?

style

I used your code. That is amazing. But it seems to only produce a dark-looking picture. How do I make it produce a brightly styled picture?

adding more balls

Adding more balls failed. And why does it consume so much CPU resources?

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.