.wdb File Format (Part 3)

This covers the last of the structures found in the world.wdb files, which I call VCLight, though until quite recently it was called VCMystery. I’m not entirely sure it’s about lighting, I just can’t think of anything else it might be. It has the following structure:

Structure VCLight
  b0 As Byte		'unidentified byte, &H00, &H01, &H03, &H04
  b1 As Byte		'unidentified byte, always &H00
  b2 As Byte		'unidentified byte
  b3 As Byte		'unidentified byte
  b4 As Byte		'unidentified byte
  b5 As Byte		'unidentified byte
  b6 As Byte		'unidentified byte
  b7 As Byte		'unidentified byte, always &HFF
  s0 As Single		'unidentified IEEESP, always 1.0
  s1 As Single		'unidentified IEEESP, always 0.0
  s2 As Single		'unidentified IEEESP, always 0.0
  s3 As Single		'unidentified IEEESP
  s4 As Single		'unidentified IEEESP
End Structure

b0 is either &H00, &H01, &H03 or &H04.

b1 is always &H00.

B4, b5 and b6 usually have the same value, indicating that they might be colours.

b7 is always &HFF.

s0, s1, s2 are always (1.0, 0.0, 0.0), so look like a 3d vector.

s3, s4 are almost always (0.5, 0.4), except on three occasions:

  • fishbowl Node 5 (85.25, 44.0)
  • help Node 3 (74.75, 26.0)
  • paradiseisland Node 4 (113.75, 28.0)

These odd values always coincide with b0=3, though most b0=3 VCLight structures have the usual (0.5, 0.4) s3 and s4 values. They are indicated by the red digits in the table below.

There are clues in the V-Chat SDK document, which mentions “Microsoft Reality Labs general purpose rendering engine” and “RenderMorphics”. RenderMorphics Reality Lab was a 3D graphics API that was bought by Microsoft in 1995 and formed the basis for Direct3D, which first appeared as part of the DirectX 2.0 SDK. DirectX 2.0 implemented different types of light (Ambient, Directional, Parallel Point, Point and Spotlight). Trawling through the old SDK documentation unearths these _D3DRMLIGHTTYPE enumerations:

D3DRMLIGHT_AMBIENT = 0
D3DRMLIGHT_POINT = 1
D3DRMLIGHT_SPOT = 2
D3DRMLIGHT_DIRECTIONAL = 3
D3DRMLIGHT_PARALLELPOINT = 4

Its also worth noting that the VRML 1.0 standard that was around at the time had similar types of light node (DirectionalLight, PointLight and SpotLight).

As a starting point I am going to assume that these five basic types might have found their way into the .wdb file, though not necessarily with the same values.

Assuming b0 indicates the type of light, the number of each type appearing in each world is shown in the table:

Worldb0=0b0=1b0=3b0=4
basketballworld1
cartooncity
compass13
eurostadium1
fishbowl112
gallery1
hanami3
help11
homespace1
hutchspace11
kivaunderground1
kivaworld1
lavalovelounge1
littlehouse15
lobby1
lodge
lunarislands11
mall14
nshof1
outerworld1
paradiseisland111
redden1
standingstone1
tabletop11
theaterchat1
waterhole1
Number of VCLights by b0 Type in each world.wdb

Most worlds have just a single b0=0 light, and there is never more than one. Not only that, but it always lives in the first VCNode under an identity matrix, so has neither position nor location. This makes it a good candidate for an Ambient light. Only cartooncity, compass, hanami and lodge don’t have one. This is almost a fit with the VCTexDef.txb4 = &H01 worlds, with the addition of compass – though this is also the only world with a b0=1 light. So maybe this hints at some correspondence between material qualities and lighting type.

The b0=1 light in compass sits under what is in essence a translation matrix (it actually incorporates some axis-rearranging rotations, but there’s a few like that in compass). This is consistent with this being a Point or Parallel Point light i.e. its position matters, but not orientation.

The b0=3 lights sit beneath matrices with both translation and rotation. If both position and orientation matter, then this would indicate a Spot light. However, poking values into WDB files makes this look more like a DirectionalLight. In this implementation it has a position, but one that seems to be ignored by the renderer.

The b0=4 lights sit beneath translation matrices. Like the b0=1 light, this is consistent with this being a Point or Parallel Point light. There’s nothing in any of the world.wdb files that would allow the two to be distinguished. You could argue that parallel point lights are less computationally intensive, so might be used in preference to point lights. That would make b0=1 a Point light and b0=4 a Parallel Point light.

This is as far as I have got to date, but is enough to experiment with.

What do you think?