Shadow Casting in World Builder A step to step tutorial on how to reach decent results on the creation of shadows Tutorial on shadow casting in World Builder 3.* Introduction Cr eating decent shadows in any 3D scene adds to realism, this is the same for scenes (landscapes) created in W orld Builder. Problem for m ost starting (and even advanced) users of a 3D package however is, how do you create decent looking shadows, how can I m anipulate shadows, do I need them always or not? W ith this tutorial I will try to explain you most elements on shadow creation within the W orld Builder package. Som e explanations will be generic and can be used within any 3D package, I will focus however on all W orld Builder aspects where it concerns shadows, as this is the pack age we work with for this tutorial. Provided with this tutorial are several W orld Builder scene’s (files to be used in W B) to help you better unders tand how things come to be. These scene’s can be explored, altered and so on. W ith most scene’s we will do som e training on shadow creation and we will go from very basic to m ore advanced as the tutorial prog resses . Some other scene’s provided are just there to explore on what settings are used and for you to experiment with. The Ambient light problem. The ambient light in most 3D program s is an unrealistic effect that is not similar to its real-life namesake, and can give problem s in realistically lighting/shading the sc ene. W hat has this got to do with shadows then, you might ask? W ell without light no shadow, and non realistic light will in most cases produce non realistic shadows. As the ambient light in W orld Builder is evenly distributed within your scene, this can cause loss of detail. Why, is this? I will try to explain this in a short and sim ple way. In real life am bient light is widely distributed light that has bounced off objects in an environment. Ambient light even lights areas not directly lit by any other light sourc e. Real life ambient light is tinted as it bounces around the environm ent. It picks up color from every object it has bounced against, it varies in intensity and thus does not evenly distribute a single color. It shades objects with a different intensity and coloring. Here it is, the word shades (it has to do with shadows )! A n even am bient color and intensity distribution can create an incredible loss in detail within a shadow and dep th visualization. I will explain this with a picture, to make you better understand what this is about (a picture can say more then a thousand words) To achieve real lifelike am bience shading/coloring, a 3D prog ram would need to calculate every aspect of the bounced light. This is time, processor and m em ory consum ing. This is why in m ost 3D programs the am bient light is evenly distributed to avoid extreme calculation times. Global ambience set on Global am bience set off (turn the ambient color to black RGB 0,0,0) From the exam ple on the previous page, you can see that a global ambient color can create loss in detail, the picture on the right hand s ide has far m ore detail in the shadow areas of the tree then the one on the left hand side. Of course it is still a m atter of taste which you like best, but the one on the right is more realistic in nature. (I have added a W B scene file to show what has been done to create the picture on the right. W ith this file you can experim ent yourself and see what can be done when you c hange light colors, change the strength of the light source and so on). In real life you will not see evenly distributed shading and this is why I am explaining a little bit about the am bient color setting. In W B, if you want to turn off global ambient lighting, you have to turn the am bient color to black (RGB 0,0,0). This way, there will be no light added to the scene other than the lights you add and position deliberately, and that are under your control. For the m om ent, we will not go into much further detail about this subject. At a later stage, you will see more information coming along on ambient settings when we go into shading a bit more deep. Am bient light property in W orld Builder Am bient light is a global adjustm ent for the Sc ene's lighting that effects the appearance of all surfaces . This is a nondirectional light that sim ulates the diffuse light found in most real environments. By adjusting RGB settings, you can set the brightness and color of the Ambient Light. This is an animatable param eter. R - An entry field and slider for setting the Red color com ponent. G - An entry field and slider for setting the Green color com ponent. B - An entry field and slider for setting the Blue color com ponent Glossary Before we start g oing into the real tutorial(s), I will give you an overview of what options and/or term inology there are in W B for the creation of shadows. Most of this, is also explained in the W B Help file and/or m anual. It is handy though to have this available without searching through the m anual/helpfile when using this tutorial. Z-Buffer: A rendered image containing depth information. A-Buffer: Gives us opportunity to get light shadows from transparent objects. Shadow properties available in WB light settings: (exam ple of prope rties for sh ado ws from a para llel light) Shadows: W orld Builder generates shadows using Shadow Maps. These are essentially renderings of the shadow casting objects from the point of view of the light source. Generate Map options determine when shadow maps are generated. Shadow maps take time to generate and you may not need to regenerate them each tim e a scene is rendered. If no objects have changed shape or position and no new objects have been added since the last render, there m ay not be any need to spend tim e generating a shadow map. Never: This means that the shadow map will not be generated when the scene is rendered. If you have previously rendered the scene with this shadow m ap set to generate, that shadow map is stored and will be reused even when Generate Map is set to Never. First Fram e: This means that the shadow m ap will be generated the next tim e the sc ene is rendered. After that, Generate Map is automatically set to Never. You would use First Frame to update the shadow map after making chang es to g eometry. Ev ery Frame: this means that the shadow m ap will be generated each tim e the sc ene is rendered. T his is appropriate if you are m aking frequent changes to the geom etry of the scene. Size: The amount of detail in a shadow map is controlled by the size of the shadow map. This is the width and height of the bitmap produced when a shadow map is generated. Higher numbers m ean more shadow detail but they also take longer to generate and use more memory when rendering. A shadow map that is too small will produce dark bands on the Landscape surface. Shadows Calculation options are m ethods of generating shadows. W hen casting shadows on large objects like Landscapes you will occasionally see artifacts such as dark stripes. Changing the shadow calculation method will often fix the problem. Intensity Interpolation: Interpolates calculated shadow intensity. T his method m ay result in undesirable effects such as moire patterns but it produces s oft shadows. This is the default method. Depth Interpolation: Interpolates depth to calculate shadow intensity. This method is unlikely produce moire patterns or other artifacts but it results in sharper shadow edge s. T his option doesn't work when A-Buffer shadows are ON. Combined Method: Average shadow intensity calculated by both previous methods. No Interpolation: Neither intensity no depth interpolation is performed. Use A-Buffer: A-Buffer methods are used for shadows calculations. This feature allows to reduce dram atically the shadow m ask dimensions without reducing the shadow details. In addition, the soft shadows cast by sem i-transparent objects will be obtained automatically when this option is ON. Add Extra details: Fractalizes shadow edges producing softer shadows Shadow Options: For parallel light sources in W orld Builder there is a possibility to have several shadow maps. In this case there are two variants of how the shadow maps will be combined. If the Choose by resolution option is checked, the shadow map with higher resolution will be chosen during computation of the shadow intensity. It is useful when you need a high resolution shadow for the objects in front of the cam era and the resolution of shadow for the distant objects is not so important. Another variant (when Choose by resolution option is not checked) different shadow maps will be simply com bined together. It is very useful when there is some moving object in the scene, for example a car, and you want to recalculate in each frame only the shadow from that car, without recalculating the shadow for the whole scene. It may greatly reduce the rendering time. Shadow view (parallel light example): You can change the area covered by the shadow map of a Parallel Light. This lets you direct the shadow to where it is needed and reduces the need for a huge shadow map to m aintain detail and prevent artifacts. Note that only those objects will cast shadows which are not selected in the Excluded Objects list. Use the general View Tools to manipulate (shift, zoom) the shadow view. Look at scene - click this button to automatically fit the shadow view the whole scene. Lock shadow view - if this control is checked, the shadow view will be automatically aimed at a group of objects (from a single object to the whole sc ene). This feature is especially useful when you want to get detailed shadows from som e objects while the light source or the objec ts themselves are animated (or they are under edition). Note that in this case the m anual shadow view manipulation is disabled. Important: To choose objects the shadow view is to be aim ed at, keep them unselected in the Excluded Objects list. Tip: If you like to get detailed shadows from Objects Sc attered in Area, you have to keep unselected both the Area and the Landscape (or another mesh) the Area belongs to. In this case the shadow view will be aimed at the area itself instead of the whole landscape. Rem em ber that if you exclude the landscape, the Objects Sc attered in Area will not be drawn. Shadow view (spot light exam ple):You can change the area covered by the shadow map of a Parallel Light. T his lets you direct the shadow to where it is needed and reduces the need for a huge shadow map to maintain detail and prevent artifacts. Use the general View T ools to m anipulate (shift, zoom ) the shadow view Shadow exc lude objects: Any objects tagged on this list will not be used to generate a shadow map. Tag objects on this instance of Object Tree by Ctrlclicking to tag individual objects and Shift-click to tag ranges of objects. Exclude Hidden Objects: Automatically excludes hidden object from shadow map rendering. Procedural Fake Shadow: Enables you to create a false shadow without using a light source. You can create a range of shadow patterns from sm ooth to dappled. You can also control the shadow density contrast, width and sharpness of the shadow pattern. You would used this in an Area beneath Grass or Plants to simulate the dappled patterns of dense plant shadows without spending the rendering time to calculate exact shadow locations. Scale, Details, Dens ity, Shadowness - directly correspond to the same properties of noise generator used in Clouds or Procedural Bumping. Contrast - determines the shadow contrast Shadow Opacity: Add this shader to an object to make it cast a soft shadow onto the other objects in the scene. The shadow softness is controlled by a single parameter Opacity just as in the ordinary Constant Opacity shader. Opacity set to 100 m akes the shadow very dark, while smaller values lead to soft, transparent shadows. Important Note: This feature works only if "Use A-Buffer" option is ON in the Shadow Options of the corresponding Light Source. If there are a num ber of light sources in the scene, shadows of the given object will be soft only from those sources , in which this option is chosen. Shadow opacity settings: settings range from 0..100. 0 being totally transparent and 100 being totally solid. I have set the transparency to 40, this will give a clear visible change for you to see what this shader actually does. In the example below this shader has been added to the bark of the tree, meaning that the tree trunk will have a more transparent shadow cast then the foliage of the tree. The foliage has no opacity shader added. Exam ple: picture of the Fir rendered with the A-buffer setting on and a Shadow opacity shader added to the tree trunk material (W hiteFir bark). You can clearly see the transparency of the shadow cast from the tree trunk com pared to the shadow of the foliage (which is solid). To check the settings of the opacity shader yourself, use the project file (base scene opacity shd.awb) that cam e with this tutorial. Shadow casting part 1. Now let’s s tart with the first part of the tutorial. I assum e that you have a basic understanding of the WB program, no special knowledge, just a basic understanding, that is all. I also assum e that you are using version 3.* of the WB program. Most of this tutorial will also work for version 2.*, some steps m ight be slightly different however and not all rendering modes mentioned are available. For version 2.* owners where AA (production) rendering is mentioned, use Z buffer rendering instead. W e will go throug h the basic creation of a s hadow cast from a tree (W hite Fir) on a landscape. I have provided a base scene that is setup with the tree mentioned, light source (used as sun), camera, compound sk y and of course the landsc ape (setup with a s imple procedural texture and a bum p m ap). For rendering the camera view, I will use the AA (production) render, unless m entioned otherwise. So startup your WB program and load the file “base scene.awb”. Your screen should now look something like this: (Example, screen layout of WB UI with scene loaded) Select the camera property from the property tree. Click the button from the main top menu to open the camera view , a new window will popup. Your cam era view. Click the button AA render from the main top menu. The cam era view window will start with rendering your scene. W hen the rendering is finished, your cam era view window should look something like this: You can see the landscape, sky and tree, but no apparent shadows are v isible. To get a shadow cast from the tree, we need to follow a couple of easy steps. Shadows are cast from a light source, so in order to get a shadow we will have to select the light source we want a shadow cast from . In this case this is easy, there is only one light source in the sc ene you loaded. Let’s select this from the property tree by clicking on it. Now you will see the light property settings becoming available and can start to adjust them to your needs. First of all, you can see that Shadow is set to OFF, right click on the item (a popup m enu will appear) select to enable shadow casting. If you would now render the cam era view window again, following the steps as before, you would get a rendered picture that looks something like this. There are shadows, they look not very realistically though. This is because the shadow view is setup from an extreme far distance (I have done this on purpose in the project file) and the map size is too small to get detail and realism from that distance. W hy would you do a project file with a messed up setup like this for shadow on purpose? W ell, it is to show that decent shadows do not come by them self. That when you might m ake chang es to a scene you are working on, shadows could get out of focus and mess up you scene all together. If you know how to adjust the shadows and make them look as you want, you will have at least one problem less. Now let’s start to work on the shadow to make it better than view settings. Zoom in on the tree using the area zoom tool from the bottom menu. Try to zoom in on the tree as close as you can. Look at the exam ple on the right hand side. it currently is. Go to the shadow You should make sure that you exclude the clouds from shadow map generation. The reason for this is simple, you have selected a relatively sm all area (the tree and some small surroundings)(this happened when zoom ing in on the tree) for shadow map generation. If you would include the clouds in the shadow map, clipping of the area in which clouds could be present, would occur and m ake the shadow look not realistic at all. How to hav e clouds c ast a shadow, is something we will go into later on. Now you should try and render again your cam era viewport. Before you do that, make s ure that your shadow map creation is set to First frame. After each render (when set to First Fram e) your shadow map generation is set to Never (look at the glossary of this item for m ore detail). Now render ag ain! Your camera view port render should now look much more realistic on shadows. The shadow shows now every bit of detail and is crisp in contours. It starts to look like there is som e real depth in this picture. Now you know how to create a shadow, but there is more! W e will go and have a look on what else we can do to m ake things even better and how to create shadows that suit your specific needs. Let us again go the shadow parameter s ettings panel and make som e changes to it. As you can see the Generate Map setting has gone to Never after the render, we need to reset it when we render again with different settings. Change the Size of the shadow m ap to 256, this is because we are using only a sm all area with 1 plant to cast a shadow. W e do not need a bigger m ap than 256, this will give enough details on the shadow and reduces calculation times. (you c an experiment with this setting and learn from the results you get) Click in the “add extra detail” to get Fractalizes edges on your shadow. This gives a m ore s mooth look to the shadow. Now render again. (do not forget to reset the Never to First Frame, otherwise the shadow map will not be recalculated and the old shadow map will be used instead) You can see a slig ht difference in the shadow being c ast from the tree. It has a bit m ore detail and is more soft on the edges. No major impact, but still on close up shadows the results can be am azing W e will now continue and add an other parameter to the shadow. Go back to the shadow parameters panel and click in “use a-buffer” Make sure to generate a new map like done before to get accurate results. W hat does the a-buffer do actually? W ell it adds calculated transparency to the shadow and thus g ive far m ore realistic results. Have a look in the glossary for more detail about the abuffer shadow. W hen you load the file “base scene a buff detail.awb), you will have a setup camera with a close up look of the tree base. Check all the settings on shadows as you have learned in the previous sec tions and then render the cam era view port. Your rendered picture should look som ething similar to this picture on the left hand side. If we look closely at this picture, we can see that the shadow has m ore variance in color and comes very close to the real thing, Transparency was added due to the a-buffer. There are still more things we can do to get even better shadows. For the time being I will leave the settings in the shadow parameter panel and go to a different area that has influence on the shadow casting. The light itself! W hen we have a closer look at the Light Param eters, you can see 3 items you can change. Intensity, Color and Linear diameter. W e will leave intensity and color alone and go to the Linear diameter. The default value for this is 0 and when it is left like that, the light produces sharp (crisp) shadows. If we up the value (within reason, look at the information the panel gives you) to 3, it will produce softer looking shadows. Not an overall soft look, but a calculated soft look, like in real life. A shadow cast at the base end of the object casting shadows, is always rather crisp, the further end is more smooth. Let us have a look on what a Linear diameter of 3 has on impact on the shadow. Render the cam era viewport again (make sure all settings are taken care of) You can clearly see the difference! Very sm ooth shadow casting at the far end and sharper ones nearby. You can also clearly see the transparency from the a-buffer. The foliage give a lighter shadow casting then the trunk of the tree does. You can play with the Linear diameter to get the results you want for your particular situation. W e will do one more render and set the Linear diameter to 1. I think for this particular situation that to be the one that looks best. It is a matter of taste of course, but I think the shadows do look very nice. Here we end the shadow map creation part for now. You have learned the basics and can experim ent with that. W e will now hav e a look at the shadow properties there are for the plant/tree itself. In all W B plants/trees there is an option to play with the foliage shadow. It is very simple to work with, but can produce am azing results under the right circumstances. Load the file that came with this tutorial called “foliage shadow.awb” Examine the file closely on the settings aspect. Do not change them until asked (except for the shadow map generation that is) in this tutorial, otherwise the res ults may end up different. In order to get to the shadow property of the tree/plant, you have to select the object from the property tree. Then in the object properties select Foliage density You can now see a new panel that gives you 2 options to play with. It also gives you a clear couple of tips on how to use this panel. W e are going to use the foliage shadow and leave it to 1 and then see what happens if we render the cam era viewport. Here you see the new tree (a nice Servian Spruc e) with a decent shadow cast to the landscape. W e have not used the a-buffer and not used the add extra details. W e know how this works from the previous exercises and you can experiment with them. Now we are g oing to put the foliage s hadow to a lower value and see what this does. Put the value of 0.3 in the panel for foliage shadow. Render the cam era viewport and look at the results of the change you made. You can see that the shadow density has decreased by a huge am ount, while the am ount of actual foliage rem ained the sam e. Here i have taken the sam e scene, added a grass area with 2 types of g rass and rendered it. You can see the shadow of the tree casting on the grass v ery nicely. I have included this scene file with the tutorial for you to play with. You can put into action all you have learned in the previous sections. Filename of the scene “ foliage shadow grass.awb” Here we stop for part 1 of this tutorial. There are plenty of settings to play around with for this mom ent. Shadows tutorial part 2 will go m ore into advanced aspects and more settings for shadows of other World Builder objects. I hope you enjoyed this tutorial and that it will help you to get the shadow results you are after.