I think the extra chapter on area lights is my favorite now, it's probably the best explanation of the topic I have seen so far... kudos to Jamis again!
Anyway I kinda suck at setting up scenes so I found this function quite handy. You pass the function a source and target point in world space, and it will orient the area light so that it is centered at the source point and facing directly the specified target point. I'll try to write it in pseudo code.
function orient_area_light(light, source, target) n = normalize(target - source) // Desired direction of the area light normal
// Compute tangent and bitangent vectors a = vector(0, 1, 0) t = normalize( cross_product(a, n) ) b = cross_product( t, n )
// Replace the uvec and vvec vectors, but preserve their length light.uvec = t * length(light.uvec) light.vvec = b * length(light.vvec)
// Set the corner so that the source position falls in the center light.pos = source - (light.uvec * 0.5) - (light.vvec * 0.5) }
Here's a test image!
Last Edit: Feb 6, 2019 19:32:02 GMT by ascotti: Fixed error in light.pos assignment.