News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Artifacts in track preview rendering with custom cars

Started by Cas, December 19, 2020, 10:01:41 PM

Previous topic - Next topic

Cas

I slept a little and now I've been making some tests. My hypothesis was that black artifacts shown in the track preview screen for the track Cactus Festival reminiscent of inkblots were due to the presence of player cars in the track design whose miniature shape included ellipses that were incorrectly rendered and that this was to be expected of custom made cars, like is the case of the Melange.

My test yields affirmative results. In fact, the Melange is not the only one to cause this issue. All the cars that produce these effects are custom-made, though most custom-made cars do not produce it. For each car, the distribution of the artifacts is different and sometimes, it may change for each peek in the track preview. Other artifact also appear occasionally. This suggests that there is something we do not know about how 3D shapes are supposed to be designed because some aspects of them are rarely put to the test.

Cars that produce these bugs:
Audi DTM - Huge black and red painted areas
BMW DTM - Huge black triangle
Porsche 911 Turbo - Yellow regions and distortions in terrain rendering
Melange - Two black inkblots

Custom-made cars that don't:
Mercedes DTM - Very curious since the other two DTM cars do
Speedgate
Nissan Skyline
Ford Ranger
Superkart
Xylocaine
Ferrari F40
GT3 Mark II
Lotus Esprit
McLaren Honda

After a track has been displayed in the preview and exhibited glitches, Stunts becomes unstable and is likely to crash. The colours in the glitches appear to be complete unrelated to the paint job colours.
Earth is my country. Science is my religion.

Daniel3D

I saw blue triangle shaped artifacts with the Porsche 962 IMSA.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

Oh... well, if these things happen with original cars, the message is that including car shapes in track designs can lead to these things in general. The thing is the shape has to be rendered so small that it can yield strange results.
Earth is my country. Science is my religion.

Duplode

#3
Thanks for starting a thread about the inkblot! While I have been aware of artifacts of this kind for a long time, I never gave any thought at all to what might cause them.

Quote from: Daniel3D on December 19, 2020, 11:02:11 PM
I saw blue triangle shaped artifacts with the Porsche 962 IMSA.

So it's not just custom cars then. That closes a few possible lines of investigation.

Another thing I have noticed is that results seem to also depend on the track. For instance, there is an artifact with the Corvette on ZCT075 (another track with a scenery car), but not on Cactus (both tracks are attached below).

Quote from: Cas on December 19, 2020, 10:01:41 PM
After a track has been displayed in the preview and exhibited glitches, Stunts becomes unstable and is likely to crash.

While I had not noticed any related instability instability before today, that was probably due to lack of testing. A reproducible example: if you start the game, pick the Kart as your car, then go to the track selection menu and pick Cactus, a "check disk" error will happen out of nowhere when you try to go back to the main menu. The same thing happens with the Trueno on ZCT075, with the additional weirdness of the menu music rewinding back to the start of the song! Note that you can still drive normally with those car-track combinations as long as you select the car after the track, so this issue is not quite as severe as it might seem.




Between reading your posts and doing some tests of my own, I think I now have a reasonable hypothesis to account for this issue.

Much like a car's P3S/3SH file holds car0, car1 and car2 shapes, every track object 3D shape in GAME1.P3S and GAME2.P3S has a low detail counterpart which is used when rendering the track preview, its shape name having "z" as a prefix (for instance, tunn and ztun are the two tunnel shapes in GAME1). Now, the scenery cars we add with the 0x02 and 0x03 values in a track files aren't actually track elements -- presumably we are taking advantage of the car1 shapes, by a happy accident, being loaded in just the appropriate places in memory for us to pretend so. Since the cars aren't track elements, there is no low detail counterpart of their shapes, and so whatever addressing mechanism the game uses to find the low detail shape gives back arbitrary stuff, leading to unpredictable behaviour. (Note, by the way, that even when there are no visible graphical artifacts you never actually see a car in the preview; at best, you get an empty-looking tile.)

Cas

Uhhmm... I tried the kart with both tracks, loading the car first and track after and the other way around and none of the two gave an error or showed artifacts. So weird!  Makes me think that maybe, how many cars you have in your "garage" can affect the results. Otherwise, I can't see how one would get a certain result and another person won't. On the other hand, I have indeed got that error message when I did my previous test with some cars. At a point, Stunts crashed and took me back to DOS.

There's no doubt that the issue has to do with rendering the player's car in the track preview, but it's unclear how the issue develops exactly. Instability problems usually have to do with memory being overwritten. If executable code is being overwritten, usually you get a fatal crash. This looks more like data being overwritten, so then the information is corrupt, but the code tends to stay up for longer, until some unsustainable calculation is made with extreme parameters or a corrupt pointer leads to executable code overwriting getting back to the first type of crash.

