Monday, October 28, 2013


October 28, 2013

I watched a presentation given by the Oculus team at GDC last week. The emphasis was clearly on framerate and that it is the number one priority for developers.

Well... my focus has been on realism up to this point and my demo is a tad bit on the slow side unless your gaming rig breathes fire. This means I need to reduce the number of meshes on the screen but how do I do that? I can make my demo more and more scaled down or I can hide meshes based on performance/user-preference. I chose the later.

I just coded this last night so it still needs some work, but the initial results were super cool so I thought I'd share how to do it. Well... actually it blew me away. This code was able to hide 3000+ meshes instantaneously. I've never seen a map where you can make large portions of it just disappear. With the rift on it was incredible.

The easiest route is to bind a key to this code. I actually bound 3 keys to hide different meshes but we'll focus on just the "F" key since it is next to the movement keys.

In DefaultInput.ini:
1. Find this line and comment it out (semi colon in front)
2. Then add this line:

You will need a class that extends UTPlayerController.uc. I have already covered how to set up a sample set of code for custom footsteps. Read that first if you are unfamiliar with unrealscript. We will have a variable that holds the prior hide/show setting. the function HideMeshes will flip that setting and hide/show all meshes that are of the type you are looking for. In my case I wanted to hide all trailers of a specific type. You will need to change the meshClass to be your mesh.

This solution is based on what I found here:

As usual, the example in the forum didn't work but I beat the code into submission :)

Here you go:

Class CustomGamePlayerController extends UTPlayerController;

var bool bHideStackTrailers;

