Twitter  Facebook  YouTube  E-Mail  RSS
The One Man MMO Project
The story of a lone developer's quest to build an online world :: MMO programming, design, and industry commentary
Programming Rules to Live By #19
By Robert Basler on 2011-09-13 14:21:43
Homepage: email:one at onemanmmo dot com

Never mix data from more than one code path.

I've had a problem with my lighting for a while - I get ugly bright streaks where world blocks are stitched together. I knew there had to be some problem with the normals (I'm using simple n dot l lighting for the world) but when I looked at the code, I just couldn't see the problem.

Some of the lighting normals are precalculated, some are calculated at runtime. I did this to keep the size of the data down. With all the normals in the data, the size of the world data grows from 363MB to a whopping 1.46GB. Way more than I wanted to have to pay for people to download. Precalculating some of the data ahead of time and some at runtime shouldn't be a problem, however I had two different code paths that calculated those normals. Hmmm.

The two code paths look virtually identical if you diff them, but there are unavoidable differences. I know I should have just one code path, but there are parts of the code needed for the world builder tool that I can't have end up in the game client.

After much puzzling over the static code, I finally resorted to having both code paths build the full set of normal data and diff the calculation (at about 40 minutes of calculation per try.)

The diffs showed up two surprising differences. In the world building tool, the vertex coordinates used to build the normals were offset by a fixed value from those on the client. That shouldn't affect the normals but it was still a difference in the calculation.

The big difference in the normals came from the fact that the world building tool had full accuracy data to build normals from, but in the client, the source data was quantized. The difference in the coordinates was less than a centimetre, but it affected the lighting in a visible way.

New Comment

Cookie Warning

We were unable to retrieve our cookie from your web browser. If pressing F5 once to reload this page does not get rid of this message, please read this to learn more.

You will not be able to post until you resolve this problem.

Comment (You can use HTML, but please double-check web link URLs and HTML tags!)
Your Name
Homepage (optional, don't include http://)
Email (optional, but automatically spam protected so please do)
What is 5 multiplied by 1? (What's this?)

  Admin Log In

[The Imperial Realm :: Miranda] [Blog] [Gallery] [About]
Terms Of Use & Privacy Policy