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!

Flat shading

Postby Bart » Mon May 02, 2016 4:28 pm

I'm going to be busy until Thursday and won't be able to touch Supermodel much until then but before I forget, I wanted to point out that I suspect many of the enemies in LA Machineguns should be flat-shaded. I haven't checked yet and will do so at the end of the week when I get a chance. A conspicuous example is the pair of tanks that appear in the Las Vegas stage midway through. They are not shaded at all but almost certainly should be. I think all of the bad guys running around seem like they suffer from this problem as well.

What is your current thinking on this, Ian? That IsNotShaded() in the Pro-1K manual refers to the bit we use for fixed shading? That the bit actually indicates whether the polygon has vertex normals or not? If I remember correctly, your thinking was that when lighting is enabled and there are no vertex normals, fixed intensity is used. Or is there another as-yet unknown bit that might control whether normals are sourced per-vertex or from the polygon face? In the case of the latter, one could imagine a second bit switching between flat shading and per-vertex fixed shading.
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 12:20 am

The manual actually states that flat shading is the default. The MGM lion from our current interpretation of the bits is non textured and lit by lighting. Just it really has no vertex normals. So parts of the game could well be using flat shading. Need to figure out what flag is turned on/off compared to other games which we know have per vertex normals. Vf3 has very nice vertex normals.
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Jiterdomer » Tue May 03, 2016 12:31 am

Here's the close up shot of the robot taken from Wii version:

Image

More lion shots, but this time, the camera pans to the mouth (sorry for the shot being obscured by sparks and texts on screen):

Image

If you want more reference to the MGM lion shadings, go to 4:53 - 5:42 of this video:
https://www.youtube.com/watch?v=g7Tr9BKrYOY
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 Ian » Tue May 03, 2016 8:18 am

Here is la machine guns with the normals drawn as colours (unormalised)

Image

Here it is drawn with the poly normals (aka flat shading)

Image

Literally only the helment and the dudes hands actually have normals, and maybe the water down below. The lion has none. Interestingly the dude himself is totally black, so no normals or any data must have been parsed at all there.

Here is an image where I force lighting to be true

Image

No shading, even with valid normals. My only conclusion is the sun values must be wrong. Maybe the code to parse the ambient + diffuse values are wrong in the viewport code

Here is the same image when I set some random values for sun intensity and set ambient to 0

Image

The code to parse the ambient + diffuse intensity must be wrong?
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Bart » Tue May 03, 2016 8:35 am

Are you drawing polygon normals? If so, I don't understand what's going on. Polygon normals must be defined for all polygons, except double-sided ones, for back-face culling. (EDIT: ah, you are coloring the polygon normals, which clearly exist.)

If you are instead saying that only the helmet and hands have *vertex* normals, then that makes sense to me, because I can see correct-looking smooth shading across the helmet in my renderer (possibly due to specular lighting).

My thoughts on sun vector:

It is certainly possible that the sun and ambient values are wrong, that the sun vector is wrong, or some combination of the two. If you assume that object shadow meshes are placed correctly with respect to sun orientation (not necessarily a good assumption?), it should be possible to render the sun vector and see if it makes sense. I think we originally looked at Lost World (first level has a guy facing the camera, which can be compared to actual screenshots of the game) and Sega Rally 2 (the vehicle sitting at the starting line), as well as Scud Race, to determine sun vector orientation. Scud Race's beginner day level has a glare effect when the car is facing the "sun", which should be a good test for light direction.

That said, there is obviously some weirdness in the Model 3 coordinate system. You'll notice that the first matrix I every apply is one that swaps coordinates around and negates some. Even then, in viewspace, I end up having to invert the Z coordinate because the Model 3 apparently uses a different convention. All of these transformations are applied to the sun vector, too, but the end result is rather confusing.

Hopefully, it is consistent between Step 1.x and 2.x because if not, then it will be even more difficult to sort out.
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 8:39 am

I think the sun vector is correct, it looks correct in other scenes
My sneaking suspicion is the ambient and diffuse sun parameters could be incorrect

Also yeah, every vertex or face should have a normal. My normal code might be a bit buggy :)
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Ian » Tue May 03, 2016 8:42 am

(possibly due to specular lighting).


yeah it's quite possible it's that
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

Postby Bart » Tue May 03, 2016 8:46 am

It's quite possible. Sun intensity is just a float, though, so it's hard to see the problem there. It just ranges from 0 to 1. Ambient is trickier because it is an 8-bit int, similar to the fixed shading intensities. I actually don't recall now whether the Scud debug menu allowed that value to be varied (I *think* it did) and whether it displayed it as a float or not. I first looked at it back in 2010/2011 when writing 0.1a. If it is displayed in the debug menu as an int, then that's not very helpful, but if the debug menu displays the value as a float, might be worth a look. I'm at work now but have Supermodel here (shhh!). Can't do much but let me take a quick peak at that debug menu again...
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 8:47 am

Post a screenshot of the debug menu
I'll have a proper look when I have some time :)
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: Flat shading

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

I just tested the Scud debug menu again. Ambient intensity is printed as a float ranging from 0.0 -> 1.0, which corresponds to 0x00 -> 0xFF.
Attachments
debug_menu_2.png
debug_menu_2.png (17.46 KiB) Viewed 12573 times
debug_menu_1.png
debug_menu_1.png (10.49 KiB) Viewed 12573 times
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Next

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 1 guest

cron