[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 HarryTuttle » Wed Aug 16, 2017 9:45 am

Ian wrote:What do you think the basic fixed shaded formula is?

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

That ends up saturating the image


For start I'll consider that a general, sun or fixed, shading formula. It's simpler to treat like that because when you apply the global GPU floor clamping and/or signed value to the shade it works for both variant (sun or fixed).

So: inFixedShade should be substituted with a genralized shade variable which, by means of a function or whatever you like, can be NdotL or inFixedShade depending on the state of the bool uniform fixedShading.

This is valid, of course, for illuminated polys (bool uniform lightingEffects == true). For self-illuminated let's discuss them later.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Wed Aug 16, 2017 9:49 am

What do you classify as self illuminated polys?
Ian
 
Posts: 1646
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Wed Aug 16, 2017 9:52 am

lightingEffects == false

which can be set for both shading types (sun or fixed)
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Wed Aug 16, 2017 9:53 am

Oh wait, if the signed fixed shaded values are allowed to be negative?
Does the ambient cancel that out??

So
Fixed shade = -1
+Ambient of 1 = 0 for black?
Ian
 
Posts: 1646
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Wed Aug 16, 2017 9:57 am

Exactly! ;)
Infact L.A. Machineguns uses this trick in the attract demo to modulate the diffuse light since ambient is most of the times = 1.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Wed Aug 16, 2017 9:58 am

And, in fact results as a very high contrast game
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Wed Aug 16, 2017 10:25 am

Ahhhh!
Okay now that makes total sense. Now I see what you are doing :)
So I assume it would make much more sense to pass the fixed shade value as a float to the shader? Instead of unsigned bytes?

Float because star wars actually uses unsigned bytes
Ian
 
Posts: 1646
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Wed Aug 16, 2017 10:33 am

Ian wrote:So I assume it would make much more sense to pass the fixed shade value as a float to the shader? Instead of unsigned bytes?


Absolutely! Unless you want to make it signed / unsigned in vertex shader with a function based on a uniform state like I've done. You decide... ;)

I prefer doing that in shaders so i pass only unsigned bytes and forget it, but everyone has his personal tastes.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: [Patch] Sun Shading

Postby Ian » Wed Aug 16, 2017 10:53 am

I think for me it would make more sense to pass the data as a float :)
Btw, congrats on working this out. Discovering that
a) the fixed shaded values are allowed to be negative
b) that fixed shading is literally a drop in replacement for the dot product between normal and light

I think is quite a major step forwards in our understanding :)
Will work on merging this tomorrow asap, but today I've run out of time, real life calls :)
Ian
 
Posts: 1646
Joined: Tue Feb 23, 2016 9:23 am

Re: [Patch] Sun Shading

Postby HarryTuttle » Wed Aug 16, 2017 10:59 am

Ok, glad we've sorted it out :)

Oh, btw tomorrow let's not forget to finish discussing the self-illuminated and specular hightlight topics, to complete the fixed shading argument. ;)
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 5 guests