If I have an arbitrary plane (center and normal) or a quad (center, normal and width and height) and a camera (frustum, projection & view matrix, etc). Then how would I go about calculating if the plane/quad is visible to the camera?
Additionally how would I calculate to check if it's the front or the back of the plane/quad that is visible to the camera?
My first idea was to do some ray vs plane intersection, but then I realized that it of course wan't going to work!
bool plane_visible = false;
const float denom = plane_normal.dot(camera.getLook());
if (abs(denom) > 0.0001f)
{
const float t = (plane_position - camera.getPosition()).dot(plane_normal) / denom;
plane_visible = (t >= 0.0f);
}
Using the dot product of the plane/quads normal and the camera's look direction. Will give wrong results!
For instance, use the following image as an example! A dot product will tell me that I'm looking at the face that's facing outwards of the frustum. Though the face that I'm actually looking on is face facing inwards the frustum/towards the camera!