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!

Fixed shading

Postby Ian » Wed Mar 01, 2017 2:09 pm

I realised when testing dirt devils that the way we are using fixed shading is wrong

Some docs I wrote for myself
Code: Select all
            // step 1.5 hw (ie scud) only uses values of 0-127 (like the sdk)
            // so the code should read something like
            // float shade = (ix&0xFF)/127.f;
            // Using this the castle is perfectly shaded in scud. But other parts are too dark.

            // step 2.0+ h/w uses -128 -> +127. -128 maps to 0, and 127 maps to 1

            // There is some offset value which is added to the fixed shaded value that increases it's brightness
            // Scud uses it. In some cases you can see it pushes the value to like 1.5 so the textures are 50% overbright. Advanced course start.
            // Dirtdevils is also missing this offset value. But I can't find where it is.
            // Could be in the poly header, or in the viewport data maybe. Or possibly colour table ..


Anyway here are some debug images
I noticed with our current code the castle section is totally washed out. It should be much darker, with more contrast with the shaded areas.
All the non texture parts are using fixed shading (including the sky)

This is with the polygon colours, no other shading
Image

Fixed shaded values
(using 0-127) not -128 to 127
Image

Fixed shaded values multiplied by the poly colours
Image

The castle section looks correct. The sky which is using a different viewport is way too dark. Colours seem too dark, fixed shaded values also seem too dark. Multiplied together they are even darker.
I think there is some per viewport offset added to the fixed shaded value.

The parts in scud need an offset of 1 added to look correct.
In dirtdevils the fixed shaded parts under the bridge need 0.5 to look correct.
Ian
 
Posts: 1243
Joined: Tue Feb 23, 2016 9:23 am

Re: Fixed shading

Postby Bart » Thu Mar 02, 2017 8:08 am

Do any of the affected polygons have the texture translator offset bit set? Could this be what we are looking for? Also, the polygon RAM color tables store 4-byte entries but we only use 3. I think the 4th is almost always 0 or 0xFF but maybe it's worth checking to see if it ever differs.
User avatar
Bart
Site Admin
 
Posts: 2063
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Fixed shading

Postby Ian » Fri Mar 03, 2017 4:32 am

Scud may be correctly shaded with our current code. It's hard to tell brightness values from arcade footage.
But dirt devils is definitely too dark

I dumped the values of all the polys with fixed shading
And they looked like this

Code: Select all
val 42 translator 1 1.000000
val 127 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 42 translator 1 1.000000
val -128 translator 1 1.000000
val -59 translator 1 1.000000
val 25 translator 1 1.000000
val 42 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 8 translator 1 1.000000
val -59 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val 8 translator 1 1.000000
val -59 translator 1 1.000000
val -93 translator 1 1.000000
val 8 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val -128 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val -42 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 8 translator 1 1.000000
val 8 translator 1 1.000000
val 127 translator 1 1.000000
val 8 translator 1 1.000000
val 127 translator 1 1.000000
val -59 translator 1 1.000000
val 25 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 42 translator 1 1.000000
val -128 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val -42 translator 1 1.000000
val -128 translator 1 1.000000
val 25 translator 1 1.000000
val 25 translator 1 1.000000
val -110 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val -110 translator 1 1.000000
val -110 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val -110 translator 1 1.000000
val -110 translator 1 1.000000
val -128 translator 1 1.000000
val -110 translator 1 1.000000
val -110 translator 1 1.000000
val -128 translator 1 1.000000
val -110 translator 1 1.000000
val -42 translator 1 1.000000
val 8 translator 1 1.000000
val -93 translator 1 1.000000
val 8 translator 1 1.000000
val -93 translator 1 1.000000
val -93 translator 1 1.000000
val 8 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val -128 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val 127 translator 1 1.000000
val -128 translator 1 1.000000
val -128 translator 1 1.000000
val 127 translator 1 1.000000
val -128 translator 1 1.000000
val 127 translator 1 1.000000
val -128 translator 1 1.000000
val 127 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 1 1.000000
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496
val 0 translator 0 0.031496


All the polys without the translator map bit set have a different value.
Need to debug harly and see what that game is doing because it too uses the translator bit, although not sure it uses fixed shading
Ian
 
Posts: 1243
Joined: Tue Feb 23, 2016 9:23 am


Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 3 guests