[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 Ian » Sat Mar 18, 2017 10:27 am

I've honestly no idea what the translator map does
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Sat Mar 18, 2017 3:08 pm

Ian, I've finally sorted it all. :)

As it turns out, Step 1.5 have the shade "base" value set to 2.0 for *everything* self-illuminated (even non fixed shaded), so the corresponding poly color gets its value doubled, then fixed shading is added to the value like this: for illuminated polys spans from -0.5 to +0.5, for self-illuminated polys spans from -1.0 to +1.0, finally for ambient light == 0.0 (and only in this particular case) the shade *is* the value of fixed-shading ranging from 0.0 to 1.0.

Now it all makes sense. And the much more clearer code is like this:
Code: Select all
if (m_step == 0x15) {
  if (!ph.LightEnabled()) {
    shade = 2.0f;
  }
}
float divisor = ph.LightEnabled() ? 255.0f : 127.0f;
float offset = ph.LightEnabled() ? 0.5f : 1.0f;
shade += 2.0f * (float)((UINT8)(ix & 0xFF)) / divisor - offset;
if (vp_ambient == 0.0f)
  shade = (float)((UINT8)(ix & 0xFF)) / 127.0f;
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Sat Mar 18, 2017 6:40 pm

I'll give this one a spin tomorrow :)
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby Bart » Mon May 29, 2017 11:50 am

What was the final determination on this? Is it correct and has it been incorporated into the source tree?
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: [Patch] Fixed Shading

Postby Ian » Tue May 30, 2017 2:20 am

As far as I can work out .. this is the basic formula

FinalColour.r = FixedShade * polyColour.r
FinalColour.g = FixedShade * polyColour.g
FinalColour.b = FixedShade * polyColour.b

When lighting is enabled it becomes

FinalColour.r = FixedShade + polyColour.r
FinalColour.g = FixedShade + polyColour.g
FinalColour.b = FixedShade + polyColour.b

Where the fixed shade value comes from the signed 8 bit normal vector. Where -1 = 0 and +1 = 255

Personally I wouldn't have thought the shading values be conditional on certain viewport ambient values .. but I could be wrong. The model3 is crazy :p anything is possible.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby scd » Fri Jun 02, 2017 2:55 am

hi ian. is this fixed shading already a part of the new engine, or it will be a part of it soon?
scd
 
Posts: 62
Joined: Thu Jun 01, 2017 11:35 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Sun Jun 04, 2017 11:45 am

I've done some adjustments to fixed shading (as well as other things like light on fog). I'm currently making some tidying up work to my private messy Supermodel tree. As soon as possible I'll review/update my submitted patches before (I hope) next major release.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Bart » Thu Jun 08, 2017 7:38 am

scd wrote:hi ian. is this fixed shading already a part of the new engine, or it will be a part of it soon?


I believe the fixed shading changes have already all been incorporated into the SVN tree.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: [Patch] Fixed Shading

Postby Ian » Sat Jun 10, 2017 8:44 am

I had a bit of a debug of mag truck, since never looked at fixed shading in this game

Arcade looks like this ( really poor quality :( ) anyone got any better caps?

Image

Supermodel ..
Image

Ground is clearly the wrong colour. Comes out black, should come out with full brightness ..

Changing the code from
Code: Select all
float shade = (((ix + 128) & 0xFF) / 255.f) + offset;

to
Code: Select all
float shade = (((ix + 127) & 0xFF) / 255.f) + offset;


Produces ..
Image

Personally I would think the first formula to be the correct one. Since signed int8 starts at -128 and ends at 127 but it produces the wrong colour entirely

The black values have the hex value 0x80
0x80 + 128 = 0
0x80 + 127 = 255

Needs more testing .. really only tested mag truck with this code.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

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

well that modification was definitely wrong :/
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

PreviousNext

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest

cron