I am writing a raytraced rendering program from scratch right now. I have no idea how this is typically done, I have not read any literature, but the way I am choosing to implement it is by finding the parametric equation for a light ray, and computing the parametric equation of a plane for a geometric face in the scene and then computing the intersection point.
This part is good, but the trouble is that a 'face' has boundaries, and the next thing I need to do is check to see if the intersection point is actually within the boundaries of the face.
The most obvious way to do this is to look down the y dimension, and check to see if the intersection point's x and z components are within the x and z components of the vertices that make up the geometric face. This works in most cases except when the geometric face is vertical or nearly vertical.
To get around this problem, I compute a set of 3 basis vectors that define the image plane, and project the intersection point and all of the geometric vertices into this basis. Then, I can just check to see if the x and y components of the intersection point in this basis are within the boundaries of the x and y coordinates of the geometric face vertices.
However, my intuition was wrong here...one problem is that, in the image plane basis, there is no perspective so a plane that is perpendicular to the image plane will have a valid intersection area of zero...even though it occupies some area in the image.
Does anyone have a suggestion about how I could check the intersection bounds?