Adjusting shadows through light environments

We mentioned that there are three main light types in UDK: an Emissive component, static and dynamic light actors , and a Light Environment. Light Environments apply to InterpActors, RigidBody actors, and SkeletalMeshes. Every InterpActor (aka Mover) and KActor (aka RigidBody) has a dynamic light environment by default. Light environments provide level designers with an automated way of controlling dynamic lighting by approximating the effect of relevant static lights. With that in mind, this recipe gives a guided tour of light environment staging in a scene so a SkeletalMesh can be lit dynamically in a way that reduces harsh shadows.

Getting ready

Load the provided map Packt_08_LightEnvironment_Start.UDK. This scene shows a small enclosure with a DominantDirectionalLight (Sun), a Skydome, and some weak fill lights. The next screenshot shows the scene, and the XYZ axis is the location of the DominantDirectionalLight as it shines along its X axis, tilted down over the walls. In the light properties, Light Shafts are enabled. This scene is fairly empty, and we're just going to add some SkeletalMeshes to examine the Light Environment settings.

Getting ready

How to do it...

  1. From the Content Browser drag an instance of Packt.Mesh.Packt_SkinTailFBX. Place copies in each of the four wall spaces like the one shown below. Keep them all selected at once and press F4.
  2. In the SkeletalMesh properties assign the appropriate Physics Asset from the Content Browser. The Packt_SkinTailFBX asset uses Packt.Mesh.Packt_Character_Physics. Look in the properties for the Physics Asset channel. There, press the assign icon [ How to do it... ] with Packt_SkinTailFBX highlighted in the Content Browser. In theory, this improves the shadow casting calculation and at least it removes a build performance warning.
    How to do it...
  3. In the next screenshot you can see the expanded properties of the Packt_SkinTailFBX SkeletalMesh actor.
  4. With all the SkeletalMeshes selected choose Lock Selected Actors [ How to do it... ] from the Properties window icons.
    How to do it...
  5. Once the mesh properties are locked, or pinned, select the DominantDirectionalLight in the scene (it is probably easiest to search for it using Edit | Find Actors) and expose its properties too. Under Light Component make sure Cast Composite Shadow is ticked on. Under Light Component | Lighting Channels make sure Dynamic and Composite Dynamic are turned on.
  6. Under the SkeletalMesh properties turn off Use Boolean Environment Shadowing . Turn on Synthesize SHLight.

    Note

    The next screenshot shows comparisons in the editor of these properties in different combinations. The first uses the defaults Use Boolean Environment Shadowing on, and Synthesize SHLight off. The second uses Boolean Environment Shadowing off, and Synthesize SHLight off. This causes a shadow to fall across the body from the scene that isn't shown in the quick computation of the Boolean setting. Notice the darkness of the dynamic shadow. The third: Use Boolean Environment Shadowing off, and Synthesize SHLight on. Notice the fill light that now appears, and the internal shadow on the character is lighter. The cast shadow is still very dark.

    How to do it...
  7. Now that the meshes have their settings in place, go to the main editor's View menu and choose World Properties. Scroll down to the Light Environment section, and examine the globals there that allow you to adjust the brightness, contrast, and indirect brightness and contrast. For the most part these values range between 0.5 and 5.0. I chose 1.
  8. The shadows cast from the character are very black. To fix this, select the DominantDirectionalLight and expand its Light Component | Light Component | Mod Shadow Color properties, which are below the Lighting Channels section.
  9. Set the Light Shadow Mode to LightShadow_Normal. This is important because otherwise the modulated shadows multiply against the background and go black when rebuilding lighting.
  10. Set the Mod Shadow Color so the Alpha A is about 0.75 (or close to the static shadow darkness) and set the Shadow Filter Quality to High. Depending on your scene, and here it is unlikely to matter, you can set the Min and Max Shadow Resolution to force a certain level of quality, for instance making both to be 1024 will force a set shadow resolution. If you set a Max of 1024 and a Min of 2.0 and in game walk backwards away from the cast shadow you can watch it changing resolution based on the distance.
  11. A limitation of the shadows cast this way is that you will get a drop-out of the shadow if the camera goes far enough away from the actor. This is obviously an optimization step. A way to fix it is to set the property Shadow Fade Resolution in the Dominant Directional Light to 2.0; this is very small, and therefore the dropping out will be less likely to occur.
    How to do it...

How it works...

The previous screenshot shows a dark, unpleasantly heavy shadow on the left. That is the default for a dynamic object. On the right, the effect of adding a light environment for the actor is clearly more subtle. A Light Environment pertains to a specific actor. From the static and dynamic lights that affect it, the lighting is reproduced for the object with a fixed rendering cost. This approximation is done using a spherical harmonic light and a directional light . A quick explanation is that spherical harmonics are part of a solution to Laplace's equation. Spherical harmonics help game developers code lighting complexity. For those with a coding bent, it may open your eyes to some CG math. An explanation of this can be found at http://www.research.scea.com/gdc2003/spherical-harmonic-lighting.pdf. Epic Games provides documentation about Light Environments and some common troubleshooting: http://udn.epicgames.com/Three/LightEnvironments.html.

An important thing to consider is that this method discards lights from the scene that don't affect the model, does a kind of fuzzing of light from those that do, to simulate light bounces, and then creates a direct light in favor of the strongest incident light affecting the model to produce a key light effect.

Light Environments can be told to cast a shadow (from the direct light only) which is based on the scene lights the spherical harmonics are derived from, if they happen to be casting a shadow already. A limitation of this is that if you enable shadows for it, and there are no shadows in the derivation source lights, then the resulting shadow will go straight down.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.25.112