[Patch] Fixed Shading

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

[Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 12:42 pm

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
Attachments
diff.zip
(1.48 KiB) Downloaded 49 times
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Thu Mar 16, 2017 2:01 pm

Tried it out. Basically seems to look fine :) I had wondered also about the viewport ambient value .. Need to simply the logic a bit :)
Ian
 
Posts: 1066
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 2:32 pm

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.
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 4:13 pm

Some before / after comparison:

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

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

mta1.jpeg
Magical Truck Adventure
mta1.jpeg (150.88 KiB) Viewed 1179 times
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 4:17 pm

Star Wars Trilogy:

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

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

swt3.jpeg
swt3.jpeg (169.94 KiB) Viewed 1180 times
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 4:29 pm

Dirt Devils:

dd1.jpeg
dd1.jpeg (144 KiB) Viewed 1176 times
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Thu Mar 16, 2017 4:55 pm

Dirt devils definitely looks closer to the arcade. Not sure if the others are too bright?
Ian
 
Posts: 1066
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 5:21 pm

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" ?
Last edited by HarryTuttle on Fri Mar 17, 2017 3:54 am, edited 2 times in total.
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Thu Mar 16, 2017 5:23 pm

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 1113 times

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

swt6.jpeg
swt6.jpeg (238.35 KiB) Viewed 1105 times
Last edited by HarryTuttle on Fri Mar 17, 2017 5:38 am, edited 2 times in total.
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Fri Mar 17, 2017 5:14 am

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.
Ian
 
Posts: 1066
Joined: Tue Feb 23, 2016 9:23 am

Next

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest