Spot Buffered Shadows
Spotlights can use either raytraced shadows or buffered shadows. Either of the two can provide various extra options. Raytraced shadows are generally more accurate, with extra capabilities such as transparent shadows, although they are quite slower to render. Buffered shadows are more complex to set up and involve more faking, but the speed of rendering is a definite advantage. Anyway, it shares with other lamp types common shadows options described here.
- Buf. Shadow
- When the Buf. Shadow button is activated, the currently selected Spot light generates shadows, using a “shadow buffer” rather than using raytracing.
When the Buf. Shadow button is activated, various extra options and buttons appear in the Shadow and Spot panel. A description of most of these options is given below:
- Shadow buffer generation type
- Blender has more than one way to generate buffered shadows. The shadow buffer generation type drop-down selector controls which generator to use.
- There are three shadow generation types, those being:
For more information on the different shadow generation methods see these links:
“Classical” and “Classic-Halfway” generation methods
Classical shadow generation used to be the Blender default and unique method for generation of buffered shadows. It used an older way of generating buffered shadows, but it could have some problems with accuracy of the generated shadows and can be very sensitive to ShadowBufferSize, different Bias values, and all the self-shadowing issues that brings up. It appears that the Classical method of generating shadows is in the position of being obsoleted and is really only still present to works with older versions of Blender, Classic-Halfway should probably be used instead.
Classic-Halfway is an improved shadow buffering method and is currently the default option selected in Blender. It works by taking an averaged reading of the first and second nearest Z depth values allowing the Bias value to be lowered and yet not suffer as much from self-shadowing issues. Not having to increase Bias values helps with shadow accuracy, because large Bias values can mean small faces can lose their shadows, as well as preventing shadows being overly offset from the larger Bias value.
Classic-Halfway doesn’t work very well when faces overlap, and biasing problems can happen.
Currently the Halo Step option doesn’t work well in some cases. Especially when using planes (not volumes), errors can be introduced.
Here are now the options specific to these generation methods:
- The ShadowBufferSize numeric field can have a value from 512 to 10240. ShadowBufferSize represents the resolution used to create a shadow map. This shadow map is then used to determine where shadows lay within a scene.
- As an example, if you have a ShadowBufferSize with a value of 1024, you are indicating that the shadow data will be written to a buffer which will have a square resolution of 1024×1024 pixels/samples from the selected spotlight.
- The higher the value of ShadowBufferSize, the higher resolution and accuracy of the resultant shadows, assuming all other properties of the light and scene are the same, although more memory and processing time would be used. The reverse is also true – if the ShadowBufferSize value is lowered, the resultant shadows can be of lower quality, but would use less memory and take less processing time to calculate…
|Buffered shadow examples for various ShadowBufferSize values (SpotSi to 145.0°, no filtering – Sample set to 1 –, to make it easier to see the quality degradation of the shadows).|
- As well as the ShadowBufferSize value affecting the quality of generated shadows, another property of Spot lamps that affects the quality of their buffered shadows is the size of the spotlights lighted area (the SpotSi value), as you can see below:
|Buffered shadow examples for various SpotSi values, with ShadowBufferSize set to 512, and no filtering (Sample set to 1).|
- As the SpotSi value is increased, you can see that the quality of the cast shadows degrades.
- This happens because when the Spot lighted area is made larger (by increasing SpotSi), the shadow buffer area has to be stretched and scaled to fit the size of the new lighted area. The ShadowBufferSize resolution is not altered to compensate for the change in size of the spotlight, so the quality of the shadows degrades. If you want to keep the generated shadows the same quality, as you increase the SpotSi value, you also need to increase the ShaodwBufferSize value.
- The above basically boils down to:
- If you have a spotlight that is large you will need to have a larger ShadowBufferSize to keep the shadows good quality. The reverse is true also – the quality of the generated shadows will usually improve (up to a point) as the Spot lamp covers a smaller area.
- Filtering algorithms
- The three mutually-exclusive Box, Tent, and Gauss buttons control what filtering algorithm to use to anti-alias the buffered shadows.
- They are closely related to the Samples numeric field, as when this setting is set to 1, shadow filtering is disabled, so none of these buttons will have any effect…
- The buffered shadows will be anti-aliased using the “box” filtering method.
- This is the original filter used in Blender. It is relatively low quality and is used for low resolution renders, as it produces very sharp anti-aliasing. When this filter is used, it only takes into account oversampling data which falls within a single pixel, and doesn’t take into account surrounding pixel samples. It is often useful for images which have sharply angled elements and horizontal/vertical lines (according to arkavision.com/?page_id=125).
|Buffered shadow examples for various Samples values, with the Box filtering method (SpotSi: 145.0°, ShadowBufferSize: 512).|
- The buffered shadows will be anti-aliased using the “tent” filtering method.
- It is a simple filter that gives sharp results, an excellent general purpose filtering method. This filter also takes into account the sample values of neighboring pixels when calculating its final filtering value.
|Buffered shadow examples for various Samples values, with the Tent filtering method (SpotSi: 145.0°, ShadowBufferSize: 512).|
- The buffered shadows will be anti-aliased using the “gaussian” filtering method.
- It produces a very soft/blurry anti-aliasing. As result, this filter is excellent with high resolution renders.
|Buffered shadow examples for various Samples values, with the Gauss filtering method (SpotSi: 145.0°, ShadowBufferSize: 512).|
- The following links will give more information on the various filtering/distribution methods and their uses:
- The Samples numeric field can have a value between 1 and 16. It controls the number of samples taken per pixel when calculating shadow maps.
- The higher this value, the more filtered, smoothed and anti-aliased the shadows cast by the current lamp will be, but the longer they will take to calculate and the more memory they will use. The anti-aliasing method used is determined by having one of the Box, Tent or Gauss buttons activated (see above).
- Having a Samples value of 1 is similar to turning off anti-aliasing for buffered shadows.
|Buffered shadow examples for various Samples values (Box filtering method?, SpotSi: 145.0°, ShadowBufferSize: 512).|
- The Soft numeric field can have a value between 1.0 and 100.0. It indicates how wide an area is sampled when doing anti-aliasing on buffered shadows. The larger the Soft value, the more graduated/soft the area that is anti-aliased/softened on the edge of generated shadows.
|Buffered shadow examples for various Soft values (Box filtering method?, Samples: 3, SpotSi: 145.0°, ShadowBufferSize: 512).|
The SpotSi and ShadowBufferSize have been chosen to exaggerate the blocky aliasing, and emphasize the Soft setting’s effects…
- Halo Step
- Halo Step can have a value between 0 and 12. It is used to determine whether this Spot will cast volumetric shadows, and what quality those volumetric shadows will be.
- (Layout of halo and volumetric shadow) is an example render which shows a volumetric shadow being cast.
- For volumetric shadows to work, you must have the Halo button activated, and a high enough HaloInt value, so that the cast volumetric shadow is visible. Once these conditions have been met, the Halo Step value can be altered to change the quality of the volumetric shadows.
- If Halo Step is set to a value of 0, then no volumetric shadow will be generated.
- Unlike most other controls, as the Halo Step value increases, the quality of volumetric shadows decreases (but takes less time to render), and vice-versa.
|Volumetric shadow examples for various Halo Step values (HaloInt: 2.0).|
|A value of 8 for Halo Step is usually a good compromise between speed and accuracy.|
- SampleBuffers: 1, 4, 9
- The SampleBuffers setting can be set to values 1, 4 or 9, and represents the number of shadow buffers that will be used when doing anti-aliasing on buffered shadows.
- This option is used in special cases, like very small objects which move and need to generate really small shadows (such as strands). It appears that normally, pixel width shadows don’t anti-alias properly, and that increasing ShadowBufferSize doesn’t help much.
- So this option allows you to have a sort of extra sample pass, done above the regular one (the one controlled by the Box/Tent/Gauss, Samples and Soft settings).
- The 1 value will disable this option.
- Higher values will produce a smoother anti-aliasing – but be careful: using a SampleBuffers of 4 will require four times as much memory and process time, and so on, as Blender will have to compute that number of sample buffers…
- The “pixels” of each of the sample buffers are slightly offset, in a similar way as the standard rendering OSA (TODO: or isn’t it rather like the MBLUR temporal “bluring” ?).
- Find out how the sample buffers are really generated (spacial offsetting, temporal offsetting, or both?).
- Find out the method/algorithm used to blend/mix/combine the computed shadow buffers back into a single one.
- Explain why this method is better, for small shadows, than the standard, single-buffer one.
“Irregular” generation method
Irregular shadow method is used to generate sharp/hard shadows that are placed as accurately as raytraced shadows. This method offers very good performance because it can be done as a multi-threaded process.
This method supports transparent shadows. To do so, first select the object which will receive the transparent shadow. Then alter the Shad A value in its Material panel (Shading context, Material sub-context, F5). This will only work when Irregular shadow buffer lighting is used.
- Find how this method is working (and why it has nearly no extra option).
The following settings are common to all buffered shadow generation method.
- The Bias numeric field can have a value between 0.001 and 5.0. Bias is used to add a slight offset distance between an object and the shadows cast by it. This is sometimes required because of inaccuracies in the calculation which determines weather an area of an object is in shadow or not. Making the Bias value smaller results in the distance between the object and its shadow being smaller. If the Bias value is too small, an object can get artifacts, which can appear as lines and interference patterns on objects. This problem is usually called “self shadowing”, and can usually be fixed by increasing the Bias value, which exists for that purpose! Other methods for correcting self shadowing include increasing the size of the ShadowBufferSize or using a different buffer shadow calculation method such as Classic-Halfway or Irregular.
|Buffered shadow examples for various Bias values (ShadowBufferSize: 512).|
- The images above show the affect of different Bias values. With a Bias of 0.001, the scene is full of self shadowing interferences, but the shadow coming from the back of the sphere is very close to the it. With Bias at 0.1, most of the self shadowing interferences have been eliminated (apart from small areas on the sphere), but the start of the shadow point has moved slightly to the left of the sphere. With Bias values at 0.5 and 1.0, the shadow start point moves even further away from the sphere and there is no self shadowing interference.
- Self shadowing interference tends to affect curved surfaces more than flat ones, meaning that if your scene has a lot of curved surfaces it may be necessary to increase the Bias value or ShadowBufferSize value.
- Having overly large Bias values not only places shadows further away from their casting objects, but can also cause objects that are very small to not cast any shadow at all. At that point altering Bias, ShadowBufferSize or SpotSi values, among other things, may be required to fix the problem.
Finer Bias tuning
You can now refine the Bias value independently for each material, using the LBias slider (Shaders panel, Material sub-context, Shading context, F5). This value is a factor by which the Bias value of each Spot buffered shadows lamp is multiplied, each time its light hits an object using this material. The 0.0 and 1.0 values are equivalent – they do not alter the lamp’s Bias original value.
- ClipSta & ClipEnd
- When a Spot light with buffered shadows is added to a scene, an extra line appears on the Spot 3D view representation, see (Screenshot showing shadow ClipSta and ClipEnd points line).
- The start point of the line represents ClipSta’s value and the end of the line represents ClipEnd’s value. ClipSta can have a value between 0.1 and 1000.0, and ClipEnd, between 1.0 and 5000.0. Both values are represented in Blender Units.
- ClipStart indicates the point after which buffered shadows can be present within the Spot light area. Any shadow which could be present before this point is ignored and no shadow will be generated.
- ClipEnd indicates the point after which buffered shadows will not be generated within the Spot light area. Any shadow which could be present after this point is ignored and no shadow will be generated.
|Buffered shadow examples for various ClipSta and ClipEnd values (ShadowBufferSize: 2048).|
- The area between ClipSta and ClipEnd will be capable of having buffered shadows generated.
- Altering the ClipSta and ClipEnd values helps in controlling where shadows can be generated. Altering the range between ClipSta and ClipEnd can help speed up rendering, save memory and make the resultant shadows more accurate.
- When using a Spot lamp with buffered shadows, to maintain or increase quality of generated shadows, it is helpful to adjust the ClipSta and ClipEnd such that their values closely bound around the areas which they want to have shadows generated at. Minimizing the range between ClipSta and ClipEnd, minimizes the area shadows are computed in and therefore helps increase shadow quality in the more restricted area.
- Automatic ClipStart & ClipEnd
- As well as manually setting ClipSta and ClipEnd fields to control when buffered shadows start and end, it is also possible to have Blender pick the best value independently for each ClipSta and ClipEnd field.
- Blender does this by looking at where the visible vertices are when viewed from the Spot lamp position.
I am not really clear on how SampleBuffers and Irregular shadows buffers work so if anyone has more info and came make thing clearer either contact me and I will update the page, or update it yourself – the same goes for anything else you think should be changed on this page. Terrywallwork - 3 Oct 2008, Mont29 14:11, 2 May 2009 (UTC).
Below are various examples using a solid sphere with shadows cast against a plane object. Note how the different settings affect the shadow that is cast. You get everything from sharp shadows to very soft shadows.
Any object in Blender can act as a camera in the 3D view. Hence you can select the Spot light and switch to a view from its perspective by pressing Ctrl0 NumPad. What you would see, in shaded mode, is shown in (Spot light clipping tweak).
The left frame shows ClipSta too high, the center has it correct, and the right shows ClipEnd too low. All object(s) nearer to the Spot light than ClipSta and further from ClipEnd is(are) not shown at all. Hence you can fine tune these values by verifying that all shadow casting objects are visible.