This patch is for r566. I've reworked many things, some of which are still subject to revision as a result of guess-work and visual comparison.
Regarding the spotlight/lobelight properties:
- Spot position is expressed in screen pixel coordinates (as signed 13.3 fixed point, rounded float). This was hard to fix 'cause the only visual difference I noticed with the real thing was in this particular sequence (ECA):
- Spot ellipse dimensions (again in pixels) are a fraction of a fictional 2047x2047 mega screen, so are expressed as (part of) 16 bit values. This is hinted in the "Real3DPro1000ProductDescription", here:
The illumination pattern is an ellipse that can be scaled in the x and y directions. The maximum radius of the ellipse is 2047 pixels allowing the light lobe to cover adjacent displays.
The problem was that in the hidden debug menu of Scud and basically in 99% of the cases the dimensions nodes are filled with 0-255 values, making you think that at "255" spot is a point or have zero-dimension. By chance I've discovered that Magical Truck Adventure goes over that value reaching "2047" in a brief moment as soon you start a mission, where the yellow glowing sphere/portal appears and from which the 2 guys and the girl come out.
- I've truncated spotlight "start" parameter to the third decimal number. This avoids some crazy value especially in Star Wars. In some case could be < 0, meaning the light starts from "behind" the point of view. Before "start" value no object is spot-lighten.
- I've truncated spotlight "extent" parameter for the same reason as above. Again could be < 0 (skichamp) and if less than "start" it sets the new minimum "start" point.
- The decay begins from start+extent in seemingly inverse linear fashion, like hinted here (again "Real3DPro1000ProductDescription"):
The extent of the illumination (the distance from the illumination source to the point where the illumination declines) can be specified. The intensity of the illumination decreases as a function of the inverse distance from the eyepoint to each pixel when the extent of the light lobe has been reached.
The formula I've found working well is this:
- Code: Select all
// Reference: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation
decay = 1 / (d/r + 1)^2
where:
d = distance between the light’s surface and the point being shaded
r = the light’s radius
I've chosen arbitrarily to set "x" component of the spotlight ellipse as "r". This seems to scale globally the falloff distance as measure of the spot dimension.
- I've also added the spotlight-on-fog color parameter. That's used in light-on-fog (and scroll fog) calculations and sometimes can be different from the regular spotlight color. From the latter inherits the same elliptical shape and finally gets multiplied by the fog color(!).
(Continues on Part 2: Fog)