[Patch] Sun 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] Sun Shading

Postby Ian » Thu Aug 17, 2017 7:52 am

What I mean by flat shaded version is

The fixed shade brightness comes only from the polygon colour
Not the per vertex normals

but this theory should be easy to test. If lighting is disabled and fixed shading is enabled, we should see shading done with the vertex normals

Edit, well I tried out LA machine guns with that assumption, and the only value it passes it 0
Scud only seems to set 2 values, 15 and 63
Ian
 
Posts: 1647
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Thu Aug 17, 2017 10:28 am

Ian wrote:What I mean by flat shaded version is

The fixed shade brightness comes only from the polygon colour
Not the per vertex normals


Ian, the explanation is simple (and I too was tricked when trying to find the right formula): in that scene and the scene before (the bridge) vp_ambient is "0" and vp_diffuse is "1" (or something very close to that). So with shade * vp_diffuse + vp_ambient the end result is just shade. You should only double check if the resulting shade value corresponds (or is near) to the polygon color.

Anyway with shade * vp_diffuse + vp_ambient the result is arcade-perfect, so why bother ? :D
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Thu Aug 17, 2017 11:30 am

Gonna do some more testing and get back to you :)
You could well be correct though
Ian
 
Posts: 1647
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby Ian » Thu Aug 17, 2017 2:16 pm

This is my best guess .. seems to work for LA machine guns and scud. Also looks pretty much the same as what you have Harry?

Code: Select all
polyColour.rgb += (inFixedShade * (lightDiffuse + lightAmbient));
Ian
 
Posts: 1647
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Thu Aug 17, 2017 3:10 pm

Actually I use:
Code: Select all
polyColour.rgb *= (inFixedShade * lightDiffuse) + lightAmbient;

or, more in general

polyColour.rgb *= (shade * lightDiffuse) + lightAmbient;

where "shade" can be "NdotL" or "inFixedShade"


I modulate, not add, polyColour.rgb with (shade * lightDiffuse) + lightAmbient (note also the different distribution of terms). Which is like the old light math. And I'm still referring to the LightEnabled polygons.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Thu Aug 17, 2017 3:50 pm

HarryTuttle wrote:Actually I use:
Code: Select all
polyColour.rgb *= (inFixedShade * lightDiffuse) + lightAmbient;

or, more in general

polyColour.rgb *= (shade * lightDiffuse) + lightAmbient;

where "shade" can be "NdotL" or "inFixedShade"


I modulate, not add, polyColour.rgb with (shade * lightDiffuse) + lightAmbient (note also the different distribution of terms). Which is like the old light math. And I'm still referring to the LightEnabled polygons.


I tried that one but it doesn't work for LA machine guns.

Source
Image

polyColour.rgb *= (inFixedShade * lightDiffuse) + lightAmbient;

Image

Code: Select all
polyColour.rgb += (inFixedShade * (lightDiffuse + lightAmbient));

Image

If the fixed shade value = 0, it just uses the poly colours directly. Don't know if this logic is correct but seems to work
Ian
 
Posts: 1647
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Thu Aug 17, 2017 4:03 pm

Ian, those explosions are self-illuminated polygons (LightDisabled) ;) , that's why do not work if you use that math globally.

You've to add an exception: with self-illuminated polys just use the polygon color, I'm doing this in my shaders. Also this work for step 2.x only, with step 1.5 self-illuminated have, again, another math. But let's first fix things in 2.x, since are easier to check.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Thu Aug 17, 2017 4:04 pm

I can post some screenshots made with my shaders if you want, just tell me. :)
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Thu Aug 17, 2017 4:05 pm

I assumed (perhaps incorrectly) that the shading would be the same between step 1.5 and 2.0 ...
I need some more test cases to see if the logic fails
Ian
 
Posts: 1647
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

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

Ian wrote:I assumed (perhaps incorrectly) that the shading would be the same between step 1.5 and 2.0 ...


To make things easier:

- for LightEnabled polygons the shading is the same between different steps and shading type (NdotL or Fixed Shading).
- for LightDisabled polygons not. In step 2.x leave the polygon color as is. For step 1.5 you use this logic I posted before:
Code: Select all
float offset = FixedShaded ? shade : 0.0;
lightAmbient += offset;

Yes. its odd... but works ;)
User avatar
HarryTuttle
 
Posts: 646
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

cron