All in all, the only way to be sure this won't happen appears to be to not use player or opponent cars in tracks.... sad :(  I think we can cope with the risk :P
Earth is my country. Science is my religion.

Duplode

Quote from: Cas on December 20, 2020, 03:48:11 AM
Makes me think that maybe, how many cars you have in your "garage" can affect the results. Otherwise, I can't see how one would get a certain result and another person won't.

That does seem possible. (I currently have 31 cars, one fewer than the maximum.)

Quote from: Cas on December 20, 2020, 03:48:11 AM
All in all, the only way to be sure this won't happen appears to be to not use player or opponent cars in tracks.... sad :(  I think we can cope with the risk :P

I agree, it is manageable. The upshot is that we now kind of understand the glitch and won't be too confused next time anyone runs into it.

Daniel3D

Quote from: Cas on December 20, 2020, 03:48:11 AM
Makes me think that maybe, how many cars you have in your "garage" can affect the results. Otherwise, I can't see how one would get a certain result and another person won't.
The used a clean ZakStunts 2020 copy with only the melange and the two tracks added.
It does have the car pack with the DTM car's included.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Overdrijf

#7
This is so cool. The game passed 30 and even custom car shapes have been around for years and there are still people figuring new stuff out.

Cas

Yeah, makes me want to retake my 3D engine project, but it's so much work!
Earth is my country. Science is my religion.

Duplode

I was compelled to have another look at this issue after noticing that Ryoma's Jaguar XJ220 is badly affected by it, at least in my install with 32 cars. Almost every track with a ghost car leads to a crash if you start the game and try to select it with the XJ220 as the chosen car (I have attached Visegrád and ZCT193, which can be used to reproduce the issue). Workarounds include:

  • As mentioned above, choosing the track before the car seems to be enough to avoid the problem.
  • Additionally, the crashes appear to only happen the first time you try to race after switching to an affected car. That being so, starting and quitting a race with the XJ220 on Default, or some other unproblematic track, seems to be enough to prevent the issue on further track changes. (Note that if you select some other car and then go back to the XJ220, you'll have to do it again.)
Whether, and to which extent, the issue manifests itself appears to depend on arbitrary minutiae of the car shape memory layout, and so a proper solution for this issue seem out of reach. For instance, I have tried to fool the track preview renderer by adding an empty zcar shape to STXJ22.3sh (see my longer post above for why I hoped that might work). While that does seem to prevent the issue for the XJ220, the trick doesn't work on the Trueno doesn't work, as it crashes on ZCT075 regardless. (I have attached both modified 3sh files, in case you want to inspect them.)

alanrotoi

zct16 has ghost cars too ;)

BTW I enjoy these threads but I don't know how to contribute :D

Daniel3D

I'm not near a computer now. But the cars that produce artifacts. Are they close to the limit of vertices?
Scenery has a lower limit I believe.
That would explain why there are no artifacts when the car is not selected yet.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Duplode

Quote from: Daniel3D on January 08, 2022, 09:27:58 PM
But the cars that produce artifacts. Are they close to the limit of vertices?

Some are, such as the XJ220, but others are quite far from it, such as the Kart.

Quote from: Daniel3D on January 08, 2022, 09:27:58 PM
That would explain why there are no artifacts when the car is not selected yet.

(If we load the game and start a race without going to the car selection screen, are the Countach files loaded on startup, or just when we choose "Let's drive!" on the menu?)

Daniel3D

On startup the base selection values are loaded. But the car itself is loaded when you press let's drive.
The track is also loaded then.
The preview of the car or track is separate from driving and unloaded from memory before driving.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

This sounds to me like the whole-track renderer expects some restrictions from the 3D shapes that go beyond what's normally expected in game, yet the original cars respect these restrictions. When a car is loaded, the shape is brought to memory as-is, but then, if you run a race or load another track, it seems that these mini-shapes are processed, so the problem disappears. This lead me to think, too, that cars nearing the vertex or primitive limit could be more likely to cause problems.

One thing we should try is modify each of the shapes in a car one by one leaving the other two untouched and then render the track to find out which of the three models is rendered in the whole-track screen. I would assume it's car1, because that one has the same scale as the track elements. But if it happened to be car2, it's a lot simpler to get restrictive with it. If it's car1, I would like to test whether cars that do cause problems with this also bring similar problems when you give the opponent that car and your race with him/her and watch the car from afar (so it looks as small as in the track screen). If it were car2, I would be highly suspicious of wheels, which are normally absent in car2 models of original cars.
Earth is my country. Science is my religion.