[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!

Re: [Patch] Fixed Shading

Postby HarryTuttle » Fri Jun 16, 2017 8:40 am

My first approach was that fixed shading doesn't automatically exclude lightning, so that doesn't take in consideration ph.LightEnabled() value. For what is saw the contrary is true.

So I tested fixed shading polys in both illuminated and self-illuminated cases. The values that I found seem to always work.

My only problem is how similar are in respect to the arcade counterpart. We know that sometime (L.A. M.) we have incorrect viewport sun light values and only in some scenes. Well, that will influence fixed shading when using ambient values.

We also know that some object in the same viewport has scaled down normals, the "x" component of which could give an erroneous value for fixed shading.

EDIT:
I forgot to say an important thing: every value I'm talking about is the "shade" one, that is the value that is later multiplied by the polygon color.
User avatar
HarryTuttle
 
Posts: 520
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Sat Jun 17, 2017 2:33 am

HarryTuttle wrote:Some before / after comparison:

Image


This is LA machin guns running under dolphin
Image

It's quite a good colour match since it's not recorded off CRT or something funky .. Seems to look pretty close to current supermodel. Although the actual arcade could be different. Can't find any good quality footage.
Ian
 
Posts: 1175
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Sun Jun 18, 2017 3:44 am

Usually I prefer to not compare against ported versions, there could be some misleading differences with the original arcade.

This is a list of what I've found on youtube (some have s****y quality, but other are decent):

https://www.youtube.com/watch?v=rw5XbsKP2jo
https://www.youtube.com/watch?v=CI-4pOrQPKI
https://www.youtube.com/watch?v=ruGvg-h2z6M
https://www.youtube.com/watch?v=bThWr9jz-QI
https://www.youtube.com/watch?v=eYpGC9iQ2-E
https://www.youtube.com/watch?v=pyy4nOqaM9M
(the above are from the same account)

https://www.youtube.com/watch?v=Df-yzUkxt_k

https://www.youtube.com/watch?v=g7Tr9BKrYOY

https://www.youtube.com/watch?v=_gr1sYBK1Mw
https://www.youtube.com/watch?v=Bg2Pe61DA7k
https://www.youtube.com/watch?v=d5EGI4jbTp8
https://www.youtube.com/watch?v=HQcSdUShH48
https://www.youtube.com/watch?v=L1DgaazrFZM
https://www.youtube.com/watch?v=-F1FZDVCESo
https://www.youtube.com/watch?v=WYdHclYe7H8
(the above are from the same account)

https://www.youtube.com/watch?v=oEf04ks6KJc
https://www.youtube.com/watch?v=9r1ccrXmUj4
https://www.youtube.com/watch?v=Qv57KgLm7Qg
https://www.youtube.com/watch?v=j4xnC3fpOrM
https://www.youtube.com/watch?v=gVCU6Xr1WCQ
https://www.youtube.com/watch?v=ae0Y7vgoOGs
(the above are from the same account)

https://www.youtube.com/watch?v=X6d1o3awXzI

https://www.youtube.com/watch?v=J_-R78qsKfI
https://www.youtube.com/watch?v=jiZLoDXFDss
https://www.youtube.com/watch?v=ovngeN0HezI
https://www.youtube.com/watch?v=DIisnYpqJRE
https://www.youtube.com/watch?v=T3C-wFInh2E
https://www.youtube.com/watch?v=zDtgMXN2T-o
(the above are from the same account)

Sadly a youtuber called icuk7 has removed the only video of L.A. M. he got (uploaded in january). Incidentally it was one of the very few around with good quality. Lucky me I've a local copy downloaded months ago. :)
Last edited by HarryTuttle on Sun Jun 18, 2017 7:02 am, edited 1 time in total.
User avatar
HarryTuttle
 
Posts: 520
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Sun Jun 18, 2017 4:46 am

This is the best arcade quality footage I found

Image
Ian
 
Posts: 1175
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby Ian » Sun Jun 18, 2017 1:22 pm

Harry,
have you ever looked at the fixed shading in this part of scud? I think it might gives us some clues to the missing offset
Have close look at the brightness of the wall, it changes as the car goes around the corner.

Bright wall
Image

Suddenly gone darker
Image

Side by side comparison
Image

Video of it here
https://www.youtube.com/watch?v=qrJkQ9e9uwQ#t=11m22s

This offset can't be in the poly headers themselves as they are (I think ROM models and are fixed)
So it must be something either in the culling nodes (possibly) or the viewport itself (more likely).
This change in brightness here has puzzled me for a long time ..
Ian
 
Posts: 1175
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Mon Jun 19, 2017 9:25 am

Ian wrote:Harry,
have you ever looked at the fixed shading in this part of scud?


Yes. And that part exactly was one of my reference to find the right fixed shading values. In particular I watched the lightning of the wall, the road and the inclined plane between them.

The variation is caused by sunlight dynamically changing direction as you pass by. I remember the same happens on the first course after the dolphin tunnel.

Anyway that video is from Abe, he has also uploaded on Mega the much higher quality version. He posted the link for all his videos somewhere in this forum.
User avatar
HarryTuttle
 
Posts: 520
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Tue Jun 20, 2017 6:50 am

Gonna do some more digging tonight
But you are probably right that the viewport ambient plays a role. It makes no sense (to me) that it does this. But i've explored almost every other option.
I did a binary diff on the viewports before and after the lighting changed in scud, and besides the light angle and brightness values, only the fog value changed. The whole castle section in scud that clearly uses some different fixed shading values, just so happens to exist in its own viewport, which it's own lighting values.

It's possible something in the culling nodes might effect fixed shading, but probably unlikely
Ian
 
Posts: 1175
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Wed Jun 21, 2017 2:09 am

HarryTuttle wrote:The variation is caused by sunlight dynamically changing direction as you pass by.

My bad, after a second check I have to correct that statement, there's no variation in that particular case (the wall). I think that's an artifact caused by the capture hardware.

I remember that part gave me much headache and it was hard to find the right values for fixed shading. But at least it seems that for step 1.5 hw the formula for the "shade" component is:

(fixed shaded polys)
- illuminated = ambient + (float)((UINT8)(ix & 0x7F)) / 127.0f
- self-illuminated = 2.0f

(sun shaded polys)
- self-illuminated = 1.5f
User avatar
HarryTuttle
 
Posts: 520
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Wed Jun 21, 2017 10:06 am

Have a go with my current build. It's still not finished, I need to figure out exactly what the hw is doing with regards to vp ambient with 2.x hw.
But currently it's as close as I can get it
Ian
 
Posts: 1175
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby Ian » Thu Jun 22, 2017 3:08 am

I have a feeling with step 2.x hw that the viewport ambient with unsigned values is simply the min value

so unsigned

shade = std::max(vpAmbient,shade)

signed version

shade = std::max(1-vpAmbient, shade)

Needs more testing ..
Ian
 
Posts: 1175
Joined: Tue Feb 23, 2016 9:23 am

Previous

Return to The Dark Room

Who is online

Users browsing this forum: HarryTuttle and 4 guests