Home                Company                Products                Gallery                Store                Links
 



WorldBuilder Tutorials

Shadows in the Communication Plug-in

One of the most important issues in making photorealistic scenes is proper lighting and shadows. It is not easy to create perfect lighting in one application, but it becomes really complicated when using two or more 3D packages.

Here are some tips and tricks that may help you to create good images while working with AWB and 3D Studio Max.

First of all, we have two different scenes that are illuminated by different sets of lights. We want to create consistent lighting and cast shadows from Max objects onto WB ones and visa versa. To get shadows on the WB scene is easy, but it also requires some understanding of how shadows are implemented inside WorldBuilder.

WorldBuilder uses shadow maps to store shading information. Shadow maps are z buffer rendered from the light source point of view. It has three main properties - Resolution, Interpolation Method and Shadow View. Resolution determines the shadow's width and height. The higher the resolution, the more accurate the shadow. The Interpolation Method is how the z buffer is used to compute the light intensity. "Intensity interpolation" produces softer shadows but may result in artifacts like moire patterns. "Depth Interpolation" is a more accurate method but it always results in "sharp" shadows. The Shadow View property is used to zoom in on the particular object or group of objects in the scene. This option is provided for efficient use of shadow map resolution. If we only want to get a shadow for a particular tree and not from all the objects in the scene, because all other objects may not be seen in the camera, then we should zoom in on that tree and only render it into the shadow map. You may have as many shadow maps as you like. A very common mistake users make is that they use the whole scene in the shadow view. That's why they have to increase the map resolution to obtain a reasonable shadow from an object that is just before the camera, but it is small compared to the whole scene.

The other problem is how to get shadows from WB objects on Max objects. To do this we use the dynamic light export feature. The idea is simple: to place a shadow on a Max object we must somehow export the shadow map inside Max and use it to generate a shadow. This is accomplished by using Dynamic Light Export (Max communication Object/Light Export). The only things you need to select are the lights that must be exported.

To use this simple procedure efficiently you must understand what is going on during rendering (I assume we will render from WB). First, we create the shadow map inside WB. To do so we render the WB and Max scene (using the shadow view) and compose two z buffers. Now we have a shadow map that contains information about WB objects as well as Max objects. Then we render the WB scene and use that shadow map in a processor intensive calculation. This is how Max objects cast shadows onto a WB landscape.

The next stage is much more complicated. We have to render the Max scene using pre-rendered shadow maps. First we import a shadow map inside Max and create a hidden light source attached to that map. Then we use the Max renderer to produce a z buffer, which will be returned later to WB and composed with the original. There are several hidden obstacles to this procedure described above, and I will attempt to explain them here.

The main obstacle is that WB shadows are not designed to be used inside Max. That's why shadows from Max objects on other Max objects are not as perfect as inside Max. Next, adding a new light to a scene will result in over-illumination of some objects. To avoid these obstacles we use following the procedure below, which, while it does not solve all the problems, helps in most cases.

  1. Let us assume that we have one light in WB, which represents the sun and one main light in Max (which also may be considered as the sun). It is not a problem if you have more than one light inside Max, but as a rule you have only one that works as daylight.
  1. We have a WB tree standing near two houses modeled in Max. We want to produce shadows from that tree on the Max objects as well as shadows from one house on another.
  2. Set Max light intensity to 0.5 and turn shadows on. This light will place shadows from one building on another.
  3. In WB, duplicate the main light source and set both light sources’ intensity to 0.5. Adjust the shadow view and resolution parameters for only one light.
  4. Turn off Max Communication Object "Call Max renderer option". Make a light with the shadow map turned on exportable to Max (see previous discussion).

Now you are ready to render.

Now I'll try to explain what this procedure solves.

  1. In WB we have two lights, only one of which has shadows turned on. Because light intensity is set to 0.5 the total light intensity is 1.0. This is OK. Because only one light casts shadows, however, shadows are softer, giving a feeling of a diffuse environment.
  2. In Max we have two lights - one main Max light and another dynamically imported from WB. Imported light has a shadow map that contains information only about WB objects. This is why it can not be used to cast shadows from Max objects on other Max objects. In contrast, the Max main light solves the problem of shadows from Max objects. Because light intensities are 0.5, the total intensity is 1.0.

This method solves the shadow problem for Max objects but fails to solve the problem of shadows from Max objects on WB landscapes. To correct this situation let us recall that the WB light that has no shadows at all. If that light would have a shadow map that includes information about Max objects, then everything will be OK. The simple solution of turning the Max Communication Object/Call Max renderer option on is not good enough, because it will corrupt shadows in Max. The real solution is to pre-render the shadow MAP for that light before splitting lights and performing the steps described above.

To accomplish this you need to turn the Max Communication Object/Call Max renderer option on and render the scene. Do not worry about the resulting image, the only thing we care about is the shadow map. Now you have to set the Shadow Map/Generate Map option to None. This means that the shadow map will never be regenerated which is OK for Static light and Static Max building. Now turn the Max Communication Object/Call Max renderer off again.

If you have any questions or suggestions about the communication plug-in e-mail me at sergey@animatekusa.com