Difference between revisions of "Slow Motion Bug"

From Custom Mario Kart
Jump to navigation Jump to search
(40 intermediate revisions by 13 users not shown)
Line 1: Line 1:
== Description ==
+
{{Bugs}}
 +
== Overview ==
 +
Like a PC, the [[Wii]] is a computer system with a set amount of memory (''RAM''), processing (''CPU'') power, and graphics (''GPU'') power. When it does not have enough CPU or GPU power to calculate what is rendered on screen, the action on screen (the frames per second or ''FPS'') can slow down dramatically. While this technically isn't a bug in the traditional sense, it is a symptom of poor optimization and can indicate that the track author did not test the level thoroughly before release.
  
Like a PC, the Wii is a computer system with a set amount of memory (''RAM'') and CPU power.  When it does not have enough RAM/CPU power to calculate what is rendered on screen, the action on screen (the frames per second or ''FPS'') can slow down dramatically.  The "Slow Motion Bug" can be caused many factors including model complexity, the number of objects rendered on screen, hi-res textures or a large quantity of textures.  It really isn't a bug in the traditional sense, but a symptom of poor optimization and can indicate that the track author did not test the level thoroughly before release. 
 
 
The slow down will be most noticeable when playing split-screen modes with computer drivers (bots) enabled on 150 CC mode.  The effects are lessened if:
 
 
* The computer drivers are disabled.
 
* Playing 50 or 100 CCs.
 
* Playing Single Player mode.
 
* Playing online (no bots)
 
* Playing 2 players online (no bots and FPS are set lower in this mode.)
 
* Playing 2 player split-screen instead of 3 or 4 player mode.
 
 
;Example Video
 
 
{{youtube-box|bug|x7auiQJ6QtI|Six King Labyrinth Slow Motion Bug}}
 
{{youtube-box|bug|x7auiQJ6QtI|Six King Labyrinth Slow Motion Bug}}
  
== Fixing the Problem ==
+
== Types of Slowdown ==
 +
There are several different types of slowdown that can occur in-game, depending on the component(s) being bottlenecked.
  
There are three major things that may slow down a [[Custom Track]]. The first and most common problem is a model that is too complex.  Here are some ways a model can be overly complex:
+
=== CPU Bottleneck ===
 +
Symptoms:
 +
* Game slows down in 12 player online rooms.
  
*Model Has Many Lines
+
Causes:
*Model Has Many Faces
+
* An infinite loop is occurring in a [[KMP]] route.
*Model Is Too Large
+
* A model is using too many draw calls/materials.
*Model Contains Too Many Textures
+
* There are too many NodeTree or NodeMix definitions.
 +
* There are too many particle generator objects.
  
You can find problem areas by looking at your model in [[SZS Modifier]] with the ''wire frame view'' option enabled.  To optimize your model, delete as many unnecessary lines/faces/textures in your model as you can.  Simplify curves on your model by deleting intermediate lines on the curved surface.  If you are using [[SketchUp]] to create your model, explode all components and curves.  Components will cause duplicated textures to appear in your model's brres file, increasing its memory footprint.  Likewise, check the mtl file for "#Distorted Textures."  These are twisted or skewed copies of textures used in your level, usually used on a single face of the model.  Reset the alignment of these textures on your model and re-export to eliminate the distorted duplicates.  You can find the locations of these textures on your model by replacing the distorted texture with a brightly colored texture, such as lime green or neon orange, then loading the model in-game or in the BRRES Editor.
+
=== GPU Bottleneck ===
 +
Symptoms:
 +
* Game slows down in 2 player splitscreen.
  
Reducing the resolution of textures can also help. For example, the area of a single 1024*1024 texture is equal to the area of ''16'' 256x256 textures. The difference in-game between a hi-res texture and a low-res texture is often small enough to not be noticeable.  
+
Causes:
 +
* Culling is being used improperly (no culling at all times).
 +
* A model is too geometrically complex.
 +
* A model has improper texture coordinate scale.
 +
* A model's shader is using too many stages.
 +
* There are too many large textures onscreen at once.
 +
* There are too many large texture formats (RGBA8).
  
