Shadows
See
light linking and shadow linking for information on controlling which objects cast shadows from various lights.
Tip | Shadows slow down the render. You should generally light without shadows to keep rendering speed high, then add shadows when you're satisfied with the lighting. |
Note | When rendering with physically based rendering, shadows are rendered automatically. |
Shadow calculation methods
Houdini has three methods for calculating shadows. You control the method through the Shadow Type parameter on the Shadows tab of the light.
Ray-Traced Shadows
Ray-traced shadows, also knows as “Filter shadow” or “Fast shadow”, are automatic in the sense that unlike depth-map shadows, you don’t need to configure or tune them to get good results. On the other hand, ray-traced shadows are very slow compared to depth-map shadows.
Depth Map Shadows
Depth map shadows, also known as “Z-depth”, calculate a shadow map recording the distance of each surface from the light as pixel values in an image.
This method is much faster than ray-traced shadows. Once the map is generated, calculation of shadows is extremely fast. However, the accuracy of the shadows depends on the resolution of the map image, so it requires some tuning to find the balance between speed and accuracy.
Deep Shadow Maps
Deep shadow maps, also known as “Deep shadow”, are a variation of regular depth maps. Similar to regular depth maps, they are pre-computed and are controlled by a resolution. Unlike regular depth maps, however, deep shadow maps are three dimensional: the map records every transparent surface it hits before it stops at an opaque surface.
The advantages of deep shadow maps are that they provide transparency and anti-aliasing.
The disadvantage is that generating a deep shadow map is slower and can require much more disk space than regular depth maps.
Using Shadows
| To... | Do this |
|---|---|
Use a ray-traced shadow | On the Shadows tab of a light object, change the Shadow Type to Ray-Traced Shadow. |
Use a depth map shadow | On the Shadows tab of a light object, change the Shadow Type to Depth Map Shadow and make sure the Transparent Shadows checkbox is turned off. |
Use a deep shadow map |
|
Setting up a Depth Map
Create a light and look through it.
For information on placing lights see the
Lights and Cameras help.On the Shadows tab of the light object, change the Shadow Type to Depth Map Shadow. If you want to use a deep shadow map, turn on the Transparent Shadows checkbox.
On the Depth Map Options sub-tab of the Shadow tab, turn on the Auto-generate Shadow Map checkbox.
Note | You can tweak the Resolution and Pixel Sample parameters to alter the size of your shadow map and the anti-aliasing samples. |
Addition information
See the Deep Shadow example file for examples of things like colored shadows.
Always use the .rat format for Z-depth shadows and deep shadows generated for mantra. The .rat format supports higher quality texture filtering and more efficient memory management than
.picfiles.If you want a surface to avoid having shadows cast upon it (“catching” shadows), you must write its surface shader with this in mind. Use the isShadowRay VEX function in the shader to tell when the renderer is calculating shadows.
There are a few ways you can make opaque objects cast colored shadows:
Create two light sources parented to each other. Make one light cast shadows and other cast no shadows. Set the non-shadowing light to the shadow color, and the shadowing light to the shadow color’s complement.
For example, to make a green shadow, set the non-shading light color to
0, 1, 0, and the shadowing light color to1, 0, 1. The non-shadowing light will pass through the object.Create a custom shadow shader in VEX. You can query the color of the light before shadows are cast, compute the shadows, then blend between the original color and the shadow color.
Modify the surface shader so the object becomes transparent only for shadows. This means the light passing through the surface will be added to the shadow. So, it will appear the object is transmitting light.
