= Shadows = See [Icon:PANETYPES/linker][light linking and shadow linking|lightandshadowlinking] for information on controlling which objects cast shadows from various [lights|/light]. 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|/rendering/pbr], 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|/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" shadows, 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 shadows", 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 == tasks>> 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: # On the __Shadows__ tab of a light object, change the __Shadow Type__ to Depth Map Shadow. # Turn on the __Transparent Shadows__ checkbox. Make an object not cast shadows: Use [shadow linking|lightandshadowlinking] to control which objects cast shadows from which lights. Make an object cast shadows but not appear in the render (phantom object): Turn on the __Phantom__ checkbox on the object's __Render__ tab. == Setting up a depth map == # Create a [light|/light] and look through it. For information on placing lights see the [Icon:OBJ/light][Lights and Cameras|/shelf/lightsandcameras] 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|/examples/nodes/obj/light/DeepShadow] example file for examples of things like colored shadows. - Always use the .rat format for Z-depth shadows and deep shadows generated for [mantra|Node:out/ifd]. The .rat format supports higher quality texture filtering and more efficient memory management than `.pic` files. - 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: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 to `1, 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|/shade] 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.