[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 terminento » Sun Jun 11, 2017 9:21 am

How so?
User avatar
terminento
 
Posts: 158
Joined: Fri Jun 15, 2012 8:08 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Sun Jun 11, 2017 9:26 am

This is my latest take on fixed shading. I think step 2.x values are near perfect although I'm not still 100% sure since they depends on lighting and normal values that, on their turn, could depend on that mysterious transformation matrix scale value that affects how much sun a single model receives.

Pseudo-code:
Code: Select all
// Step 1.0 doesn't use fixed-shading at all
if (!ph.LightEnabled()) {
   if (m_step == 0x15) {
      shade = 1.5f; // Over-illuminates Lost World gun calibration screen, but fixes Scud Race
   }
}
else {
   shade = 1.0f;
}

if (ph.FixedShading() && !ph.SmoothShading()) {
   if (m_step > 0x15) { // Step 2.x
      if (ph.LightEnabled()) {
         if (ph.TranslatorMap()) {
            shade = 1.0f + (float)(INT8)(ix & 0xFF) / 255.0f;
         }
         else {
            if (vpAmbientLight > 0.5) {
               shade = 0.5f + (float)(INT8)(ix & 0xFF) / 255.0f;
            }
            else if (vpAmbientLight == 0) {
               shade = (float)(UINT8)(ix & 0xFF) / 255.0f;
            }
            else {
               shade = vpAmbientLight + (float)(UINT8)(ix & 0xFF) / 255.0f;
            }
         }
      }
   }
   else if (m_step == 0x15) { // Step 1.5
      // Model 3 Step 1.5 doesn't seem to use TranslatorMap.
      if (ph.LightEnabled()) {
         float factor = (float)((UINT8)(ix & 0x7F)) / 127.0f;
         if (vpAmbientLight > 0.0f)
            shade = 0.5 + factor;
         else
            shade = factor;
      }
      else {
         shade = 2.0f;
      }
   }
}

p.v[j].color[0] = shade;
p.v[j].color[1] = shade;
p.v[j].color[2] = shade;
p.v[j].color[3] = 1.0f;
Last edited by HarryTuttle on Sun Jun 11, 2017 1:26 pm, edited 1 time in total.
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am


Re: [Patch] Fixed Shading

Postby Ian » Sun Jun 11, 2017 12:28 pm

That's good work :)
Ian
 
Posts: 1120
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby Ian » Sun Jun 11, 2017 12:39 pm

This is the best quality footage I found
https://www.youtube.com/watch?v=UBhdNCuXq94
But doesn't have the canyon scene :(
Ian
 
Posts: 1120
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Sun Jun 11, 2017 12:48 pm

Thanks Ian, I missed that footage! I'm going to dl that and add to my huge collection of model3 videos... :)
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Sun Jun 11, 2017 12:50 pm

I've got a few more of these if you are interested :)
https://www.youtube.com/watch?v=b05KB00efys
Not technically model3, but original real3d videos
Ian
 
Posts: 1120
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Sun Jun 11, 2017 12:56 pm

Already got that... :) I remember to have downloaded years ago all the videos I could from the Real3D site before it closed.

If you're interested...
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Fixed Shading

Postby Ian » Sun Jun 11, 2017 3:39 pm

Here's one from that video capture ..
Image

I guess that the min value is clamped somehow. The upper brightness doesn't seem to have increased, although it's hard to tell off a recording off a CRT ..
Ian
 
Posts: 1120
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Fixed Shading

Postby HarryTuttle » Mon Jun 12, 2017 4:00 am

Ian wrote:I guess that the min value is clamped somehow. The upper brightness doesn't seem to have increased

Does it behave like this with the current build or with my patch? Because I've just checked mine and it's fine.
mta2.jpeg
mta2.jpeg (211.56 KiB) Viewed 367 times
User avatar
HarryTuttle
 
Posts: 481
Joined: Thu Mar 09, 2017 8:57 am

PreviousNext

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 3 guests