Hey,

So I want to do a bit of optimization on my deferred renderer, in that currently I render all the lights as full screen quads, which wastes a lot of time on unnecessary pixels. Right now, all I have is point lights, so basically lights are represented with a position and a radius. I want to compute the bounding box for the sphere so that I can either render quads where the fragment shader is going to be preformed or tile-based shading, all though I'm not sure if tile based shading needs this kind of computation. Right now I've used an approximation algorithm to get the radius and the center on screen and then I can construct the bounding box by that. It goes something like this:

float rad = glm::atan(lightRad, screenSpacePos.z); rad = rad*(glm::max(ENGINE_WIDTH, ENGINE_HEIGHT) / glm::radians(RENDERENGINE_FOV));

It kinda works, but, like I said, its only an approximation, and when the camera is rotated, things that it covers becomes uncovered, so I need a more accurate representation. My thought was to construct a bounding box of the sphere in world space and translate it to clip space, get the min and max of all the points and construct a bounding box that way. Is there any way to do this more optimally? Or is this going to be one of the best ways to make sure that this is fairly accurate, as well as include other shapes ultimately (because bounding boxes can be calculated for those too).

Thanks.