ekzhang / rpt Goto Github PK
View Code? Open in Web Editor NEWA physically-based path tracer
License: Apache License 2.0
A physically-based path tracer
License: Apache License 2.0
Hello there.
I'm quite new to Rust but I wanted to use this lib to generate thumbnails for STLs in a neat way.
I have pretty much copy pasted the cylinder example and tried feeding it the paths to the STL, however this causes it to 'hang' and consume a lot of CPU, it also never finishes. Code snippet below.
I'm just wondering if this is the natural state of this library, seeing it is 'cpu' only.
pub fn gen_thumb(path: PathBuf) -> color_eyre::Result<()> {
use std::fs::File;
color_eyre::install()?;
let mut extension = path.clone();
extension.set_extension("png");
let mut scene = Scene::new();
scene.add(
Object::new(load_stl(File::open(path)?)?)
.material(Material::specular(hex_color(0xB7CA79), 0.1))
);
scene.add(
Object::new(plane(glm::vec3(0.0, 1.0, 0.0), -1.0))
.material(Material::diffuse(hex_color(0xAAAAAA))),
);
scene.add(Light::Ambient(glm::vec3(0.01, 0.01, 0.01)));
scene.add(Light::Object(
Object::new(
sphere()
.scale(&glm::vec3(2.0, 2.0, 2.0))
.translate(&glm::vec3(0.0, 20.0, 3.0)),
)
.material(Material::light(glm::vec3(1.0, 1.0, 1.0), 160.0)),
));
scene.add(Light::Object(
Object::new(
sphere()
.scale(&glm::vec3(0.05, 0.05, 0.05))
.translate(&glm::vec3(-1.0, 0.71, 0.0)),
)
.material(Material::light(hex_color(0xFFAAAA), 400.0)),
));
let camera = Camera::look_at(
glm::vec3(-2.5, 4.0, 6.5),
glm::vec3(0.0, 0.0, 0.0),
glm::vec3(0.0, 1.0, 0.0),
std::f64::consts::FRAC_PI_6,
);
Renderer::new(&scene, camera)
.max_bounces(2)
.num_samples(1)
.render()
.save(extension.as_path())?;
Ok(())
}
Awesome crate!! I'd love to make a little demo in a web app, but some of the deps don't compile for WASM.
Is this something you are interested in? I'd be happy to make a PR adding support if so.
Dear Eric,
thanks for making rpt
! I am currently using the crate for scientific visualization and I wanted to ask about support for vertex colors.
I.e., I would like to be able to pass a vector of color values, one per vertex, instead of a material when rendering a mesh. Here is an example image that visualizes cortical thickness of the human brain.
What do you think?
Hi! I noticed that the renderer currently terminates tracing the ray based on a max_bounce parameter. This, as far as I am aware, isn't unbiased. Instead, one would generally probabilistically decide to continue or terminate, adjusting the monte carlo estimator accordingly (also called russian roulette). However, I am not sure if there's something else that's accounting for this which still makes this approach unbiased.
Would love to know, and am happy to make a PR changing this!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.