Lightmaps in Director

Quicklinks

Introduction go to top

Every now and then the question about lightmaps and/or multiple texture coordinates (UV sets) arises both on the dir-lists and the forums. Although Director 3D does supports models with multiple UV sets it is nowhere near as good as it should be. For example how multiple UV sets are handled in 3ds Max itself or i.e. Virtools. Adding a extra texture channel and texture in Director is absolutely no problem. It is getting and adding a correct 2nd UV set, preferably from out 3ds Max, that can be the hard part. Let’s keep hoping for a big Director 3D update with a new exporter and decent native support for multiple UV sets ;)

Most developers and hobbyist soon find out that you have to work with Directors “features” and work around the missing ones. This document is a workaround for adding lightmaps fast and easy. This is by no means a “wonder” solution. It comes with some serious downsides, but it has been a solution that has always worked for us, without any problems and great end results.

This “solution” is based upon a 3ds Max (8) script. It is not very complex and the theory behind could possibly be converted to other 3d packages as well.

How does it work? go to top

This part might be a bit technical and/or boring. If you want you can just skip ahead.

First of all, you can just model, unwrap and texture everything in 3ds Max as you usually do. You can add a second UV set and create your lightmaps with 3ds Max as well. I will not go into details about this, check the manual or some online tutorials on the subject. The script is actually just a macro recording of something that can be done manually as well. Although that can be a lot of work.

When you run the script all models will be triangulated. All vertices will be broken (each vertex will be broken into 3 new ones). This is only done to models with more than 1 UV channel. The 3ds Max export dialog will show up for the first time. You’ll export your file to a .w3d like you normally do. After this is done the script will copy the UV set of the second channel to the first one. Models with only one channel will be hidden. The 3ds Max export dialog will show up for a second time. Export to a .w3d file as normal. You can turn off a lot of features, because this file will only be used to retrieve the texture coordinates for the second channel. The hidden models will show up as groups in the .w3d file, but this is no problem. After the export you’re done in 3ds Max. Your model/world will probably look distorted so it might be a good idea to save before you export. I removed the auto undo from the script because it was a bit buggy initially.

You can save the “distorted” file, after exporting, for future exports of the second channel. No guarantees though, I had some troubles with this in the past. It almost seemed that 3ds Max had a different way of exporting models (vertex ID’s and positions) with each instance it was running. That is why this “double” exporting in a single click was made for originally.

There is one last thing I’d like to add. Obviously, some of you will now ask yourself the following question. “Why not only break the vertices that are needed to be broken? You’ll save yourself an unnecessary large data set of vertices. Which is slower etcetera etc.” Although I intentionally wanted to do this I soon found out that in most cases I would end up with all vertices broken anyway. Just because of the way you normally unwrap and texture your model. First channel tilling and the second channel an optimised unwrap with as least seams as possible. Furthermore, I noticed some odd export results in some circumstances with other techniques (i.e. breaking only necessary vertices using the unwrap UVW modifier). For example, a standard triangulated teapot has 1024 faces. When all vertices are broken it should have 3072 (1024 x 3) vertices. When the vertices were broken in the unwrap I ended up with more vertices (over 3100) in Director. This bothered me a bit and as you can understand for this technique to work the amount of vertices need to be exactly the same in both files. I couldn’t get this right with any other method. That is why the “breaking” is done. It’ll create a “correct” amount of vertices in all cases.

Advantages/Disadvantages go to top

Like I mentioned before there are some downsides when using this script or “solution”.
Let me first start of by mentioning the advantages so you won’t get scared ;)

Advantages

Disadvantages

How to use it? go to top

Files to download:

Ok, now how do you use it? I’ve already talked a lot so I’ll try to make this as short as possible. It is not very difficult anyway.

Installing the script.

Preparing and exporting your 3d model or 3d world.

Initializing and assigning the lightmaps.

It doesn’t work/I get errors/Other stuff.

Finally… go to top

So, finally at the end... I did write a lot more than I intended, but I’ll hope it’ll make the use of this “solution” clear. We do hope that people will have use for this method to create great looking 3d worlds and models in Director. Drop us a line if you do so! If some of you think we should add or correct something to this document. Probably a bug, error or some other vital information for the use of the script/method, don’t hesitate to contact me!

Good luck and have fun!