Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement image tracer #3

Merged
merged 17 commits into from
May 4, 2021
Merged

Implement image tracer #3

merged 17 commits into from
May 4, 2021

Conversation

Paolo97Gll
Copy link
Owner

@Paolo97Gll Paolo97Gll commented Apr 28, 2021

Implementation of the image tracer to capture light from a scene.
It is necessary to implement the following:

  • Ray,
    a struct representing a ray from a origin up to a maximum distance. ;
    • (r::Ray)(t::Real),
      we must be able to sample the ray. We opt to implement this by rendering the Ray type callable;
    • approx method ,
      we compare rays only through the starting point and direction;
    • multiplication method * with a Transformation,
      allowing camera manipulation through multiplication;
    • tests for all of the above.
  • the abstract type Camera,
    cameras have a rectangular virtual screen (the properties of which are defined by the aspect ratio), an observer at a given distance, and a transformation to represent orientation and translation;
    • PerspectiveCamera,
      represents a camera capturing rays converging onto the observer at a finite distance from the screen;
    • OrthogonalCamera,
      represents a camera capturing rays coming from a direction normal to the screen (as if the observer was at an infinite distance)
    • a fire_ray method,
      returns a ray passing through a given point on the screen. Must be specialized for each concrete subtype of Camera to represent their different behaviors;
    • an aperture_deg method,
      returns the FOV angle of our camera in degrees;
    • tests for all of the above.
  • ImageTracer,
    an agent struct that fills an HdrImage with the information collected by a Camera;
    • a fire_ray method,
      similar to the Camera method but this takes discrete pixel coordinates from the image instead of the continuous screen coordinates. Additional information must be provided on the exact origin of the ray within the pixel;
    • a fire_all_rays method,
      iterating the fire_ray method on all pixels. The method must also accept a Function argument with instructions on how to calculate what RGB object to store in the image;
    • tests for all of the above.

Paolo97Gll and others added 6 commits April 28, 2021 10:14
Co-authored-by: Samuele-Colombo <Samuele-Colombo@users.noreply.github.com>
Co-authored-by: Samuele-Colombo <Samuele-Colombo@users.noreply.github.com>
src/cameras.jl Outdated
0 <= u <= 1 || throw(ArgumentError("argument `u` must be bound to the range [0, 1]: got $u"))
0 <= v <= 1 || throw(ArgumentError("argument `v` must be bound to the range [0, 1]: got $v"))
origin = Point(-camera.distance, 0, 0)
direction = Vec(camera.distance, (1.0 - 2 * u) * camera.aspect_ratio, 2 * v - 1)
Copy link
Collaborator

@Samuele-Colombo Samuele-Colombo Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUG! This line throws the function into an infinite recursion until stack overflow!
This is a known issue caused by StaticArrays. I opened up #4 about this on the master branch and a pull request to fix it.

@Samuele-Colombo Samuele-Colombo merged commit d0e59b5 into master May 4, 2021
@Paolo97Gll Paolo97Gll deleted the cameras branch May 26, 2021 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants