Cascaded Shadow MappingReal-time, dynamic shadows can add huge amounts of realism and depth to a 3D game and shadow technology has grown massively over the last few years. There have been various ways of creating them and although they're all essentially "hacks" (i.e. they're not "real" shadows), the very latest techniques produce very impressive results. Futuremark's 3DMark06, along with Alan Wake and other titles, uses a method called cascaded shadow maps. Before we can explain the "cascaded" part, a brief description of how shadow mapping works is needed. To help with the lesson, we're using NVIDIA's OpenGL shadow mapping demo (which can be download from here but note that it requires glut32.dll to be installed on your machine) - it's a few years old now but the basic idea is still the same. In the images below we have a teapot, floating above a table, being illuminated by a single, directional light - i.e. the beam of light points in a set direction. In the top left hand corner, a view as seen by the light is rendered, so there are two views in the scene: the camera's and the light's. The difference between the first two pictures is that the position of the camera changes in the second one; note that the light's view is still the same.
In the third picture, the camera stays in the same place as in picture one but this time, the light is moved - see that it's view has changed? When using shadow maps, the graphics processor first renders (draws) the frame from the light's point of view; part of the rendering process is to generate something called a z or a depth buffer. A buffer is a collection of data, in the form of a table, that sits in memory - as its name suggests, a depth buffer stores information about the depth of each pixel, which is measured from the start of the point of view and then along the z-axis into the frame. The fourth picture shows what the depth buffer is for the light's position.
Odd looking colours, yes? That's because depth is just one thing, distance, so it only needs to be represented here by a simple greyscale range of colours: the lighter the colour, the further away that pixel is. This depth buffer is very important in shadow mapping because it tells the graphics processor whether or not a pixel is going to be visible in that point of view. The frame is then rerendered but this time from the camera's perspective - the light's depth buffer is then used a texture and mapped onto the surface in question. A bit of pixel processing is then done comparing the colour of the pixel in the depth buffer or to be correct, depth texture (the shadow map) to the colour of the surface. The result of this test will then determine whether the surface pixel needs to be dark (in a shadow) or normal (not in a shadow)! And that's all there is to it! Well not quite, as it's not a perfect solution..
|
|||||||||||||||||||||||||||||||||
![]() |