Get light intensity at a position?

Would it be possible to get the light intensity/amount of light (or similar) at a specific position in the game world?

I use C#

Thank you

Yeah, though the code may be a little involved: Get all the lights in the scene; perform a raycast to each one (or, for directional lights, a raycast to infinity in that light’s “backwards” direction) ; for each one where the raycast doesn’t hit a closer object than the light (or, in the case of directional lights, where it doesn’t hit anything at all), compute the intensity given the distance to the light. Sum up all the resultant intensities, and also add in the ambient light.

If you need to support spotlights, you’ll also need to make sure the position is within the light cone before you add the intensity in.

I would guess that getting a per pixel solution equation for a specific point in 3d space would be a bit messy to achieve. If it’s a single light source it would be easier, something like this perhaps: http://www.ehow.com/how_7240676_calculate-light-intensity.html

Otherwise you could look into what Unity does with shaders and attenuation: http://unity3d.com/support/documentation/Components/SL-Attenuation.html

I’d probably try to cheat this depending on nearest light source while checking their range and intensity and having ambient light into calculation to come up with a quick solution.