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

Explore the Cyrille Rossant Python Ray Tracer #128

Closed
acs opened this issue Aug 2, 2020 · 4 comments
Closed

Explore the Cyrille Rossant Python Ray Tracer #128

acs opened this issue Aug 2, 2020 · 4 comments

Comments

@acs
Copy link
Contributor

acs commented Aug 2, 2020

Continue from #127:

https://gist.github.com/rossant/6046463

and improved by James Bowman as described in https://excamera.com/sphinx/article-ray.html in the GitHub repository:

https://github.com/jamesbowman/raytrace

@acs
Copy link
Contributor Author

acs commented Aug 2, 2020

Ok, let's describe how the ray trace works. The ray tracer renderer has:

  • A 3D Scene is defined with 4 elements: 3 spheres and a plane.
  • The Scene has also lights (ambient and diffuse) and a camera pointing to the center of the Scene
  • A 2D image where the 3D scene is rendered using ray tracing

The logic is:

  • For each pixel in the 2D image fill the color based on ray tracing.
  • Cast a ray with origin (O) the camera that goes through each pixel (this defines the direction)
  • Find if the ray hits any object in the Scene.
    • If no hits, drop the ray (no effects in the pixel color)
    • If the ray hits an object, find the hit point (M)
      • If the hit point is shadowed drop the ray (no effects in the pixel color)
      • Find the hit point color contribution to the pixel based on:
        • Ambient light
        • Diffuse light using Lambert shading
        • Specular light using Blinn-Phong shading
    • Create max_depth reflection rays and repeat the above process

@acs
Copy link
Contributor Author

acs commented Aug 2, 2020

One of the hardest problems with ray tracing is the intersection point and howto find the direction of the ray from the light to the hit point. In this simple case, we have a plane and a sphere. In these cases, it is pretty simple.

https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection

@acs
Copy link
Contributor Author

acs commented Aug 2, 2020

All done for this first iteration.

@acs acs closed this as completed Aug 2, 2020
@acs
Copy link
Contributor Author

acs commented Aug 4, 2020

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

No branches or pull requests

1 participant