Flat 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: Flat shading

Postby Bart » Tue May 03, 2016 9:08 am

By the way, I noticed you didn't try rendering with lighting enabled but using polygon normals. I tried this the other day and thought it looked decent, although not quite correct on the lion statue.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Flat shading

Postby Ian » Tue May 03, 2016 9:10 am

Wow crazy,
never knew this thing existed .. will do some testing with it
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Jiterdomer » Tue May 03, 2016 9:19 am

It will probably fix some numerous emulation issues with it, if this is the only hope.
Feel the heartbeat of my machine through this tight seat. I feel every motion of my machine
Image
User avatar
Jiterdomer
 
Posts: 627
Joined: Mon Sep 26, 2011 6:37 pm
Location: Los Angeles, California

Re: Flat shading

Postby Bart » Tue May 03, 2016 10:17 am

The problem is that without a real Scud Race machine to verify against, the test results can be difficult to interpret. I used this menu while writing 0.1a to figure out where various parameters were stored in the viewports but could not verify that my implementation is correct. I could easily produce EPROMs for someone with a Scud board to try out but repeated insertion and removal of EPROMs is physically damaging to the board. If I could get a Scud board off of eBay on the cheap, it might be doable but some of the tests require that the steering wheel be hooked up and I'm not sure how to simulate that.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Flat shading

Postby Ian » Tue May 03, 2016 10:59 am

Is there no crazy key combo that activate this menu?
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Bart » Tue May 03, 2016 1:00 pm

Stefano Teso initially found this way back in 2003. The farthest he got was an array of function pointers in memory, one of which points to 0x50208, which in turn enters the debug menu. The patch places this address into the first element of the function pointer table. I just spent about 15 minutes looking at it and discovered that there does indeed appear to be a bit of code that will select this element in the table :) Let's keep our fingers crossed that this is activated with buttons and not via some serial port interface or something crazy like that.

Code: Select all
0x00059B54: 0x806D8094  lwz r3,-0x7F6C(r13)
0x00059B58: 0x5460E801  rlwinm. r0,r3,29,0x80000000
0x00059B5C: 0x40820010  bf  cr0[eq],0x00059B6C
0x00059B60: 0x54600001  and.  r0,r3,0x80000000
0x00059B64: 0x40820008  bf  cr0[eq],0x00059B6C
0x00059B68: 0x4800000C  b 0x00059B74
0x00059B6C: 0x3860003C  li  r3,0x0000003C   <-- this gets us to debug menu
0x00059B70: 0x986DC006  stb r3,-0x3FFA(r13)
0x00059B74: 0x4E800020  bclr  0x14,0


Now just need to work backwards. I'll have to really dig in on Friday because I don't think I'll have time in the next couple of days. Unfortunately, useful though it will be, it won't solve most of the lighting equation problems :(

Re: shading, perhaps "IsNotShaded()" in the manual refers to sun vector shading only and not ambient? Or, it refers to the lighting components (sun_vector+ambient) but NOT fixed intensity. If the latter is true, it would mean, I think, that lighting disabled and (not shaded and not fixed shaded) are equivalent states.

This could mean that there are bits for each of these:

1. Shading enable/disable
2. Flat/smooth (if fixed shading enabled, smooth shading disables sun vector entirely?)
3. Fixed shading enable/disable

An alternative is to have a fourth sun vector bit, allowing some weird illegal state where both smooth-shaded sun vector and fixed lighting are enabled, with the API in charge of preventing this, but seems unlikely.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Flat shading

Postby Ian » Tue May 03, 2016 1:25 pm

If we could get this thing working on real hardware, we could figure out some of the weird stuff like scroll fog, scroll att,

I should add, the IsShaded() in the manual says (HasNormals)
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Chine » Tue May 03, 2016 1:33 pm

If you want to test on real hardware, you should really ask to Guru !
Chine
 
Posts: 5
Joined: Wed Feb 29, 2012 10:17 am

Re: Flat shading

Postby Bart » Tue May 03, 2016 2:12 pm

Ian wrote:If we could get this thing working on real hardware, we could figure out some of the weird stuff like scroll fog, scroll att,

I should add, the IsShaded() in the manual says (HasNormals)


That's only for the vertex-level function. Which kind of makes sense. Shaded either refers to sun vector alone or both sun vector + ambient. It's not really clear from this function what was intended.

The problem with the Scud Race castle is that ambient is disabled entirely and fixed shading is used. Seems to me there are three possibilities, assuming that ambient is being computed from the viewport correctly:

1. Both sun and ambient light are disabled for these polygons, and only the fixed intensity is used at each vertex. (vertex_lighting = fixed_intensity)
2. Sun light is enabled with flat shading, ambient disabled, and fixed lighting enabled. (vertex_lighting = sun_component*fixed_intensity)
3. Sun light is enabled with smooth shading, ambient disabled, and fixed lighting is enabled; a potentially invalid state that the API would have blocked, which ends up re-using the fixed intensity as an X-oriented normal. (vertex_lighting = sun_component*fixed_intensity, with sun_component computed erroneously from vertex normals rather than polygon face).

Number 3 seems unlikely. Number 1 seems most likely to me. Number 2 is a possibility if ambient lighting can be controlled independently.
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: Flat shading

Postby Ian » Tue May 03, 2016 2:19 pm

What should it look like compared to what it looks like now?
Because I can't see anything obviously wrong :p
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