Ray tracer in C
cd ~/Desktop; gcl https://github.com/gouiferda/RTv1.git; cd RTv1; make run;
-
Minilibx functions
-
expose properly (mlx_expose_hook)
-
Functions and structures
- vector
- ray
- figure (sphere,plane,cylinder,cone)
- camera
- light
-
Mapping the coords system (0,0,0) to screen (0,0)
-
ambiant light / intersection with ray
- sphere
- plane
- cylinder
- cone
-
diffusion: lambert diffuse model
-
specular: blinn specular model
-
Shadows
-
Moving and rotating the objects
-
Moving and rotating the camera
-
Norm & Handle errors and leaks and messages
-
Multi lights (spots)
-
Reflection
-
Extra Bonuses: Antialiasing, External files for scene description, Reflection, Transparency, Shadow according to transparency...
-
Research/learn about: ray tracing and vectors in maths
-
Do a test and understand: plane line intersection
-
cylinder/line intersection
-
cone/line intersection
-
Antialiasing
-
create YML maps parser (Read External files for scene description)
- Ambiant: Color alone of the object
- Diffuse: controls roghness/dullness of object
- Specular: controls shinningness (noticable in : metal , marbles)
- Specular + Diffuse: How surface responds to light
- Indirect illumination: Light bounding off of other objects in the scene (Reflected rays)
- Shading model: diffuse + specular reflection
Lambert: (Diffuse)
To caluclate the color we need:
- surface normal (intersection point - center of sphere) normalized
- direction to the light (light pos - intersection point) normalized
- do a dot product
- refelective color of the sphere
each rgb has from 0 to 1 color = (l.n) x light.intensity x color of figure rgb color = (L.N) x M diff x color of figure rgb L: Ray towards light direction N: normal at hit pos, M diffuse: material's diffuse coeficcient // how much the figure is absorbing light / 1 max 0 min C object: color of object Dot product should not be negative
Blinn-Phong shading model: (Specular shading)
Phong_term = (V.R)^k
V- Ray towards viewer R- Light ray reflexted direction k - Material's specular coefficient (shininess) (L: intersection to light, N normal, R referse of L : reflection, V intersection to viewer ray to point) Dot product should not be negative
Half way vector:
H = L + V H = norm (H)
Blinn term = (H.R)^k
Material:
- Color:base color
- Ambient: what color it reflects in ambient light
- Diffuse: what color it reflect in diffuse light
- Specular: what is the color of its specular hihglight
- Easy explaination
- Khan academy course: Basics and the Mathematics of rendering
- Udacity course: Interactive 3D Graphics
- Ray tracing 1
- A Ray Tracer - Part 1
- A Ray Tracer - Part 2