Tutorial: How to get an accurate sun path into the UDK from MAX

Okay, so this is pretty hackey, but it works great. One day, I'll have the time to implement a real sun/sky system with actual math but for now it will just have to do. Really, I'm just stealing the animation of a Daylight system in MAX and rigging a light to it in UDK. There's a couple of tricks to make authoring in the UDK easier as well as some thoughts on how I can expand the system in the future. I won't be discussing the details of the sun and sky to create convincing sunrise effects, just the way I got the camera path into the UDK.

  1. In MAX, create a Daylight System. I use the Create drop-down:
    You're gonna get a ton of messages about lights and render settings. None of them mean anything for us so it shouldn't matter what you press. I pressed No.
  2. Center the compas rose on 0,0,0
  3. Select the light element of your Daylight System, go to the Motion Tab in your Command Pannel and set the location of your project
  4.  Also, setup the date you want to simulate. I chose mid-summer since I wanted a lot of daytime and a nice, long arc with a high zenith at noon.
  5. Next, set the duration of your timeline to the following:
    1. This gives you 24 seconds of animation. This is going to make our Matinee setup way easier.
  6. Set the time to 0:0:0, enable Set Key and set an initial keyframe at fame #1.
  7. Set the time slider to frame 720, set the time to 23:59:59 and set another keyframe.
  8.  Now, we'll convert the trajectory of the light into a spline:
  9.  Create a box, and a bone dummy at 0,0,0. Apply a Skin modifier to the box and select the Dummy
  10.  Select the dummy and set the Position Controller to a Path Constraint and the rotation to a LookAt Constraint.
  11. Set the Path Constraint to the newly created spline and the LookAt Constraint to the compas rose. If MAX is behaving well, your sun and box will be completely synch'd and will loop endlessly. If not, be sure to set your cives to linear so there's no ease in and out.
  12. Look at us! Ready to export. I've basically completely dropped ActorX and use Filmbox for everything. For this export, we want to make suer we bake out our animation as UDK/FBX aren't too keen on strange constraints like LookAt and Path Constraint.
  13. INto the UDK! For this tutorial, we'll use one of the default levels. As a rule, I don't use these levels to create production maps, however it's got the sun and sky all ready to go and will save us all that.
  14. First, replace the DominantDirectionalLight with a DominantDirectionalMoveable light.
  15. Reset the Location and set the Pitch to 90 (Straight down)
  16. Import our animation using the following settings:
  17. You should get a SkeletalMesh and an AnimSet with the import.
  18. In the AnimSet, be sure to turn off the Rotation Only setting, otherwise the root bone can't translate away from the origin.
  19. Next, we'll add out skeletal mesh box to the scene.
  20. Set the location and rotation of the box to 0 and type in the name of the animation from the imported animSet.
  21. Next, we'll attach our sun to the box. Open up the Attachment manager and connect the sun to the bone in our skeletalMesh.
    1. Now, if you move the box, the light moves too. I think you're seeing where we're going with this. 
  22. Next set up the Matinee. With your box selected, open a new Matinee and create a Skeletal mesh Group. Assign the imported AnimSet to the group.
  23.  On the Anim track, hit Enter and select the AnimSequence from the dropdown (there should only be the one, unless you're getting ahead of the class)
  24. Wham! Now, when you scrub you should see your sun moving! The reason we set up 720 frames in MAX is illustrated below. By making each second in Matinee represent 1 hour, we get 24 seconds. That gives us a very easy-to read clock:
    Now, all that's left is to add in all your fogs, skylights, directional lights and sky materials to the matinee to get the right look and feel for each time of day.


  1. Hey thanks, this is great. I have a question though. What can be done about the shadows that get weird when the sun is setting and rising?

  2. Not much! You can do some ini settings to help smooth out the dimpling, but at some performance cost. I cheat and leave a lot of my early morning lighting to the skylight before turning up the sun intensity, that helps get rid of the most exaggerated of the shadow issues.


Post a Comment