Join George Maestri for an in-depth discussion in this video Adding depth map shadows, part of Maya Essentials 6: Lights and Rendering.
- View Offline
In the real world, all lights cast shadows. In Maya, you have to specify if a light cast shadows and how it will cast them. So let's take a look at the simplest type of shadows and those are called depth map shadows. I have a simple scene here with an airplane on a flat field and I also have a spot light that's illuminating it. So if I want I can move the spot light to adjust it or use the Manipulator if I want.
But really what we want to do is take a look at this light from the Attribute Editor. So I want to make sure I select the light, go into the Attribute Editor and let's go ahead and add some shadows to this. So I am going to go down from Spot Light Attributes until I find Shadows. Then I am going to go ahead and open up the Shadows rollout, and then we have two options here: one is Ray Trace, the other is Depth Map, which is the top one.
So if we want this to have Depth Map Shadows, I can just go ahead and collect this to turn it on. Now I am not seeing shadows in the Viewport. If I want to, if want to make sure that I have Viewport 2.0 turned on, Use All Lights and make sure I have Shadows turned on. Now once I have that turned on, you can see pretty accurately how the shadow is being cast on this object. Now we have a number of options here for depth map shadows.
The first one is the resolution of the shadow. depth map shadows work by creating a bit map of the shadow and laying it over the image. So this number here is the Resolution of that bitmap. Now this number may need to change upwards if you are rending large high quality images. So this is a specific number, so if you are rendering larger images, you need to have a larger number.
But right now we are just rendering 640x480, so let's just take a look at how this works. So this will determine the granularity of the shadow. So a lower number, let's bring this to down to say 64, will make this very, very blocky. Now what this does is it creates a 64x64 pixel-wide bitmap to cover the entire area that this light is illuminating and obviously this is not enough.
Now if we want we can bring it up. So let's say I will bring it up to 128, you will see that I get more coverage. If I bring it up really high, let's say bring it up to 2000, in fact, I am going to bring up to 2048, I typically use powers of two for this. You can see how it gets very, very sharp. So if you want very sharp shadows, a larger Resolution Depth Map will help. But if we want say fuzzy or kind of not so sharp shadows, you can actually use these lower values to your advantage.
So I am going to bring this back down to 128. Now as it stands here, this is going to be too jagged for us to actually use it. But we have some additional parameters here. So if I scroll down, we have one here called Filter Size and what this does is it blurs the edge of the shadow. So when the filter is at 0 or 1, you are pretty much getting the edge of that bitmap that you're seeing, but as it goes up, let's say it goes up to 2, or 3, or 4, you will see how it's actually adding enough blur so that you are really not noticing the edge of that shadow.
Now I am doing all of this in the Viewport, so you can see how it works interactively, but if I were to render this, let's say we render this with a Filter size of 0, I am just going to do quick render right here. You will see that's pretty much what we had. Now if I bring the Filter Size up and do a quick render, you'll see I get a much softer shadow. So we have two attributes here that need to be balanced.
One is the Resolution of the bitmap; the other is the Filter which determines the blurring. So higher numbers in the bitmap make for a sharper shadow. Higher Filter Sizes, blur that to soften the edges of that. But it only softens the edges between the pixels. So if you have a really sharp shadow, Filter Size isn't going to blur it. Now in addition to this, we have a couple of other parameters here and probably the most important one is Bias.
Now what this does is it actually offsets the shadow from the object. Now remember how depth map shadows work. We take a bitmap that's the size of the light and use that to create the shadow and then that's projected over the image. So this Bias basically offsets that just a little bit, so that way you don't get self-shadowing, or you don't get that shadow overlapping on your object.
So if you're getting a little bit of shadow error, you can always increase this Bias. So as I bring this Bias up if you notice here, the propeller, it kind of goes away. So what it's really doing is it's pushing the shadow back or forward depending on this Bias. So typically we want to keep this at a fairly low number. So those are some of the basics of how to do depth map shadows and this is probably the easiest and also fastest to render shadow that you have in your toolkit.
- Adjusting the Render Settings menu
- Adding depth map and raytrace shadows
- Understanding the principle of light decay
- Creating cameras
- Using Motion Blur in Maya and mental ray
- Using Final Gather for natural illumination
- Rendering transparent materials with caustics
- Batching rendering