How can I a find the Light Direction/Ray from a Point on a surface to an Area Light? Is there a universal technique to do this for all types of lights (circle, rectangle, sphere & tube)?
Although this is for area lighting in a ray tracer, is there another way to implement area lighting through an emissive value that I can apply to any object or surface (I have seen this mentioned online)? As opposed to doing it like this.
For example for a point light I know it can be done like this:
class PointLight : public Light
{
Vec3f pos;
public:
PointLight(const Matrix44f &l2w, const Vec3f &c = 1, const float &i = 1) : Light(l2w, c, i)
{ l2w.multVecMatrix(Vec3f(0), pos); }
// P: is the shaded point
void getDirectionAndIntensity(const Vec3f &P, Vec3f &lightDir, Vec3f &lightIntensity) const
{
lightDir = pos - P; // compute light direction
float r2 = lightDir.norm();
lightDir.normalize();
lightIntensity = intensity * color / (4 * M_PI * r2);
}
};