Supermodel originally appeared to have many small rendering anomalies.Here in scud race there is what appears to be a missing poly on the car windscreen (windshield for you yanks).

There actually existed a prototype version of scud race for the dreamcast, and there is some footage on youtube of it, running under demul.

The exact same poly errors shows up here too, so I assumed that the car was just modeled badly originally. Without high quality footage of car from the original model3 hardware I had no way of knowing if this was a bug or not, so I just wrote it off.

Then Harry showed me this screenshot, and hardware comparison.

And on the model3

Oh god, what's going on with the texturing? Why is it so broken. To debug this thing first I took a look at the actual polys themselves.(Scud race looked actually quite awesome like this lol)

Poly 712 and 713 were the most visibly broken ones.

Here is the polys overlayed with the original rendering. The white lines show how they are being split into triangles.

Okay maybe we've split our quads the wrong way? There are actually 2 ways you can split a quadrilateral, and you can get quite different results depending on which split you take.

Okay so let's see the rendering with the splitting into triangles flipped.

Parts of the model look better.. other parts look more broken somehow. My original thoughts were, the splitting could have been related to how the vertices were arriving at the input buffer, but that turned out not to the case. There actually exists algorithms to split quads to give better results. For example you can split a quad into triangles by the shortest distance between the vertices. I tried this, and results were better but still no cigar. I realised later on that, both ways of splitting the quad were wrong, and actually the hardware was natively rendering quads, ie with quadratic interpolation (between 4 points) This is somewhat problematic, because virtually all hardware in existence renders only triangles (interpolation between 3 points). Besides the DS? The only hardware that rendered quads were made 20+ years ago, sega saturn, nvidia NV1? Not much is known about how they render quads, and what kinds of limitations they actually had.

The left is triangles per vertex, middle quads, right pixel shaders. The per vertex quad version looks almost identical to the pixel shader version ... which is a massive improvement over triangles.

You can also do this with quads

To texture that properly with triangles, you'd have to really tessellate that down to the pixel level. There are papers online that recommend tessellation to solve this problem and that was the first solution I tried. But splitting a quad into 4 quads, and splitting again to render as triangles 1 quads becomes 8 triangles, and all you've done is halved the error. Do a 2nd or 3rd level of splitting really explodes the number of polys and basically chokes the renderer. Not a viable solution.

Nvidia has a paper where they recommend rendering quads with a geometry shader and gl_lines_adjacency. You can then pass all the 4 attributes to the pixel shader and do custom interpolation there.

My original quad code based upon this paper, basically worked (as a proof of concept) but had a lot of corner cases that would result in NaNs and other errors. And I also had a serious issue with AMD cards where interpolation qualifiers didn't work with geometry shaders. Looked like this

This bug caused me to abandon the project entirely. If I couldn't get it to work on my AMD card, what's the point? Anyway, 1 year later AMD got back to me and that bug has been fixed. Just not on my AMD card because it's older and doesn't get driver updates anymore .. lol, oh well.

Anyway with this bug fixed, motivated me enough to finish this project. And these are the results.

Just like the arcade now!

Although interpolation of vertex attribs now looked correct, these errors still existed.

The reason is because fundamentally we are still rendering the quad as 2 triangles. And the depth values are being written as triangles. Anyway in GLSL you can write to gl_FragDepth and write your own custom values. Normally you don't need to bother with this because it's done automatically. You don't even need to write anything. Triangles are always planar, but quads, well they don't have to be planar. In fact you they can be twisted and contorted. You can render some extremely complex shapes with just a single quad polygon. Anyway interpolating the depth between 4 points gives us these results.

No more depth testing errors, everything works as expected!

As far as I know this is the only general purpose quad renderer (in opengl) in existence. You can switch between the triangle and quad shaders with the command line -quad-renderer. Personally I wouldn't have bothered with the normal triangle renderer at all, but there are enough people out there with potatoes for pcs that will complain if I make it the default renderer lol.

This project has actually changed my mind about quads. I don't see them making a come back, but they aren't so evil after all.

This is a great write up, even for those of us who've been following along (there were details I wasn't yet aware of, and it's a great jog to the memory of how far you've come). Your patience and attention to detail is beyond commendable.

One thing I have to ask, though: was there actually a leaked prototype of Scud Race for Dreamcast? That screenshot appears to be of the Model 3 game from an older build of Demul (it had Model 3 support for a while, before the author decided it wasn't worth it to him to continue work on it given the state of Supermodel).

Ian wrote:As far as I know this is the only general purpose quad renderer (in opengl) in existence. You can switch between the triangle and quad shaders with the command line -quad-renderer. Personally I wouldn't have bothered with the normal triangle renderer at all, but there are enough people out there with potatoes for pcs that will complain if I make it the default renderer lol.

hello ian , nice work as always

just downloaded 741 and that quad command doesn't seem to get recognized (i tried using -quad renderer as well)is it something meant for the next release(s) maybe ?

also,is the performance loss from switching from triangles to quads supposed to be that big ?my hardware isn't that great (very old i7 and a 750ti) but i didn't notice a significant difference when i tested your wip quadtest build a couple days agoa few games do drop from 70/80 fps to 30 in particular moments or stages in the "regular" build but pheraps those are known issues ?i might open a thread in the fitting room section later i guess

one final question while we're at it (i've been kinda out of the loop in the past 6-8 months)should i disable the network emulation (aka does it help performance) or is it mandatory in certain games ?and what's the command to disable it if there is one

and thank you again for fixing vf3 , that was the #1 on my personal wish list

Command line is-quad-renderingmy bad for probably type out the wrong one. You should disable the network code .. unless you actually have multiple instances of the program and you have other people to play with lol. Currently the network code can only work in single threaded mode, which is significantly slower