Project

General

Profile

Actions

Emulator Issues #13783

open

Vertex color lingering behavior not emulated

Added by liyliyliyliy 3 days ago. Updated about 18 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

What's the problem? Describe what went wrong.

The Wii has another hardware quirk similar to the one fixed in build 2409-150, but with vertex colors. if you draw an object with vertex colors, but draw objects after that without vertex colors, and if you have the channel control set to take in vertex colors, then the objects drawn will take on the color of the last vertex color sent in the last object with vertex colors. this affects 0 games that i know of

What steps will reproduce the problem?

I believe these steps only work if there is lighting and both objects have normals.

  1. Draw an object with vertex colors
  2. Draw an object without vertex colors, without making the color channel control stop using vertex colors as an input
    The second object will take on the color of the last vertex in the first object on console, but on Dolphin the second object will take on a white color.

Is the issue present in the latest development version? For future reference, please also write down the version number of the latest development version.

Yes, 2503-200.

Is the issue present in the latest release? For future reference, please also write down the version number of the latest release.

Yes, 2503

If your issue is a graphical issue, please attach screenshots and record a three frame fifolog of the issue if possible. Screenshots showing what it is supposed to look like from either console or older builds of Dolphin will help too. For more information on how to use the fifoplayer, please check here: https://wiki.dolphin-emu.org/index.php?title=FifoPlayer

A fifolog is attached. A screenshot of the software running on console is attached, of the scene correctly rendered incorrectly. A screenshot of the software running on Dolphin is attached, of the scene incorrectly rendering correctly.

Eventually, I'll make a dedicated application for demonstrating this quirk and share it.


Files

guy-vcolcache.7z (3.73 MB) guy-vcolcache.7z Fifo log. liyliyliyliy, 04/12/2025 03:33 PM
colcachebugconsolenobug.png (425 KB) colcachebugconsolenobug.png Console screenshot. liyliyliyliy, 04/12/2025 03:33 PM
dolphcolcachebug.png (685 KB) dolphcolcachebug.png Dolphin screenshot. liyliyliyliy, 04/12/2025 03:34 PM

Related issues 3 (2 open1 closed)

Related to Emulator - Emulator Issues #9268: Super Smash Bros. Brawl custom character Lloyd renders incorrectlyAccepted

Actions
Related to Emulator - Emulator Issues #12987: Graphical Issues - Lego Indiana Jones: The Original AdventuresFixed

Actions
Related to Emulator - Emulator Issues #13184: Super Mario Sunshine - Coconut drinks in Gelato Beach bar are invisible due to using nonexistent vertex color (conflicts with debug cubes fix)New

Actions
Actions #1

Updated by Billiard26 2 days ago

I have limited graphics knowledge, but this is maybe related/duplicate of #9474 ?

Actions #2

Updated by liyliyliyliy 1 day ago

