that a given ray intersects the view frame. After either a maximum number of reflections or a ray traveling a certain distance without intersection, the ray ceases to travel and the pixel's value is updated. Calculate rays for rectangular viewport On input we have (in calculation we use vector normalization and cross product): eye position target position field of view - for humans, we can assume numbers of square pixels on viewport vertical and horizontal direction numbers of actual pixel vertical vector which indicates where is up and down, usually (not visible on picture) - roll component which determine viewport rotation around point C (where the axis of rotation is the ET section) The idea is to find the position of each viewport pixel center which allows us to find the line going from eye through that pixel and finally get the ray described by point and vector (or its normalisation ). First we need to find the coordinates of the bottom left viewport pixel and find the next pixel by making a shift along directions parallel to viewport (vectors i ) multiplied by the size of the pixel. Below we introduce formulas which include distance between the eye and the viewport. However, this value will be reduced during ray normalization (so you might as well accept that and remove it from calculations). Pre-calculations: let's find and normalise vector and vectors which are parallel to the viewport (all depicted on above picture) note that viewport center , next we calculate viewport sizes divided by 2 including inverse aspect ratio and then we calculate next-pixel shifting vectors along directions parallel to viewport (), and left bottom pixel center Calculations: note and ray so Above formula was tested in this javascript project (works in browser). Detailed description of ray tracing computer algorithm and its genesis What happens in nature (simplified) In nature, a light source emits a ray of light which travels, eventually, to a surface that interrupts its progress. One can think of this "ray" as a stream of photons traveling along the same path. In a perfect vacuum this ray will be a straight line (ignoring relativistic effects). Any combination of four things might happen with this light ray: absorption, reflection, refraction and fluorescence. A surface may absorb part of the light ray, resulting in a loss of intensity of the reflected and/or refracted light. It might also reflect all