Additionally, creating a [[Solidity#Collision_Models|simplified collision model]] can help improve frame rates by reducing the number of calculations the CPU needs to make when players interact with the track.
+
== Troubleshooting ==
 +
=== Optimize Model Geometry ===
 +
You can find problem areas by looking at your model in [[SZS Modifier]] with the ''wireframe view'' option enabled. To optimize your model, delete as many unnecessary lines/faces/textures in your model as you can. To reduce the complexity of curves, explode curves on your model and delete intermediate lines on the curved surface. This is an important step if you are creating objects with the Follow Me tool as it can drastically reduce their complexity.  
  
If these steps only partially solve your problem, than your level might have too many items.  
+
Note that OBJ exporter plugins for [[SketchUp]] are not perfect; some may cause duplication of textures if components ''are not'' exploded, while others may create garbage polygons if they ''are'' exploded. You will need to experiment to get the best results. Some authors recommended using the [[3ds Max]] .dae exporter and [[BrawlBox]] to import models. The [http://www.vgmp3.org/DLs/HSKP2UNR_v103-Sketchup_Plugin.zip The HardPCM plugin] is a good free option.  
  
This may be caused by:
+
[[file:reduce-faces-1.png|thumb|right|'''Figure 1.''' Overlapped polygons.]]
 +
[[file:reduce-faces-2.png|thumb|right|'''Figure 2.''' The same polygons on different planes.]]
 +
[[file:reduce-faces-3.png|thumb|right|'''Figure 3.''' The previous image from a different angle.]]
  
*Too Many Items in the SZS
+
Some [[custom tracks]] define faces from both sides. <!-- I believe this mainly happened in the mspaint era. --> But for nearly all of the drivable faces (road, offroad, boost, water and some more) only face up triangles are needed. So the first possibility to reduce the number of faces is to remove all drivable face down triangles. In the the example on the right this may save 41 of the 82 triangles (90 triangles total).
*Too Many Items In Game
 
*Unused items that are still rendered
 
*Items with animations set to display in all game modes
 
  
The easy solution would be to remove all unnecessary items. This can be done with easily The [[KMP Modifier]].
+
Using face down roads has also another negative effect: If jumping down to the road the player touches sometimes the face down triangle and the vehicle will drive head down for a moment into a complete wrong direction. So it is an obligation to remove the face down triangles of drivable [[KCL]] types. Not only roads, but also walls are candidate for removing triangles.
  
A dirty SZS can also contribute to slow FPS. This means is that the SZS has unnecessary files that are not being used in the level.  These files are still loaded in memory even if they don't appear in-game.
+
The general rules are:
 
+
* Remove triangles (faces) that can never be seen. Do this for the visual model and also for the KCL.
To fix this, open up the SZS [[CTools]], right click unnecessary items, and press "Delete".
+
* Remove triangles from the KCL that can never be reached.
 
 
Some items should only appear in single player mode, such as animated characters like piantas, flowers, and shy guy groups. In SZS Modifier's KMP Editor the final box will have a value like 0000003F.  3F means that object will appear in all game modes.  Change it to 00000009 to disable those objects in split screen modes.  
 
  
=== Reducing the number of faces ===
+
You can save much more triangles if you think in 3D. See the 3 pictures at the right: green is grass, blue the road, yellow are boost and brown a small hill. In the first picture you see, that 49 triangles are used. It's because the developer thinks only in 2D and lays all triangles side by side.
  
[[file:reduce-faces-1.png|right|More faces than needed]]
+
And now let's take a look, how Nintendo did it for the newer tracks. They think in 3D and define the grass level with only 2 triangles. Then they place a street 2-4 units higher and use again only a few triangles. And in a third level they place the boost parts. And the hill is also placed in the grass and may go below the grass.
  
Most custom tracks define faces from both sides. But for nearly all of the drivable faces (road, offroad, boost, water and some more) only face up triangles are needed. So the first possibility to reduce the number of faces is to remove all drivable face down triangles. In the the example on the right this may save 41 of the 82 triangles (90 triangles total).
+
In the third picture you see a schematic 3D view of the second one. Watch out the black shadows. In the first picture 49 face up triangles are used and in the two other pictures only 19; this saves 61% triangles in this example. Nintendo raises the above levels about 2-4 units (100 units in this demonstration).
  
Using face down roads has also another negative effect: If jumping down to the road the player touches sometimes the face down triangle and the vehicle will drive head down for a moment into a complete wrong direction. So it is a obligation to remove the face down triangles of drivable [[KCL]] types. Not only roads, but also walls are candidate for removing triangles.
+
=== Optimize Objects ===
 +
Your level might also have too many objects. This may be caused by:
 +
* Too many objects in the KMP.
 +
* Unused objects that are still rendered.
 +
* Objects with model animations set to display in all game modes.
  
;The general rules are:
+
The easy solution would be to remove all unnecessary items from the KMP. Some decoration [[object]]s should only appear in single player mode, such as animated characters like piantas, flowers, and shy guy groups. See »[[presence flag]]s« for more details.
* Remove triangles (faces) that can never be seen. Do this for the visual model and also for the KCL.
 
* Remove triangles from the KCL that can never reached.
 
  
<br clear="all" />
+
=== Optimize Textures ===
[[file:reduce-faces-2.png|right|Much less triangles]]
+
Be sure to check the [[SZS]] for duplicated textures before releasing. You can find them by [[Texturing|browsing through the textures]] in course_model.brres. Likewise, check the mtl file for "#Distorted Textures." These are twisted or skewed copies of textures used in your level, usually used on just a single face of the model. You can find the locations of these textures on your model by replacing the distorted texture with a texture that contrasts well with the rest of the textures in your level, such as lime green or neon orange, then loading the model in-game or in the BRRES Editor. Reset the alignment of these textures on your model and re-export to eliminate the distorted duplicates.  
  
You can save much more triangles if you think 3D. See the the 3 picture at the right: green is grass, blue the road, yellow are boost and brown a small hill. In the first picture you see, that 49 triangles are used. It's because the developer thinks only in 2D and lays all triangles side by side.
+
Large resolution textures like 1024x1024 are rarely necessary and it is best practice to avoid them. Reducing the resolution of textures may help, although the impact of a few hi-res textures usually won't be noticed unless there are other problems. Just like the images below, you should try to make your images as unique as possible. You should also use the best possible texture format. Very simple gray-scaled Textures should use I4. More complex ones should use I8. If a gray-scaled image requires an Alpha Channel, it should use IA4 or IA8. For basic colored textures, you should choose CMPR. CMPR can have a better quality in Brawlbox's Importer than RGB565, which does not support an Alpha Channel and creates bigger files. RGBA32 or RGBA8 should be only used if you need True Color images with opacity, due to this file format creating large files. If you also don't know how to enable mipmaps in the MDL0 or don't need/want them, you should not create them in the Texture Importer.
  
And now let's take a look, how Nintendo did it for the newer tracks. They think 3D and define the grass level with only 2 triangles. Then they place a street 2-4 units higher and use again only a view triangles. And in a third level they place the boost parts. And the hill is also placed in the grass and may go below the grass.
+
<gallery>
 +
File:GCN Sherbet Land Water2.png|'''Figure 4a.''' A redundantly tiled texture.
 +
File:GCN Sherbet Land Water.png|'''Figure 4b.''' The same texture tiled only once.
 +
File:SNES Rainbow Road Tile2.png|'''Figure 5a.''' Another example of redundancy.
 +
File:SNES Rainbow Road Tile.png|'''Figure 5b.''' The same texture tiled only once.
 +
</gallery>
  
<br clear="all" />
+
=== Optimize KCL ===
[[file:reduce-faces-3.png|right|A 3D view]]
+
Between the time of the SZS Modifier's KCL Editor and Wiimm's KCL Tool, people used workarounds to generate a bigger KCL than the ones from original game files. After [[Chadderz]] sent [[Tock]] a Beta version of his own KCL Editor, Tock was able to create a 3.29 MB sized KCL by importing the raw model of GCN Sherbet Land twice. This has helped many people to create KCLs easier for their own Custom Tracks. Sadly, this means the SZS nowadays is blown up by much unused data. This can be fixed by simply decoding the KCL to a .obj file with Wiimms KCL Tool and re-encoding it to a KCL. The KCL files from Tock's old GCN Sherbet Land was reduced from 3.29 MB to 630 KB.  
In the third picture you see a schematic 3D view of the second one. In the first picture 49 face up triangles are used and in the two others pictures only 19; this saves 61% triangles in this example. Nintendo raises the above levels about 2-4 units.  
 
  
<br clear="all" />
+
Additionally, it is best to simplify collision not only to avoid getting snagged or stuck on parts of the level, but also so that the CPU makes fewer collision calculations as players move through the level, reducing slowdown. <!-- Collision can be huge, and shouldn't be underestimated. I recently fixed a UT2004 level that was unplayable during certain conditions by turning collision off on most of the small, decorative meshes in the map. Like night and day. - Jefe --> Creating a separate [[Solidity#Collision_Models|simplified collision model]] allows you to optimize collision in a way that does not impact the look of your level.
 
 
== Known Tracks with Slow Down ==
 
  
 +
== Known Tracks with Slow Motion Bug ==
 
; Major problems:
 
; Major problems:
* [[Bowser's Lava Road]]
+
* [[Bowser's Lava Road]] ~42 000 facepoints
* [[Daisy's Palace]]
+
* [[Daisy's Palace (Vulcanus2)|Daisy's Palace]] RC2: ~'''80 000''' facepoints, RC3: ~46 000 facepoints
* [[Dry Coast]]
+
* [[Dry Coast (Putinas)|Dry Coast]] ~40 000 facepoints
* [[GBA Ribbon Road]]
+
* [[GBA Ribbon Road (DemyxIX)|GBA Ribbon Road]] Single Player ~'''102 000''' facepoints, Multiplayer ~'''72 000''' facepoints
* [[GCN Wario Colosseum]]
+
* [[GCN Wario Colosseum (MKDasher)|GCN Wario Colosseum]] ~'''98 000''' facepoints
* [[GP Mario Beach]]
+
* [[GP Mario Beach]] ~'''90 000''' facepoints
* [[Nightmare to Dream World]]
+
* [[Grease Beach]]
 +
* [[Nightmare to Dream World]] ~'''83 000''' facepoints
 +
* [[Peach's Beach Party]] v1.5-beta ~'''101 500''' facepoints, v1.6 ~45 000 facepoints
 +
* [[River Bridge]]  
 
* [[Six King Labyrinth]]
 
* [[Six King Labyrinth]]
  
 +
; Minimal problems:
 +
* [[Yoshi Mountain]]
  
; Minimal problems:
+
; More tracks ([[:Category:Slow Motion Bug|Category ''Slow Motion Bug'']])
* [[ SNES Bowser Castle 2]]
+
<categorytree mode=pages hideroot=on showcount=on>Slow Motion Bug</categorytree>
  
 
[[Category:Bug]]
 
[[Category:Bug]]
 +
[[Category:Slow Motion Bug| ]]
 
[[Category:Optimization]]
 
[[Category:Optimization]]

Revision as of 06:23, 12 November 2020

Overview

Like a PC, the Wii is a computer system with a set amount of memory (RAM), processing (CPU) power, and graphics (GPU) power. When it does not have enough CPU or GPU power to calculate what is rendered on screen, the action on screen (the frames per second or FPS) can slow down dramatically. While this technically isn't a bug in the traditional sense, it is a symptom of poor optimization and can indicate that the track author did not test the level thoroughly before release.

Six King Labyrinth Slow Motion Bug

Types of Slowdown

There are several different types of slowdown that can occur in-game, depending on the component(s) being bottlenecked.

CPU Bottleneck

Symptoms:

  • Game slows down in 12 player online rooms.

Causes:

  • An infinite loop is occurring in a KMP route.
  • A model is using too many draw calls/materials.
  • There are too many NodeTree or NodeMix definitions.
  • There are too many particle generator objects.

GPU Bottleneck

Symptoms:

  • Game slows down in 2 player splitscreen.

Causes:

  • Culling is being used improperly (no culling at all times).
  • A model is too geometrically complex.
  • A model has improper texture coordinate scale.
  • A model's shader is using too many stages.
  • There are too many large textures onscreen at once.
  • There are too many large texture formats (RGBA8).

Troubleshooting

Optimize Model Geometry

You can find problem areas by looking at your model in SZS Modifier with the wireframe view option enabled. To optimize your model, delete as many unnecessary lines/faces/textures in your model as you can. To reduce the complexity of curves, explode curves on your model and delete intermediate lines on the curved surface. This is an important step if you are creating objects with the Follow Me tool as it can drastically reduce their complexity.

Note that OBJ exporter plugins for SketchUp are not perfect; some may cause duplication of textures if components are not exploded, while others may create garbage polygons if they are exploded. You will need to experiment to get the best results. Some authors recommended using the 3ds Max .dae exporter and BrawlBox to import models. The The HardPCM plugin is a good free option.

Figure 1. Overlapped polygons.
Figure 2. The same polygons on different planes.
Figure 3. The previous image from a different angle.

Some custom tracks define faces from both sides. But for nearly all of the drivable faces (road, offroad, boost, water and some more) only face up triangles are needed. So the first possibility to reduce the number of faces is to remove all drivable face down triangles. In the the example on the right this may save 41 of the 82 triangles (90 triangles total).

Using face down roads has also another negative effect: If jumping down to the road the player touches sometimes the face down triangle and the vehicle will drive head down for a moment into a complete wrong direction. So it is an obligation to remove the face down triangles of drivable KCL types. Not only roads, but also walls are candidate for removing triangles.

The general rules are:

  • Remove triangles (faces) that can never be seen. Do this for the visual model and also for the KCL.
  • Remove triangles from the KCL that can never be reached.

You can save much more triangles if you think in 3D. See the 3 pictures at the right: green is grass, blue the road, yellow are boost and brown a small hill. In the first picture you see, that 49 triangles are used. It's because the developer thinks only in 2D and lays all triangles side by side.

And now let's take a look, how Nintendo did it for the newer tracks. They think in 3D and define the grass level with only 2 triangles. Then they place a street 2-4 units higher and use again only a few triangles. And in a third level they place the boost parts. And the hill is also placed in the grass and may go below the grass.

In the third picture you see a schematic 3D view of the second one. Watch out the black shadows. In the first picture 49 face up triangles are used and in the two other pictures only 19; this saves 61% triangles in this example. Nintendo raises the above levels about 2-4 units (100 units in this demonstration).

Optimize Objects

Your level might also have too many objects. This may be caused by:

  • Too many objects in the KMP.
  • Unused objects that are still rendered.
  • Objects with model animations set to display in all game modes.

The easy solution would be to remove all unnecessary items from the KMP. Some decoration objects should only appear in single player mode, such as animated characters like piantas, flowers, and shy guy groups. See »presence flags« for more details.

Optimize Textures

Be sure to check the SZS for duplicated textures before releasing. You can find them by browsing through the textures in course_model.brres. Likewise, check the mtl file for "#Distorted Textures." These are twisted or skewed copies of textures used in your level, usually used on just a single face of the model. You can find the locations of these textures on your model by replacing the distorted texture with a texture that contrasts well with the rest of the textures in your level, such as lime green or neon orange, then loading the model in-game or in the BRRES Editor. Reset the alignment of these textures on your model and re-export to eliminate the distorted duplicates.

Large resolution textures like 1024x1024 are rarely necessary and it is best practice to avoid them. Reducing the resolution of textures may help, although the impact of a few hi-res textures usually won't be noticed unless there are other problems. Just like the images below, you should try to make your images as unique as possible. You should also use the best possible texture format. Very simple gray-scaled Textures should use I4. More complex ones should use I8. If a gray-scaled image requires an Alpha Channel, it should use IA4 or IA8. For basic colored textures, you should choose CMPR. CMPR can have a better quality in Brawlbox's Importer than RGB565, which does not support an Alpha Channel and creates bigger files. RGBA32 or RGBA8 should be only used if you need True Color images with opacity, due to this file format creating large files. If you also don't know how to enable mipmaps in the MDL0 or don't need/want them, you should not create them in the Texture Importer.

Optimize KCL

Between the time of the SZS Modifier's KCL Editor and Wiimm's KCL Tool, people used workarounds to generate a bigger KCL than the ones from original game files. After Chadderz sent Tock a Beta version of his own KCL Editor, Tock was able to create a 3.29 MB sized KCL by importing the raw model of GCN Sherbet Land twice. This has helped many people to create KCLs easier for their own Custom Tracks. Sadly, this means the SZS nowadays is blown up by much unused data. This can be fixed by simply decoding the KCL to a .obj file with Wiimms KCL Tool and re-encoding it to a KCL. The KCL files from Tock's old GCN Sherbet Land was reduced from 3.29 MB to 630 KB.

Additionally, it is best to simplify collision not only to avoid getting snagged or stuck on parts of the level, but also so that the CPU makes fewer collision calculations as players move through the level, reducing slowdown. Creating a separate simplified collision model allows you to optimize collision in a way that does not impact the look of your level.

Known Tracks with Slow Motion Bug

Major problems
Minimal problems
More tracks (Category Slow Motion Bug)
Category Slow Motion Bug not found