I believe that the issue in 9474 is per pixel, but this issue is per-vertex (for reference, this issue still occurs in the software renderer, but 9474 doesn't.) A very similar fix for vertex normals, binormials, and tangents is already in Dolphin, but not for vertex colors.

Actions #3

Updated by pokechu22 1 day ago

I assume this is #8059 / #13184, which is currently worked around with a per-game color fallback in this case instead of trying to preserve the last value.

I thought I tried using a single lingering value and it didn't work for the debug cubes. That was a long time ago though, so maybe I did something wrong.

Actions #4

Updated by pokechu22 1 day ago

A dedicated test application would be appreciated.

I remember trying to write one a while back but I just confused myself when trying to determine if it immediately affected other vertices or there was a delay, and which vertex was used. I remember it seeming like there were multiple colors that could be buffered and it would use them in sequence, and I also ended up getting a point to end up showing as two separately colored triangles. It also seemed to vary based on how much data was associated with each vertex (if there were more texture coordinates, it would affect other vertices sooner). I probably still have this test somewhere, but I don't remember exactly where, and I was also messing around with other things (in particular I think I had mismatched color counts between XFMEM_VTXSPECS (0x1008), XFMEM_SETNUMCHAN (0x1009), and BPMEM_GENMODE (0x00)) which may have been more complicated and less useful.

The main quirks that would matter for implementation are if it uses the color from the last drawn vertex, and if that color is immediately used or if it waits a few vertices. (For LIT my somewhat lazy experimentation indicated that it used the last drawn vertex's normal immediately).

Actions #5

Updated by pokechu22 about 21 hours ago

  • Related to Emulator Issues #9268: Super Smash Bros. Brawl custom character Lloyd renders incorrectly added
  • Related to Emulator Issues #12987: Graphical Issues - Lego Indiana Jones: The Original Adventures added
  • Related to Emulator Issues #13184: Super Mario Sunshine - Coconut drinks in Gelato Beach bar are invisible due to using nonexistent vertex color (conflicts with debug cubes fix) added
Actions #6

Updated by pokechu22 about 21 hours ago

I did a quick test with the software renderer:

diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
index b655a3143b..f3859c728f 100644
--- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
+++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
@@ -167,13 +167,7 @@ static void ReadVertexAttribute(T* dst, DataReader src, const AttributeFormat& f
 static void ParseColorAttributes(InputVertexData* dst, DataReader& src,
                                  const PortableVertexDeclaration& vdec)
 {
-  const auto set_default_color = [](std::array<u8, 4>& color) {
-    color[Tev::ALP_C] = g_ActiveConfig.iMissingColorValue & 0xFF;
-    color[Tev::BLU_C] = (g_ActiveConfig.iMissingColorValue >> 8) & 0xFF;
-    color[Tev::GRN_C] = (g_ActiveConfig.iMissingColorValue >> 16) & 0xFF;
-    color[Tev::RED_C] = (g_ActiveConfig.iMissingColorValue >> 24) & 0xFF;
-  };
-
+  static std::array<std::array<u8, 4>, 2> colors;
   if (vdec.colors[0].enable)
   {
     // Use color0 for channel 0, and color1 for channel 1 if both colors 0 and 1 are present.
@@ -181,7 +175,7 @@ static void ParseColorAttributes(InputVertexData* dst, DataReader& src,
     if (vdec.colors[1].enable)
       ReadVertexAttribute<u8>(dst->color[1].data(), src, vdec.colors[1], 0, 4, true);
     else
-      set_default_color(dst->color[1]);
+      dst->color[1] = colors[1];
   }
   else
   {
@@ -189,9 +183,11 @@ static void ParseColorAttributes(InputVertexData* dst, DataReader& src,
     if (vdec.colors[1].enable)
       ReadVertexAttribute<u8>(dst->color[0].data(), src, vdec.colors[1], 0, 4, true);
     else
-      set_default_color(dst->color[0]);
-    set_default_color(dst->color[1]);
+      dst->color[0] = colors[0];
+    dst->color[1] = colors[1];
   }
+
+  colors = dst->color;
 }
 
 void SWVertexLoader::ParseVertex(const PortableVertexDeclaration& vdec, int index)

The debug cubes in Mario Sunshine were still present, but it did restore the coconut drinks. It also produced accurate results for Lego Indiana Jones (see #12987) and Lloyd from modded brawl (#9268). I can make the same change for the hardware renderers, but doing this will conflict with the current debug cube workaround.

Actions #7

Updated by liyliyliyliy about 18 hours ago

Im also not entirely sure what triggers the lingering either. In my application, if I drew 5 triangles of the eyebrow object (the last object with vertex colors drawn before the textured objcets), then the vertex colors would reset to white on hardware, but if I drew 6, 7, or all 8, then the colors would linger. Perhaps something is overflowing and automatically flushing? Im making stuff up, I have no idea how the FIFO works.

Actions #8

Updated by liyliyliyliy about 18 hours ago

thus my lack of real ability to make a reliable test application. I don't know what triggers the quirk!

Actions

Also available in: Atom PDF