<p>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 <code>I_diffuse_line</code> function from listing 1.6 (modified to use 2-component vectors) yields reasonable-looking lighting.</p>
<p><img src="https://i.sstatic.net/kNkMB.png" alt="a diagram of a sphere with a line projected onto it" /></p>
<p>There’s a copy of the paper available <a href="https://blog.unity.com/technology/linear-light-shading-with-linearly-transformed-cosines" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2021-07-19T05:11:33.897Z
2021-07-19T05:11:33.897Z
Noah Witherspoon
<p>I’m trying to render a 2D image something like this:</p>
<p><img src="https://i.sstatic.net/vkZB6.png" alt="a circle with its edge illuminated by a line" /></p>
<p>…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. <a href="https://eheitzresearch.wordpress.com/757-2/" rel="nofollow noreferrer">linearly transformed cosines</a>; 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?</p>

<lighting><geometry><2d>
Area-light approximation in 2D
Noah Witherspoon
# Area-light approximation in 2D

(Asked by: username_0 on 2021-07-19)

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

![a circle with its edge illuminated by a line](https://i.sstatic.net/vkZB6.png)

…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](https://eheitzresearch.wordpress.com/757-2/); 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?

**Tags:** lighting, geometry, 2d


---

## 1 answers

### Answer by username_0 on 2021-07-19. Score: 3 | Accepted answer

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](https://i.sstatic.net/kNkMB.png)

There’s a copy of the paper available [here](https://blog.unity.com/technology/linear-light-shading-with-linearly-transformed-cosines).


---

