Post Categories

UDK Static Shadows on terrain

One of my pet peeves with UDK is the surprising quality of shadows as a default on terrain. Seen here is a sequence of images that simply goes over the process of shadows in UDK. I’m sure this is not a mystery to the folk at Epic games, after all the demo games that come with UDK are typically built with BSP brushes and meshes rather than relying on the overhead that comes with complex terrains, and it’s something to take note of.

Some starter info : I’m using a moonlit night, but I have turned down some defaults in UDK.

Under World Settings : I like to turn my Environment color way down, there is simply too much light bouncing around for me. So I set the color dark, and then I set the Environment Intensity down as well. This makes it much more shadowy in my worlds.

shadowWORLD_PROPS

For this test environment I’ve also turned off the default exponentialHeightFog, to keep the scene clear. The only thing I am altering in these renders are the lighting attributes on the Terrain.

NOTE : Although I will crank up the resolution of the shadow it is not recommended to do this for your game. This is A SIMPLE scene and merely to DEMONSTRATE the change in shadow quality, but real world tests of your game will show that this will not only be costly in time to bake your shadows, but also will create overhead in your maps that are loaded into memory.

FIRST RENDER : I set up a quick environment to show what shadows of my trees will look like on the default UDK ground. It’s passable, we have shadows out of the gate.

treeShadows_1

SECOND RENDER : I added a 16×16 terrain to my environment, and added a quick grass texture. There is no height change in this render, so it should be pretty clean. Now, to the new user of UDK this will look pretty promising. This is a render from the Editor window, but it’s deceptive and disappointing. When in editor mode our shadows are dynamic shadows, because they haven’t yet been rendered. To use dynamic shadows throughout our game would be very heavy in UE3 (we’re promised real time shadows in UE4).

treeShadows_EditorWin_1

Confusing to many who setup a scene in UDK and are seeing great shadows, is the surprise of going into game mode, and seeing your shadows evaporate. The reason can be found in the terrain’s settings. You can see the Static Lighting Resolution is super low, this line and the entry below it are what we want to focus on.

treeShadows_onTERRAIN_Default-SETTINGS

THIRD RENDER : Static Lighting 2 :
This is what the shadows look like after we bake out our lighting. There is simply not enough resolution someplace, so we lose any fidelity in our shadow renders. If we double click on the Terrain, our terrain Attributes will come up, and we can see the default static lighting Resolution is set to 2, and that Override is turned off. (Actually this is a mistake, the default is actually a more discouraging 1 – and that number can not exceed 4 without hitting Overriding Light Resolution. If overriding that number doesn’t make you nervous it should. You have reached a dilemma, and will face quality vs speed issues after that number goes up.)

treeShadows_onTERRAIN_Default

Now we can start doubling that number to 4 and 8, but our progress making better shadows will be slow. So we jump to Default Static Lighting : 16 However, before you type that in, make sure Overriding Light Resolution : is ON ! Otherwise it will bounce back to 4.

treeShadows_onTERRAIN_set16-SETTINGS

FOURTH RENDER : Static Lighting : 16
In this render we can see a great improvement in our shadows. Remember at this point to Play your game and make sure the shadows are the same as in the editor window.

treeShadows_onTERRAIN_set16

FIFTH RENDER : Static Lighting : 32
For this demonstration I’m doubling my numbers and keeping them power of two, but this will not be our end game, this is more about demonstration. We are seeing a much higher quality and I could live with this render and get back to other tasks. Still, I want to push it one more notch and see what I get.

treeShadows_onTERRAIN_set32

LAST RENDER : Static Lighting : 64
A thing to note is that I also turned on specular highlights on my terrain in the attributes, but here we can see a higher quality. It looks good. The trade off will be how much time I am willing to wait for shadows to bake to get better results.

treeShadows_onTERRAIN_set64

This tutorial was not meant to be an end all on the subject of shadows but I hope it gives guidance to the issue of what happens to terrain shadows, so that someone making a UDK game can consider some of the hidden things about UDK before proceeding too far in design. Shadows themselves are a complicated area, the information will vary for different types of objects. Terrain, static mesh, dynamic mesh all have different requirements. There is also a zone around the player which has dynamic shadows, and may be seen at times as it follows the player through the game, this is because you will have a near area in game you interact with in terms of lighting, casting your own shadow, or using a light that is carried in game).

One thing that is clear, for now in UE3 if you set your shadows to dynamic your game will not likely be able to handle shadows for long, although it will be tempting to use, you need to think smart about how to bake shadows, set up lighting UVs on objects and break your game up to make sure the lighting can still bake. Be careful how much you crank up that number for static shadows while you’re testing.

For the record : I am currently using a Static Lighting value of 10 in my game, but the results in overhead will vary depending on the size of your terrain, and the number of materials you use to paint your terrain. These numbers make my lighting too heavy to bake out daily while developing. I test small areas of my game by keeping my game areas as streaming levels, so that I can test parts of the whole and consider how to make my work, and game more efficient, while still trying to make the game look good.

UDK can be a very intuitive software to use, but shadows are a sticky point in UE3, that will challenge your patience as you wait for scene lighting to bake out. To me the end result is one of the most rewarding but lack of computer power for an Indie developer makes it one of the most challenging to deal with.

Leave a Reply

 

 

 

*