How to render soft shadow from directional light

Practical and theoretical implementation discussion.
Post Reply
shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

How to render soft shadow from directional light

Post by shiqiu1105 » Fri Oct 24, 2014 8:27 pm

Hi,

My question is really simple.
In ray tracing, sun-like light source is directional, which results in perfectly hard shadows.
In nature, however, shadow of the sun usually is a little fuzzy too.

How to achieve that in ray tracing?

Thanks

AranHase
Posts: 9
Joined: Fri May 16, 2014 11:00 pm

Re: How to render soft shadow from directional light

Post by AranHase » Sat Oct 25, 2014 2:09 am

For point light the most straightforward way of producing soft shadows is to give an area to your light source, and take more than one sample for your shadow rays. This was initially proposed by Cook (http://en.wikipedia.org/wiki/Distributed_ray_tracing).

For directional light, maybe use distance to the geometry? http://www.iquilezles.org/www/articles/ ... hadows.htm

ingenious
Posts: 282
Joined: Mon Nov 28, 2011 11:11 pm
Location: London, UK
Contact:

Re: How to render soft shadow from directional light

Post by ingenious » Sat Oct 25, 2014 10:30 am

It's pretty easy. Instead of shooting shadow rays in a single direction, you can generate their directions uniformly in a small cone around this direction.
Image Click here. You'll thank me later.

shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

Re: How to render soft shadow from directional light

Post by shiqiu1105 » Sat Oct 25, 2014 5:25 pm

ingenious wrote:It's pretty easy. Instead of shooting shadow rays in a single direction, you can generate their directions uniformly in a small cone around this direction.
Sounds like a good solution! Thanks!

Also, an additional question is that, how to render reflected specular high light from delta light sources like directional lights or point lights?

papaboo
Posts: 46
Joined: Fri Jun 21, 2013 10:02 am
Contact:

Re: How to render soft shadow from directional light

Post by papaboo » Sat Oct 25, 2014 6:04 pm

how to render reflected specular high light from delta light sources like directional lights or point lights
Please don't go there. :) A point light has zero radius and cannot be sampled from a specular surface. The probability of a specular ray hitting the exact point at which your pointlight lies is 0.

You can hack it by evaluating the specular surface as a slightly glossy surface when sampling light sources directly, but it will look weird in some cases, fx when the point light is really close to the surface, you'll see a large'ish highlight from a light source that you can't actually see. I've done this before and it works, but it also means that you have to tweak your material to every new lighting scenario, since you're hacking the material to simulate something in the scene that doesn't really exist.

Instead just save yourself the hacks and implement proper area lights from the start. You can look at pbrt and Mitsuba's light sources for inspiration. Then you also have a solution that should produce consistent renderings across integrators. Personally I'm very happy with this property in my current renderer, since we use that property for verifying just about everything that we do. :)

Post Reply