Git Product home page Git Product logo

rpt's Issues

Heavy CPU use causing hanging

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(())
}

WASM Support

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.

Max bounce termination

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!

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.