Giter VIP home page Giter VIP logo

rustracer's People

Contributors

andros21 avatar dependabot[bot] avatar paolo-azzini avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

paolo-azzini

rustracer's Issues

wrong default values for `--init-state` and `--init-seq` cli parameters

rustracer/src/cli.rs

Lines 40 to 47 in 9b028ac

/// Default init seed for random generator.
///
/// When no arguments are provided to `--init-state` flag
const INIT_STATE: &str = "45";
/// Default identifier for random generator sequence.
///
/// When no arguments are provided to `--init-seq` flag
const INIT_SEQ: &str = "45";

deafult values should be 42 and 52, see

rustracer/src/random.rs

Lines 12 to 20 in 9b028ac

impl Default for Pcg {
/// Provides a default constructor for [`Pcg`](struct@Pcg),
/// the default values for the seed are:
/// - `init_state==42`;
/// - `init_seq==54`.
fn default() -> Self {
Self::new(42, 54)
}
}

avoid repetition of `match` inside a nested for loop

for y in (0..height).rev() {
for x in 0..width {
match endianness {
ByteOrder::LittleEndian => buf_reader
.read_f32_into::<byteorder::LittleEndian>(&mut buffer)
.map_err(HdrImageErr::PfmFileReadFailure)?,
ByteOrder::BigEndian => buf_reader
.read_f32_into::<byteorder::BigEndian>(&mut buffer)
.map_err(HdrImageErr::PfmFileReadFailure)?,
}
hdr_img.set_pixel(x, y, (buffer[0], buffer[1], buffer[2]).into())?;
}
}

In this double nested for cycle, it's maybe better to reverse the logic ... not repeat match width*height times, but match before loop and create a nested for each branch of the match. Something like this:

match endianess {
condition1 => {  double for loop }
condition2 => { double for loop }
}

images flipped upside-down

inside demo feature branch is now visible a problem when a scene is rendered ...
shapes placed along y-axis are flipped upside-down, ๐Ÿ‘€ at that:

for how scene is built in demo subcommand insidemain.rs

rustracer/src/main.rs

Lines 104 to 119 in cb35aef

let mut world = World::default();
for x in [-0.5, 0.5].into_iter() {
for y in [-0.5, 0.5].into_iter() {
for z in [-0.5, 0.5].into_iter() {
world.add(Box::new(Sphere::new(
translation(Vector::from((x, y, z))) * scaling(Vector::from((0.1, 0.1, 0.1))),
)));
}
}
}
world.add(Box::new(Sphere::new(
translation(Vector::from((0.0, 0.0, -0.5))) * scaling(Vector::from((0.1, 0.1, 0.1))),
)));
world.add(Box::new(Sphere::new(
translation(Vector::from((0.0, 0.5, 0.0))) * scaling(Vector::from((0.1, 0.1, 0.1))),
)));

the big circle in the upside middle part of the image should stay at the bottom!

Probably there is problem inside already merged imagetracer module

PR is coming

wrong transformation composition in scene parser

description of the problem

command

$ rustracer render -f 0.5 examples/demo.yml demo.png

result


command

$ rustracer render --angle-deg 90 -f 0.5 examples/demo.yml demo.png

result

This is wrong! It's an unexpected behaviour, because z-axis rotation is applied before the translation (see examples/demo.yml)

rustracer/examples/demo.yml

Lines 103 to 105 in 71a9531

- name: camera_tr
compose:
- translation: [-2, 0, 0.5]

instead the logic should be reversed, before translation and then rotation added via cli, the problem is transformation product order:

rustracer/src/scene.rs

Lines 1190 to 1195 in 71a9531

let transformation = var.transformations.get(&transformation_id).copied().ok_or(
SceneErr::UndefinedIdentifier {
loc,
msg: format!("{:?} transformation not defined", transformation_id),
},
)? * rotation_z(f32::to_radians(cli.angle_deg));

and it's not the only occurrences of that type cause also when composing multiple transformation, the product must be reversed:

transformation = transformation * self.parse_transformation(transformations, var)?;

rustracer/src/scene.rs

Lines 992 to 993 in 71a9531

transformation =
transformation * self.parse_transformation(transformations, var)?;

so that the expected output of precedent command will be:

expected

arguments exchanged in `PerspectiveCamera::new`

in the method new of PerspectiveCamera the argument aspect_ratio and distance
are exchanged respect how are used inside test

rustracer/src/camera.rs

Lines 103 to 114 in 66115ce

pub fn new(
aspect_ratio: f32,
distance: f32,
transformation: Transformation,
) -> PerspectiveCamera {
PerspectiveCamera {
aspect_ratio,
distance,
transformation,
}
}
}

this kind of errors are not caught in unit tests cause objects are created directly (using the power of super::*) ...
this teach us to always use new method also inside unit test or at least alternate with the direct creation
(unrelated this workflow probably will improve also unit test coverage)

PR is coming

todo list

todo ๐Ÿ“˜

  • @Paolo-Azzini | try to improve unit test coverage removing useless traits from#derive macro of each class
  • @Paolo-Azzini | try to improve unit test coverage using new instead direct object initialization
  • @Paolo-Azzini | uniform return type for traits and methods, when Self is correct to be used?
  • @andros21 | but if UnableToNormalize is used only inside tests, we can delete it
  • @Paolo-Azzini | a simple test for onoffrender.solve is possible? And for ray_intersaction in world?
  • @Paolo-Azzini | A impl ::from tuple for Vector2D in misc.rs could be useful to lighten syntax, no?
    And little unit test for Vector2D::isclose
    >> Actually i think Vector2D::from((f32, f32)) is heavier syntax than Vector2D{u: f32, v: f32,}
  • @Paolo-Azzini | flat renderer + antialising
  • @Paolo-Azzini | improve in cli (complete+manpage) using clap related projects
  • @andros21 | add rustfmt.toml (alacritty for some ideas ๐Ÿ’ก)
    >> ๐Ÿ˜ข ly the major cool things aren't in stable rustfmt ... we'll see
  • @andros21 | try to remove duplication in main function in inside main.rs
  • @andros21 | check support file format ldr image before convert or render the image!
  • @andros21 | best rust workflow to emulate python setup/tear_down in unit tests, useful e.g. imagetracer.rs
    >> ๐Ÿ‘€ at it ... it's nightmare, no advantages in my opinion
  • @andros21 | fire up CD pipeline, ci-cd branch already open, cd.yml missing
  • @andros21 | profiling flamegraph heap_allocator? dev dependencies?
    >> too much work and study for a dummy dev, performance and benchmark are projects alone
  • @andros21 | reformat error.rs so that source error are printed at new line
  • @andros21 | when macro #[no_coverage] will be stable, bypass coverage test for main.rs, cli.rs, etc ...
  • @andros21 | after the bottleneck is found try to improve performance using multi-threading (rayon)

other improvements're welcome!

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.