Ian wrote:So what do you think the correct formula is?
I really think it's this:
- Code: Select all
shade = 1.f + (float)((UINT8)(ix & 0xFF)) / 128.f;
I can also confirm all the values for Step 1.5, I've just finished to re-check all the Scud race videos and made many other comparisons.
I'm also quite sure about Step 2.x self-illuminated, I'm checking right now illuminated polys. Also TranslatorMap seems to not affect the choice of the formulae.
So basically it's the ambient light that "decides", once the threshold of 0.5 is reached.
I tried this one with scud .. and it was definitely too bright.
Fixed shading is supposed to be easy. You set a fixed brightness value for the vertex and done. But it gets a bit more complex since the poly colour is always multiplied by the vertex brightness. And the colour itself can modulate the brightness for the final poly, ie if you set a black value.
So, so far we get the simple forumula
FinalColour.r = FixedShade * polyColour.r
FinalColour.g = FixedShade * polyColour.g
FinalColour.b = FixedShade * polyColour.b
As far as I can tell this looks correct for most things that used fixed shading. Except for scud, large parts of the game look way too dark. The sky, signs, everything. Examining these polygons the colour values are always less than 1. But not only that the fixed shade values are also less than one. Multiplying these two together the brightness is even darker.
If you look at the building, it's over bright. That's impossible with our current formula. Even if fixed shade was 100% and the colour was white, it still wouldn't come out that bright. All these polys are marked with a different flag, lighting enabled or disabled, i forget which.
With these polys if you assume the formula is instead
FinalColour.r = FixedShade + polyColour.r
FinalColour.g = FixedShade + polyColour.g
FinalColour.b = FixedShade + polyColour.b
This is basically how the current code works. This seems to look more or less perfect for scud. Actually I thought the castle section might be darker in the original arcade or with more contrast. But it's more or less correct.
This also looks correct for LA machine guns which makes heavy use of fixed shading, basically everywhere.
What threw me most was dirt devils, it looks mostly correct, except the part under the bridge. It needs a value of 0.5 added to it. Which lead me to speculate the fixed shade value could have been ofset by something else. But I've totally failed to work out what exactly. What looks correct for dirt devils, then breaks all other games.