I’m trying to render a 2D image something like this:

a circle with its edge illuminated by a line

…where an arbitrary shape has its border illuminated by a line in a relatively physically accurate way, i.e. with less illumination reaching the shape at points that the line is farther away from. I’m generally familiar with some of the existing approximations in 3D, e.g. linearly transformed cosines; as far as I can tell, though, there’s no literature on ways to do the same in 2D. It seems like there might even be a way to solve the actual integral analytically, but I’m not sure where to start. Any ideas?


Found a solution—it may not be strictly accurate for 2D, but it produces the look that I’m after. “Linear Light Shading with Linearly Transformed Cosines”, in section 1.3, describes a closed-form solution to this integral; transforming the line’s endpoints into a space local to the surface and then running them through the I_diffuse_line function from listing 1.6 (modified to use 2-component vectors) yields reasonable-looking lighting.

a diagram of a sphere with a line projected onto it

There’s a copy of the paper available here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.