I want to draw realistic shadows, but all techniques I have found look bad. So to learn more I have tried to analyze if a shadow can be simulated.
The challenging region of a shadow is its blurry edge, the penumbra. Knowing how it turns from dark to bright is essential for drawing. This could depend on many factors, e.g. the shape of the light casting the shadow, the color of the light, etc. So in order for the analysis to not get out of hand I will impose some restrictions. The only type of shadows I will analyse are shadows cast by the Sun. I will try to find out if how these shadows turn from dark to bright can be be described by a linear gradient, Gaussian blur, or as a shadow from a uniformly radiating disc.
The last alternative assumes that the Sun is a Lambertian radiator, i.e. the intensity of the light emitted is described by Lambert’s cosine law. However, the Sun is affected by limb darkening and is darker at the edges than the center. So it may turn out that Gaussian blur is a better model.
To know something, I need data. Assuming all shadows from the Sun has the same blurry edge, it will be sufficient to only analyze one shadow. And to make the analysis simpler, I took a photo of the edge of a straight shadow on a gray background.
I took the photo with a Ricoh Caplio GX100 and exported it using Adobe Lightroom 3. This is a scaled version of the photo.
The analysis is the same for each of the three color channels and the results are very similar. The following results are from the green sRGB channel.
All pixels in a column of the photo has approximately the same intensity. The column-wise histogram and the column-wise mean are useful to get an overview of the data.
I tried three ideas for functions that may estimate the shadow. A linear gradient, Gaussian blur, and a shadow from a Lambertian radiator. I used genetic programming to find parameters for each function so that it would fit the photo. The best Euclidean distance to the photo were 70.97 for the linear gradient, 70.01 for Gaussian blur, and 68.90 for the shadow of a Lambertian radiator. Here are their graphs.
The only way to evaluate which method is best is to paint the estimated shadows and to perform a visual inspection. This is how each model would estimate the shadow.
©2023 Mats Mattsson