Page 1 of 8

[Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 12:42 pm
by HarryTuttle
I'm purely speculating, after observing and "playing" with numbers, that fixed shading is not entirely an alternative to sun lighting like the devguide hints, instead substitutes the diffuse part, retaining the ambient value that, I think, is crucial to determinate the formula and the offsets applied to the "x" component of the fixed shaded vertex normal.

Following and expanding Ian's considerations about the different Model Step revision behavior I've compiled a list of fixed shaded polygon "states" that modify the "x" value, as summarized below:
Code: Select all
// for Step 2.x

1) Illuminated
 a) AmbientLight >= 0.5
 b) AmbientLight < 0.5

2) Self-Illuminated
 a) AmbientLight >= 0.5
 b) AmbientLight < 0.5

// for Step 1.5

// Model 3 Step 1.5 doesn't seem to use TranslatorMap.
1) Illuminated
 a) AmbientLight >= 0.5
 b) AmbientLight < 0.5

2) Self-Illuminated // Seems to always use the same value independent of AmbientLIght

// for Step 1.0

// Model 3 Step 1.0 doesn't seem to use Fixed Shading at all.
// VF3, VF3TB actually set the FS bit and transparency level > 32 for
// a lot of discarded polygons. Probably junk polys anyway.


As you'll see in my code, my "brute-force-like" approach is to check every state combination before i try to simplify it's logic. Someone smarter than me can see something in that "kabala" of numbers. Anyway, as it is, it just works. I'll post later some comparative screenshots.

Note to Ian:
- I've used an horrible hack (global variable) to pass the ambient light value to the fixed shading check condition, It's not meant to remain like this.
- I've slightly changed the polygon color assignment function to check for translatorMap after the first check for "direct RGB" / "color index", so is no more only a sub-type of direct RGB.
- I've double checked everything, but testing is needed to definitely confirm those values.

*WARNING* ugly code ahead...

UPDATE #1:
uploaded new patch with a quick fix for Magical Truck Adventure

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 2:01 pm
by Ian
Tried it out. Basically seems to look fine :) I had wondered also about the viewport ambient value .. Need to simply the logic a bit :)

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 2:32 pm
by HarryTuttle
Ian wrote:Tried it out. Basically seems to look fine :) I had wondered also about the viewport ambient value .. Need to simply the logic a bit :)


Yeah, it needs badly... :)

I'm still testing, later I'll post some screenshots.

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 4:13 pm
by HarryTuttle
Some before / after comparison:

lam1.jpeg
L.A. Machineguns
lam1.jpeg (231.34 KiB) Viewed 12649 times

lam2.jpeg
L.A. Machineguns
lam2.jpeg (222.07 KiB) Viewed 12649 times

mta1.jpeg
Magical Truck Adventure
mta1.jpeg (150.88 KiB) Viewed 12649 times

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 4:17 pm
by HarryTuttle
Star Wars Trilogy:

swt1.jpeg
swt1.jpeg (180.99 KiB) Viewed 12650 times

swt2.jpeg
swt2.jpeg (133.4 KiB) Viewed 12650 times

swt3.jpeg
swt3.jpeg (169.94 KiB) Viewed 12650 times

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 4:29 pm
by HarryTuttle
Dirt Devils:

dd1.jpeg
dd1.jpeg (144 KiB) Viewed 12646 times

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 4:55 pm
by Ian
Dirt devils definitely looks closer to the arcade. Not sure if the others are too bright?

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 5:21 pm
by HarryTuttle
Ian wrote:Dirt devils definitely looks closer to the arcade. Not sure if the others are too bright?

I've checked everything with actual footage, adjusting the overall image gamma of Supermodel.

- Magical Truck Adventure has the ground visible under rails.
- L.A. Machineguns should be correct considering that the footage i saw is really over-brightened, i think the whole game's is somewhat very illuminated. There're also little shadowed details in Las Vegas that were completely black.
- Star Wars Trilogy is definitely correct, especially the death star reactor final level and the escape sequence. The Endor forest has the shadows near the trees' base and not the way around.

Anyway tomorrow I'll make another global check, as I've a doubt regarding this:
Code: Select all
// Step 2.x Self-Illuminated case
shade = vp_ambient + (float)(128 + (INT8)(ix & 0xFF)) / 255.0f; // should be "vp_ambient" or "1.0" ?

Re: [Patch] Fixed Shading

PostPosted: Thu Mar 16, 2017 5:23 pm
by HarryTuttle
Edit: here they are, some comparative screens with arcade versions.

What's important here is the overall image brightness/contrast and relative brightness of the single elements side-to-side. If there's nothing "too off" we could assume that's correct.

Star Wars Trilogy
Left: Abe's video capture, Right: Supermodel post-processed (blur/gamma/temperature/vignette):
swt4.jpeg
swt4.jpeg (245.59 KiB) Viewed 12583 times

swt5.jpeg
swt5.jpeg (217.38 KiB) Viewed 12580 times

swt6.jpeg
swt6.jpeg (238.35 KiB) Viewed 12575 times

Re: [Patch] Fixed Shading

PostPosted: Fri Mar 17, 2017 5:14 am
by Ian
Definitely looks closer to the arcade
Not really played star wars, wasn't even aware it used fixed shading!
The comparisons with the real hw are definitely useful.