So, past few months sorta sucked (January was bad because of work, then like 2-3 months of illness).
Spent the past couple weeks tracking down more stuff for model importing (I now actually understand the material data! big day). Got
so close to tracking down how the game does reflections (like in PSO!), and then it turned out that it doesn't actually because the component that would
use the reflection data doesn't exist. Oops.
I also spent some time trying to make the game do proper lighting! That was rather interesting. PSU runs on Direct3D 9 (fixed pipeline, it appears), so in theory, it supports
these three types of lights. The game only actually
uses the following:
2 directional lights for players
1 ambient light for players (and environments--I'll revisit this one)
2 directional lights for monsters
1 ambient light for monsters
Ambient light can be provided by any light type--you define the light directly generated by the light source, and then you define ambient light associated with it ("by having this light source present, every object receives this amount of light from all angles regardless of where the light source is"). The two ambient lights are actually created as directional lights.
You may have noticed that certain areas will have different lighting from other areas, despite being in the same map. This is done by changing the intensity of the first player directional light every frame based on the intensity associated with the current triangle the player character is standing on (based on a point in between its feet). Despite there being data that looks like it should do the same for the other player lights, that functionality does not actually exist.
Now, thanks to some help from Cydrith over on the Clementine side, I managed to find out where the game actually creates its light objects. This is done via a call to Direct3D's
SetLight function, passing in a
D3DLIGHT9 structure, replicated below:
typedef struct D3DLIGHT9 {
D3DLIGHTTYPE Type;
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Ambient;
D3DVECTOR Position;
D3DVECTOR Direction;
float Range;
float Falloff;
float Attenuation0;
float Attenuation1;
float Attenuation2;
float Theta;
float Phi;
} D3DLIGHT9, *LPD3DLIGHT;
Now, if you look at the docs, for directional lights (as mentioned before, PSU
only uses directional lights), only the Diffuse/Specular/Ambient and Direction values are used.
...However, the other fields
are populated. I haven't really tracked down where they're defined, but if you define a point light, the game will make sure it stays in the same position it started, even with the game world moving around. Of course, the game's got the light type hardcoded across the board, so it's mainly just a curiosity.
NOTE: These two things actually
are available but (as far as I know) largely unused:
1.
Specular highlights. As far as I can tell, these are never used because they're disabled two different places in the model file, but you can still make them work. Uncertain: specular map textures. One of the texture modes appears to take the current specular value as input, but I haven't investigated it too deeply.
2. A whole pile of (as far as I can tell) unused texture modes. The game lets you change the magnification/minification (read: zoom in/zoom out) filters, the filter used for going between mipmaps, and the color operation/alpha operation (this affects how the texture interacts with other textures on the same faces, as well as how they interact with lighting or vertex coloring).
So, long story short, mostly disappointments all around. Oh well.