// You will need to change the meshClass to be your mesh.
exec function HideStackTrailers() {
    local StaticMesh meshClass;
    ClientMessage("HIDING TRAILERS");
     bHideStackTrailers = !bHideStackTrailers;
    meshClass = StaticMesh'ready_player_one.Meshes.trailer_a';
    ToggleStaticMeshActor(meshClass, bHideStackTrailers );

// Note that I also disable/enable the collision for the mesh
function ToggleStaticMeshActor(StaticMesh meshClass, bool hide) {
    local StaticMeshActor actor;
    foreach AllActors(class'StaticMeshActor', actor) {
        if (actor.StaticMeshComponent.StaticMesh == meshClass) {

Sunday, October 27, 2013

Creating a UDK Installer

Creating a UDK Installer
October 27, 2013

Creating an installer for my UDK demo turned out to be a lot more difficult that I imagined.

DirectX9 versus DirectX11
My first confusion was DirectX9/11. The installer only allows you to create a DirectX9 installation but my UDK Editor was running in DirectX11 AND certain foliage meshes would only display properly if I was in DirectX11. If you want force your game to run in directX11 you will need to pass a parameter into the UDK engine (I cover this below).

Configuration files
It turns out there are a 3 different configuration files for same settings. I found myself making configuration changes that would work when I ran Oculus from the editor but wouldn't work in the installation. Because I don't have the time to study all the configuration files/documentation to become a zen master I took the brute force approach of putting my settings in all 3 files for each setting.

Configuration Settings
Automatically load your map


Exit on escape DefaultInput.ini


Improved Appearance

MaxAnisotropy   = 4 -> 16
ResY            = 720 -> 800
ScreenPercentage= 100.000000 -> 150.000000 (200 TURNS 90% OF SCREEN BLACK)

Enabling Oculus Support


Installation Creation

Before creating your installation make sure you have fully built your map in the UDK Editor.

UDK Frontend
UDK comes with a tool called "Unreal Frontend". You will use this to create your installation executable. There isn't much you need to do here.

1. You'll want to create a new profile.
2. Select your map
3. In the launch items I added -dx11 to enable DirectX11 when the game comes up.
4. Click start.

Your executable can be found in c:\UDK\UDK-2013-03

Now test out your executable.

Thursday, October 24, 2013

My Setup II

My Setup II

October 24th, 2013

I thought I'd share a quick update of my setup. I have moved into our Tower Room as my office for work and Oculus development. I have Serena shades so that I can open/close all the shade via remote.

Shades open

Shades closed

Tuesday, October 22, 2013

Custom Footstep Sounds in UDK

Custom Footstep Sounds in UDK

October 22nd, 2013

Getting custom footsteps/jump/landing sounds working in UDK is anything but straight forward. I am going to provide you a complete working solution so that you do not have to struggle with this like I did.

First off, all examples I found on the web were incomplete/incorrect. Maybe it is because I am using a beta version of UDK for the Rift but the examples I found did not work. They got me going in the right direction but they didn't work.

Second, there is some weird code under the hood of UDK. Base classes making references to subclasses (that is a big no-no) and returning hardwired values for things.

I will provide code for this tomorrow.

Sound/Texture work

1. Create a sample sound.
I used quack from this website. It will need turned into 16bit/44100 wav.
(see prior blog entry for how to do this)

2. Import the sound into UDK
(see prior blog entry for how to do this)

3. Create a sound cue for the quack.
> right click in content browser and select 'new sound cue'.
> give the sound cue a name and press ok. This will take you into the sound cue editor.
> leave the editor open and return to the content browser
> select your sound (quack) and return to the sound cue editor
> right click in the sound cue editor and select 'SoundNodeWave: quack'
> connect the sound to the speaker and close the editor

4. Create a physical material to hold the "material name" you will associate with quack
> physical materials are special materials that the physx engine can use. In this case we are going to use it to reference the sound cue of the quack footsteps.
> right click in the content browser and select 'new physical material'
> give the physical material a name. I think the naming convention is ph_{name}. ex:ph_quack_material
> The last property is "Physical Material Property". click the blue arrow to the right and pick "UTPhysicalMaterialProperty".
> In the "Material Type" enter the "quack" for the value. This is the entry we will reference in the unrealscript code.

5. Assign the physical material to your "display material"
> Open the material you want to make noise when you walk on it.
> Expand the "Physical Material" section
> In the content browser select your physical material
> Return to the "physical material" of you texture material and assign the physical material by clicking the green arrow to the right of the "Phys Material" entry.
> close the texture material and you are done with the UDK editor part.

At this point you have a texture with the "quack" physical material associated with it. Now we need to get the unrealscript code in place.

UDK unrealscript prepwork

If you have never coded in unrealscript there is a bit of work involved to get your environment setup. There are a lot of tutorials that cover this topic in detail so I will be brief.

1. I recommend you fire up the UDK log when the editor comes up. It just saves you a lot of digging constantly for log files. In your executable shortcut (on the start button and/or desktop) add -log to the end of the executable target. Like this:
C:\UDK\UDK-2013-03\Binaries\UDKLift.exe editor -log
> You can use the log to look for log entries I have added to the custom code such as this:
> when you watch the log you should see my log entries. If so, you know you are on the right track.

2. You need to add a directory for your custom unrealscript code.
It will code here: C:\UDK\UDK-2013-03\Development\Src\
You will need a name for your project and a classes subdirectory. In the end it will look something like this: C:\UDK\UDK-2013-03\Development\Src\myproject\Classes
> All of your unrealscript custom code will go in that Classes directory

3. We need to let the unreal system know about your custom directory.
> open this is a text editor: UDK\UDKGame\Config\UDKEngine.ini
> In the [UnrealEd.EditorEngine] section add this entry at the bottom:

Adding code to make it work

We need 4 custom scripts/files to make this work

To make this is as simple as possible I have added them to gist:

Save these files in your Classes directory

Here is a brief overview of the 4 files/classes:

CustomGame.uc :
This is a new Game you are creating. It extends UTGame (a must) and overrides the damn SetGameType method. That was the secret sauce that took me days to sort out.

This is a controller for handling activity from the player.

This represents your player and other spawned characters. This forces the system to use your new sound class.

This is where the magic happens. All of the sound customization you need to do is right here. FootstepSounds, JumpingSounds & LandingSounds are arrays that hold possible sound mappings.
> MaterialType = the value you gave "Material Type" in the physical material in the UDK editor.
> This material type is mapped to a sound cue via this array.

You will need to edit CustomGameSoundGroup.uc. This is where you map the physical material so they make a noise. The line of interest is:

You will need to change the project name to match your project.

Compiling the code

The easiest way to compile the code is to let UDK do it for you. Because UDK knows about your code directory (via UDKEngine.ini change you made), it checks to see if anything in it has changed and needs compiled when it starts.

Restart the UDK editor and it will ask you to recompile the unrealscript. Hopefully you won't have any issues. Close that and restart the UDK editor again

Selecting your game

One of the classes you added is CustomGame. This will now be available to pick from within the UDK editor. Select CustomGame for your level in the menu item View:World-Properties

Add a mesh that uses your texture and walk on it. Voila! You have quacking.

Now you can adjust/add more sounds & physical materials and make them work by adjusting the code in CustomGameSoundGroup.

I know this is a lot of stuff and you may run into difficulties. I didn't feel like taking snapshots of all the steps. It was too much work. If you need help just comment on this blog and I'll do my best to help you you.

I have also referenced this tutorial in the UDK forum. You may want to check there too:

Saturday, October 19, 2013

UDK Sound

UDK Sound

September 19th, 2013

There are 3 types of sound in UDK:
1. Area sound effects
2. Sound effects that are a result of something the player does
3. Ambient Music

In this tutorial I will cover all three of these and explain how to implement them (I am learning as I go here).


The first thing you need to do is to convert your sound into something UDK can use.

Here are the recommended specs:
1. 16 bit
2. 44100 Hz.
3. wav file

You can find a ton of detail on that here:

There are a lot of solutions to convert sounds. Since I don't plan to make any money for the time being on what I am building I will use wavepad to covert sound files. It doesn't come with any crapware in the install which is a plus in my book.

1. Install & Open wavepad. You don't need any of the extras.

2. Open the batch converter by selecting Tools : Batch Converter...

3. Add your files/folders

4. I'm not positive this is necessary but I picked "Convert Sample Rate" and make sure it was 44100Hz.

5. Select "convert to file format" and pick ".wav". Then in the format options pick "Custom" and select "44100 Hz, 16bits, Stereo".
6. If you don't want to overwrite the original sound files pick a different folder.
7. Press "Next" and you are done.


This is really simple. Just right click in the content browser in UDK and import the sound. You probably want a folder dedicated to sounds within the content browser.


This type of sound is placed in your level and has a radius. You can control the radius, volume and drop off. You just need to drag the sound into your level and then you can adjust it.

For my level a part of it takes place 20+ stories in the air. I wanted the ambient sound of wind blowing at the top 5 stories. This required me to place multiple instances of the wind effect at the top so that no matter where the player went at the top of the level they would hear wind.


If you want a different sound based on where the player is walking the solution requires a bit more effort. There are several parts to doing this right:
1. changing your game type so you can actually hear sound from meshes you walk on
2. hiding the gun & hud (unless you want that stuff)
3. mapping a physical material with mapped sound to your UV material

Special thanks to this forum entry. It covered the gun/hud disable perfectly.

Changing your game type:
You need to switch your game type to utgame making it an unreal tournament game. This causes surfaces to generate sound when a player steps on them. 

1. Go to "View : World Properties".

 2. Within "Game Type" change the "Default Game Type" to utgame.

hiding the gun
To hide the gun you give the player no inventory. To hide the hud you need to do a bit of kismet.

1. Go to "View : World Properties" (see above)
2. Within "World Info" check "No Default Inventory For Player"

hiding the hud
1. Open UnrealKismet (the green K icon at the top on UDK)
2. Right click in kismet workspace
3. Select "New Event : Level Loaded".
4. Right click in kismet workspace
5. Select "New Action : Toggle : Toggle HUD"
6. Drag a wire from "Level Loaded : Beginning of Level" to "Toggle HUD : Hide"
7. Right click in kismet workspace
8. Select "New Variable : Player : Player"
9. Drag a wire from "Toggle HUD : Target (bottom)" to "Player"
When you are done it should look like this:

Mapping a physical material with mapped sound to your UV material
Finally, we need to associate a sound emitting physical material with your texture material that is on your mesh. This was a revelation to me. I had no idea there was such a thing as a physical material. This is a material that works with Unreal's PhysX physics engine. In this case the material is recognized by the game to produce a sound.

1. Open your texture material
2. Open the Physical Material section (see below)

3. Find an existing Physical Material for demonstration purposes
To keep things simple lets use a physical material that already exists: ph_metal. Open the content browser, select the UDKGame package and search for metal. Scroll down until you find PM_Metal. Note the PM prefix. This is telling you it is a Physical Material. Select the material

4. Click the Green Arrow to the right of the "Phys Material" property and voila. You have a texture material that will emit a metal sound when you walk on it.

Stay tuned for more...

Tuesday, October 15, 2013

The Dreaded Dark Landscape Issue

The Dreaded Dark Landscape Issue

October 15th, 2013

A few weeks ago I discovered that if I use the UDK foliage mode to add meshes to my landscape they turn black when I build lighting. This was when I discovered something called "UV Lightmaps". Not knowing about lightmaps until now was a huge mistake.

A UV Lightmap is a separate UV layer that tells UDK how to calculate lighting for a mesh. What you do is take each surface that shares lighting and separate it in the UV mapping from the other surfaces.

Currently none of my meshes have UV lightmaps. Unfortunately this includes models from Forester.

In this blog entry I will cover what is necessary to create a UV lightmap for a landscape element. I believe Forester is working to resolve the issue but in the meantime I am going to do it by hand for a few of the trees/grass I have.

1. Create your tree/grass in forester and import it into UDK applying the material to the mesh

2. We need to switch over to DirectX9 to create the lightmap otherwise it will error out:

3. Open the tree/grass mesh

4.  Select Mesh : "Generate Unique UVs..." from the menu

5. In the lower right corner you will have a dialog to generate the UV. Make sure you check "Pack UVs only". Click "Apply"

6. If you show the UV channels and go the second one you will have the new lightmap UV.

That's it. Now just do this for each tree/grass from Forester and you are good to go.

When you are all done switch back over to DirectX 11. Otherwise the foliage you add to your landscape will "flicker" or appear/disappear.

Blender Alpha Channel Madness

October 15th, 2013

When I was first learning blender I stumbled into getting alpha channel textures to display in the 3D view in Blender. I continued to use the same starting file / setup so I always get this behavior. Well I have built a new gaming / development computer and had to reinstall Blender on it. I soon discovered that this transparency / alpha channel display was anything but straight forward. It took me several hours to find the "secret sauce" to get this to work.

I found the answer near the bottom of this tutorial:

Here is the no-nonsense solution:
1. UV map texture onto object (see other tutorials on how to do this)

2. in the "3D View" press N
   > go to "Display" section
   > in shading pick singletexture or multitexture
   > check 'Textured Solid'

3. On the top menu bar change the engine used for rendering to "Blender Game".
   > the default value is "Blender Render"
   > this will enable a "hidden" game settings feature

4. In the "Properties" view select the "material" section/tab
   > go to "Game Settings" section
   > in "Alpha Blend" select "Alpha Blend"
   > if you want double sided uncheck "Backface Culling"

5. On the top menu bar change the engine used for rendering back to "Blender Render".