D2X-XL Worklog
Notes on features and problems from the development of D2X-XL, newest first.
Mesh Optimization |
|
Had you ever noticed that certain areas in Descent 2 levels were very dark despite some light source being close? The reason behind that is a peculiarity of the light calculation system employed in D2X-XL (and as I write this, of every other Descent 1 and Descent 2 version): Color values are assigned to each vertex (corner) of the faces composing a level, and the light colors of the face's pixels are interpolated (derived) from these vertex colors. For huge faces that means that even though the light source may be close to the face's surface, it may be quite far away from its vertices. As light decays with the distance, that means that the vertices (correctly) are quite darker than the light source. This however breaks the lighting for the face's center: Its color is derived from the (dark) vertex colors, so it will be pretty dark, too. There's two cures for this: True per pixel light calculation using shader programs - this requires quite a few changes in the D2X-XL renderer -
or splitting huge faces into smaller ones, increasing the number of vertices and thus always having some vertex close enough to any light source
in the level. While per pixel lighting certainly is an option This is particularly true with many light sources around, which brings me to another optimization. Currently, each shot fired by a gun is a separate light source. For shots fired in groups, like plasma blobs or laser bolts, this doesn't make much sense lighting wise as they are really close together. D2X-XL will therefore treat each group of related shots as a single light source with appropriate brightness. For quad lasers this will cut the number of light sources down to a quarter. Pictures are always good, so here are some picture from a test level with very huge faces (80x80) I have built, showing the mesh at the various improvement stages. The orange lines surround the original rectangular faces. Various mesh grids
![]() ![]() ![]() ![]() Lights at low, medium and high mesh qualities
![]() ![]() ![]() Gun shot at medium and high mesh qualities
![]() ![]() ![]() Now for the options |



, I decided to go for a mesh optimizer first. It took
me a few days to get it done, but the result is pretty pleasing. The only backdraw to this method is that the more vertices you add to a level,
the more work the lighting code has to perform, so depending on computer speed, level size and mesh quality you can really bring the
renderer down to a crawl.









. I am currently working on per pixel lighting and I believe I have taken the biggest
hurdles. Performance looks acceptable, and while there's still some work to be done, D2X-XL might offer true per pixel lighting in the near
future. Now does that sound like an incentive for a donation?