L3DT users' community
Large 3D terrain generator

Super-sampled shadows

It doesn't hurt to ask...

Super-sampled shadows

Postby David Walters » Thu Apr 30, 2009 1:54 pm

I was wondering could you improve shadows by extended the shadow code to blend samples together? i.e. instread of creating an 8K monchrome shadow texture - you'd create a 1K greyscale map by picking picking "8x" super-sampling from a combo box.

This would blend the binary shadow contributions together to get an approximate penumbra region (especially with shallow angled sunlight) - and leave you with a softer anti-aliased edge. Without taking up as much texture space.

I may have missed some vital thing that would make this fail, or not look too good, but it sounds like a good way to get a nicer looking shadow edge.
David Walters
Doyen
 
Posts: 129
Joined: Fri Apr 24, 2009 1:10 pm

Postby Aaron » Thu Apr 30, 2009 9:38 pm

Hi David,

L3DT does shadow anti-aliasing behind the scenes when it generates the light map from the shadow map*. You should be able to notice the soft edge if you look closely at a shadow edge in, say, an 8x res light map. However, the anti-aliasing radius is hard-coded**, but I can make this an option if you like. Also, if you want to use the shadow map in another application, I can certainly add an option to actually bake the anti-aliasing onto the shadow map.

Cheerio,
Aaron.


* only available in L3DT Pro, when using high-res light maps.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby David Walters » Fri May 01, 2009 9:54 am

Ah, okay - I didn't spot that it was filtered when you make the light maps - I saw the raw shadow map as monochrome and assumed that was it. :oops:
(I've not had enough time lately to play with my new Pro copy!)

I've also thought some more and realised the major flaw with my assumption that my request would generate realistic soft shadows! :oops: :oops:

For my request to work how I originally thought it would you'd actually need to create a number of offset samples from your shadow ray, effectively casting a cylinder. It's something I've seen suggested to make soft stencil shadow volumes, but I think would work better as an offline process.

So I guess that's my amended request. With the same caveat that I'm not sure if the banding you'd get would be acceptable without a massive number of extra ray-casts!
David Walters
Doyen
 
Posts: 129
Joined: Fri Apr 24, 2009 1:10 pm

Postby Aaron » Sun May 03, 2009 1:25 pm

Hi David,

L3DT Pro can indeed do multiple shadow casts with a small divergence angle to simulate an extended light source such as the sun. By default, this is only used to prevent banding on near-axis rendering, but I think you could adapt it for soft shadows. The relevant settings may be edited from the 'Settings->Presets' menu option, in the 'Calcs->LM->CastShadows' branch. The settings are:
  • MultiCastMax - the number of rays cast for each point. Default is 4.
  • MultiCastDivergence - the maximum ray vector divergence from the set sun angles, in tangent ratios. Default is 0.005 [ atan(.005) = 0.3 degrees].
  • MultiCastThreshold - the angle, as measured in degrees from cardinal axis, above which multi-casting is disabled. Default is 10, but you can set this to 0 to force multi-casting for all angles.


Alternative, you can use the 'LightMapSequence' plugin to generate a number of light maps with mildly different sin angles, and average the resulting maps*.

Cheerio.
Aaron.

* Map averaging may require some Photoshop work, or else a custom plugin or script.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to Feature requests

Who is online

Users browsing this forum: No registered users and 27 guests