Emulator Issues #13711
openMetroid Prime 3 - Enabling Fog causes Pause Menu background to be Fog Color instead of normal while Scan Visor is active
0%
Description
Game Name?
Metroid Prime 3: Corruption (NTSC-USA)
Game ID? (right click the game in the game list, Properties, Info tab)
RM3E01
MD5 Hash? (right click the game in the game list, Properties, Verify tab, Verify Integrity button)
6a6fc8eb6873f80c5d240b0e89f8518c
What's the problem? Describe what went wrong.
Opening the Pause Menu while Scan Visor is active in some rooms causes the Pause Menu background to show a bright solid color. (Usually the background is "translucent" and shows a blurred screenshot of the game-play.)
This seems to only occur if "Disable Fog" is unchecked.
What steps will reproduce the problem?
First noticeable instance of this is in the room Docking Bay Access, G.F.S. Olympus
- Have "Disable Fog" unchecked in Graphics settings.
- From the beginning of the game, play the game normally (do the ship start up sequence, enter the G.F.S. Olympus.)
- Enter the room Docking Bay Access (It's the second room, from where your ship lands)
- Open the Scan Visor
- While Scan Visor is active, open the Pause Menu
Is the issue present in the latest development version? For future reference, please also write down the version number of the latest development version.
2412-80, Yes
Is the issue present in the latest release? For future reference, please also write down the version number of the latest release.
2412, Yes
If the issue isn't present in the latest release, which is the first broken version? (You can find the first broken version by bisecting. Windows users can use the tool https://forums.dolphin-emu.org/Thread-green-notice-development-thread-unofficial-dolphin-bisection-tool-for-finding-broken-builds and anyone who is building Dolphin on their own can use git bisect.)
(Not applicable)
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
[Attach any fifologs if possible, write a description of fifologs and screenshots here to assist people unfamiliar with the game.]
Pause menu background working as intended in certain rooms (Docking Bay Access, G.F.S. Olympus):
Broken pause menu background in in certain rooms (Docking Bay 5, G.F.S. Olympus):
Broken pause menu background in in certain rooms (Docking Hub Alpha, Norion):
FIFO Logs:
https://drive.google.com/drive/u/1/folders/1PPm3vu-BqsKwqQgEufTy5g9Lx99S-rFG (I think these are too large to upload directly.)
There's two FIFO recordings: one with working pause menu and one broken.
Video of the issue:
https://discord.com/channels/521709831132807179/521711075721478145/1322639965963685949 (on the Dolphin Emulator Discord server)
What are your PC specifications? (CPU, GPU, Operating System, more)
- CPU: AMD Ryzen 7 5700X 8-Core Processor
- GPU: NVIDIA GeForce RTX 3070
- OS: Windows 11 - Version 23H2
- RAM: 32GB
Is there anything else that can help developers narrow down the issue? (e.g. logs, screenshots,
configuration files, savefiles, savestates)
I originally reported this in the support-windows channel on the Dolphin Emulator Discord: https://discord.com/channels/521709831132807179/521711075721478145/1322639965963685949
JMC4789 asked if I could record fifo, so I did and sent it there. I also decided to report it here, if it makes it easier to track the issue.
My current hypothesis is that the color of the background comes from the color of the in-game fog in the room:
Graphics Settings:
Video comparing having fog enabled and disabled:
https://discord.com/channels/521709831132807179/521711075721478145/1322653272108044378 (on the Dolphin Emulator Discord server)
Files
Updated by MayImilae 17 days ago · Edited
Wow there is a lot going on with your settings. Use the portable.txt trick and without changing any graphics settings test this again. Does it still occur under default settings? And does it occur if you keep all settings default but disable fog?
Updated by Nystrata 17 days ago
- File clipboard-202501040002-ca9qu.png clipboard-202501040002-ca9qu.png added
- File clipboard-202501040003-lemvf.png clipboard-202501040003-lemvf.png added
- File clipboard-202501040003-b6n9q.png clipboard-202501040003-b6n9q.png added
- File clipboard-202501040003-asft2.png clipboard-202501040003-asft2.png added
MayImilae wrote in #note-2:
Wow there is a lot going on with your settings. Use the portable.txt trick and without changing any graphics settings test this again. Does it still occur under default settings? And does it occur if you keep all settings default but disable fog?
Downloaded a fresh copy of Dolphin 2412 with a portable.txt, only settings I changed was to set up my controller profile.
Still the same behavior:
- Disable Fog Unchecked: Broken Pause Menu with Scan Visor
- Disable Fog Checked: Working Pause Menu with Scan Visor
Here's the unchanged settings when using portable mode
Updated by MayImilae 17 days ago · Edited
So I know this bug is real. I've seen it myself, and it's been reported before too. Recently even! However, it's a dastardly bugger. Case in point...
Methodology:
Tested RM3E01 in the Docking Bay Access room during the start of the game. All graphics settings default. First tested D3D11 with a fresh run, then savestated inside Docking Bay 5 (an unaffected room), then for each video backend I loaded the state, walked in, and opened the map. Also toggled Disable Fog on then off again each time to see if there was any effect. The savestates may have had an effect on the issue but since D3D11 is the specified reproduction criteria and I tested that without them, and I savestated outside the affected space, I believe that is acceptable.
Results:
Unable to reproduce in 2412-57 in the D3D11 Backend.
Unable to reproduce in 2412-57 in the D3D12 Backend.
Unable to reproduce in 2412-57 in the OpenGL Backend.
Unable to reproduce in 2412-57 in the Vulkan Backend.
Tested on system:
Windows 11 23H2
Intel Xeon w7-3465X
NVIDIA GeForce RTX 4090 FE (driver v566.03)
Updated by Nystrata 16 days ago
MayImilae wrote in #note-5:
In the other issue report, they said this.
I'd like to add that opening and closing the HOME Menu fixes the background... until you close and open MP3's menu again, at which point the background breaks again.
Can you reproduce that behavior?
Yes - opening and closing the Wii Home Menu "fixes" the background during the Pause menu, until you unpause and pause the game again.
Updated by pokechu22 16 days ago
- Status changed from New to Accepted
RM3E01 - Docking Bay Access (Room with Broken Pause Menu) - Scan Visor Pause Menu.dff renders correctly on real hardware when using the hardware fifoplayer. It also renders incorrectly in Dolphin regardless of the video backend (as long as fog is enabled). So this is definitely a rendering bug.
Messing around with freelook, it looks like Docking Bay 5 doesn't have any fog (toggling fog doesn't do anything, and moving far away from the scene doesn't show any fog), while Docking Bay Access does have fog. It does look like the fog is being applied to the screenshot in the background.
Can I get a fifolog of the issue fixing itself with the home menu? It feels like that might be interesting for seeing what happens to the fog config in that case.
I think it also would be possible to reproduce by recording inputs using Dolphin's TAS features. Using the same portable.txt trick, you can click on MP3 in the game list and then select Movie -> Start Recording Input. This should at least theoretically be replayable on a different machine to produce the same behavior, though I don't 100% know if it'll sync. (I don't own MP3 so it wouldn't be useful for me, but MayImilae may be able to use it). Note that I remember that at least in the past recording a movie clears your save file, so that's why I recommend using portable.txt.
Updated by JosJuice 16 days ago
Note that I remember that at least in the past recording a movie clears your save file, so that's why I recommend using portable.txt.
If there is a save file already, it will use that save file. Which is usually not what you want (unless you explicitly want to record something that requires starting from a save), as it makes syncing the movie on other computers a lot harder. So I recommend using portable.txt to start with no saves and fresh settings.
Updated by Nystrata 16 days ago
pokechu22 wrote in #note-7:
Can I get a fifolog of the issue fixing itself with the home menu? It feels like that might be interesting for seeing what happens to the fog config in that case.
Sure thing:
I added it to the Google Drive folder as RM3E01 - Docking Bay Access - Scan Visor Pause Menu (Home Menu).dff
Updated by Nystrata 16 days ago
pokechu22 wrote in #note-7:
I think it also would be possible to reproduce by recording inputs using Dolphin's TAS features. Using the same portable.txt trick, you can click on MP3 in the game list and then select Movie -> Start Recording Input. This should at least theoretically be replayable on a different machine to produce the same behavior, though I don't 100% know if it'll sync. (I don't own MP3 so it wouldn't be useful for me, but MayImilae may be able to use it). Note that I remember that at least in the past recording a movie clears your save file, so that's why I recommend using portable.txt.
Here's the TAS input recording, I also put it in the Google Drive Folder as RM3E01 - TAS - Docking Bay Access - Scan Visor Pause Menu.dtm
I also simultaneously recorded a video while recording the TAS inputs, maybe it'll help with comparing: https://youtu.be/ocUh7Q1Laz0
Note, I had to turn off Dual Core for the recording to work - otherwise, the settings shouldn't be any different from a fresh config using portable mode.
Updated by pokechu22 16 days ago
Here's the relevant fog config:
BP register BPMEM_FOGPARAM0
A value: -4.015625
Mantissa: 8
Exponent: 129
Sign: -
BP register BPMEM_FOGBMAGNITUDE
B magnitude: 4194319
BP register BPMEM_FOGBEXPONENT
B shift: 1>>1 (1/2)
BP register BPMEM_FOGPARAM3
C value: 0.05882263
Mantissa: 1807
Exponent: 122
Sign: +
Projection: Perspective (0)
Fsel: Linear fog (2)
BP register BPMEM_FOGCOLOR
Red: 242
Green: 216
Blue: 179
This gets set on most frames, though once the menu is fully open, they stop setting anything other than the color (which is set to black when drawing the transparent parts of the visor. among other things, and then switched back afterwards).
When the HOME menu is open, fog gets configured each frame to this:
BP register BPMEM_FOGPARAM0
A value: 0.0009803772
Mantissa: 8
Exponent: 117
Sign: +
BP register BPMEM_FOGBMAGNITUDE
B magnitude: 4195343
BP register BPMEM_FOGBEXPONENT
B shift: 1>>2 (1/4)
BP register BPMEM_FOGPARAM3
C value: 0.05882263
Mantissa: 1807
Exponent: 122
Sign: +
Projection: Perspective (0)
Fsel: Linear fog (2)
BP register BPMEM_FOGCOLOR
Red: 242
Green: 216
Blue: 179
which also persists when you return to the pause menu. (During the HOME menu, the fog color isn't changed to black, but that starts happening again once you're back in the pause menu)
For Docking Bay 5, I see this:
BP register BPMEM_FOGPARAM3
C value: 0
Mantissa: 0
Exponent: 0
Sign: +
Projection: Perspective (0)
Fsel: Off (no fog) (0)
which disables fog and thus avoids the issue entirely.
Change to highlight fog commands in the fifo analyzer
diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp
index 8f6a54916e..5190a2fca5 100644
--- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp
+++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp
@@ -65,11 +65,15 @@ public:
bool m_start_of_primitives = false;
bool m_end_of_primitives = false;
bool m_efb_copy = false;
+ bool m_fog_command = false;
+ bool m_fog_color_command = false;
// Internal state, copied to above in OnCommand
bool m_was_primitive = false;
bool m_is_primitive = false;
bool m_is_copy = false;
bool m_is_nop = false;
+ bool m_is_fog_command = false;
+ bool m_is_fog_color_command = false;
CPState m_cpmem;
};
@@ -88,17 +92,24 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
u32 offset = 0;
u32 part_start = 0;
+ bool has_fog_command = false;
+ bool has_fog_color_command = false;
CPState cpmem;
while (offset < frame.fifoData.size())
{
const u32 cmd_size = OpcodeDecoder::RunCommand(&frame.fifoData[offset],
u32(frame.fifoData.size()) - offset, analyzer);
+ has_fog_command |= analyzer.m_fog_command;
+ has_fog_color_command |= analyzer.m_fog_color_command;
if (analyzer.m_start_of_primitives)
{
// Start of primitive data for an object
- analyzed.AddPart(FramePartType::Commands, part_start, offset, analyzer.m_cpmem);
+ analyzed.AddPart(FramePartType::Commands, part_start, offset, analyzer.m_cpmem,
+ has_fog_command, has_fog_color_command);
+ has_fog_command = false;
+ has_fog_color_command = false;
part_start = offset;
// Copy cpmem now, because end_of_primitives isn't triggered until the first opcode after
// primitive data, and the first opcode might update cpmem
@@ -109,7 +120,10 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
if (analyzer.m_end_of_primitives)
{
// End of primitive data for an object, and thus end of the object
- analyzed.AddPart(FramePartType::PrimitiveData, part_start, offset, cpmem);
+ analyzed.AddPart(FramePartType::PrimitiveData, part_start, offset, cpmem, has_fog_command,
+ has_fog_color_command);
+ has_fog_command = false;
+ has_fog_color_command = false;
part_start = offset;
}
@@ -118,7 +132,10 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
if (analyzer.m_efb_copy)
{
// We increase the offset beforehand, so that the trigger EFB copy command is included.
- analyzed.AddPart(FramePartType::EFBCopy, part_start, offset, analyzer.m_cpmem);
+ analyzed.AddPart(FramePartType::EFBCopy, part_start, offset, analyzer.m_cpmem,
+ has_fog_command, has_fog_color_command);
+ has_fog_command = false;
+ has_fog_color_command = false;
part_start = offset;
}
}
@@ -133,6 +150,10 @@ void FifoPlaybackAnalyzer::OnBP(u8 command, u32 value)
{
if (command == BPMEM_TRIGGER_EFB_COPY)
m_is_copy = true;
+ if (command >= BPMEM_FOGRANGE && command < BPMEM_FOGCOLOR)
+ m_is_fog_command = true;
+ if (command == BPMEM_FOGCOLOR)
+ m_is_fog_color_command = true;
}
void FifoPlaybackAnalyzer::OnPrimitiveCommand(OpcodeDecoder::Primitive primitive, u8 vat,
@@ -152,6 +173,8 @@ void FifoPlaybackAnalyzer::OnCommand(const u8* data, u32 size)
m_start_of_primitives = false;
m_end_of_primitives = false;
m_efb_copy = false;
+ m_fog_command = m_is_fog_command;
+ m_fog_color_command = m_is_fog_color_command;
if (!m_is_nop)
{
@@ -167,6 +190,8 @@ void FifoPlaybackAnalyzer::OnCommand(const u8* data, u32 size)
m_is_primitive = false;
m_is_copy = false;
m_is_nop = false;
+ m_is_fog_command = false;
+ m_is_fog_color_command = false;
}
} // namespace
diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.h b/Source/Core/Core/FifoPlayer/FifoPlayer.h
index 62ba207e64..92d72f6428 100644
--- a/Source/Core/Core/FifoPlayer/FifoPlayer.h
+++ b/Source/Core/Core/FifoPlayer/FifoPlayer.h
@@ -67,8 +67,10 @@ enum class FramePartType
struct FramePart
{
- constexpr FramePart(FramePartType type, u32 start, u32 end, const CPState& cpmem)
- : m_type(type), m_start(start), m_end(end), m_cpmem(cpmem)
+ constexpr FramePart(FramePartType type, u32 start, u32 end, const CPState& cpmem,
+ bool has_fog_command, bool has_fog_color_command)
+ : m_type(type), m_start(start), m_end(end), m_cpmem(cpmem),
+ m_has_fog_command(has_fog_command), m_has_fog_color_command(has_fog_color_command)
{
}
@@ -76,17 +78,24 @@ struct FramePart
const u32 m_start;
const u32 m_end;
const CPState m_cpmem;
+ const bool m_has_fog_command;
+ const bool m_has_fog_color_command;
};
struct AnalyzedFrameInfo
{
std::vector<FramePart> parts;
Common::EnumMap<u32, FramePartType::EFBCopy> part_type_counts;
+ bool m_has_fog_command = false;
+ bool m_has_fog_color_command = false;
- void AddPart(FramePartType type, u32 start, u32 end, const CPState& cpmem)
+ void AddPart(FramePartType type, u32 start, u32 end, const CPState& cpmem, bool has_fog_command,
+ bool has_fog_color_command)
{
- parts.emplace_back(type, start, end, cpmem);
+ parts.emplace_back(type, start, end, cpmem, has_fog_command, has_fog_color_command);
part_type_counts[type]++;
+ m_has_fog_command |= has_fog_command;
+ m_has_fog_color_command |= has_fog_color_command;
}
};
diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp
index 2387ecf458..f59c62af4d 100644
--- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp
+++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp
@@ -159,8 +159,15 @@ void FIFOAnalyzer::UpdateTree()
const AnalyzedFrameInfo& frame_info = m_fifo_player.GetAnalyzedFrameInfo(frame);
ASSERT(frame_info.parts.size() != 0);
+ if (frame_info.m_has_fog_command)
+ frame_item->setBackground(0, QBrush{Qt::magenta});
+ else if (frame_info.m_has_fog_color_command)
+ frame_item->setBackground(0, QBrush{Qt::green});
+
Common::EnumMap<u32, FramePartType::EFBCopy> part_counts;
u32 part_start = 0;
+ bool part_has_fog = false;
+ bool part_has_fog_color = false;
for (u32 part_nr = 0; part_nr < frame_info.parts.size(); part_nr++)
{
@@ -168,6 +175,8 @@ void FIFOAnalyzer::UpdateTree()
const u32 part_type_nr = part_counts[part.m_type];
part_counts[part.m_type]++;
+ part_has_fog |= part.m_has_fog_command;
+ part_has_fog_color |= part.m_has_fog_color_command;
QTreeWidgetItem* object_item = nullptr;
if (part.m_type == FramePartType::PrimitiveData)
@@ -186,6 +195,14 @@ void FIFOAnalyzer::UpdateTree()
object_item->setData(0, PART_END_ROLE, part_nr);
part_start = part_nr + 1;
+
+ if (part_has_fog)
+ object_item->setBackground(0, QBrush{Qt::magenta});
+ else if (part_has_fog_color)
+ object_item->setBackground(0, QBrush{Qt::green});
+
+ part_has_fog = false;
+ part_has_fog_color = false;
}
}
@@ -244,6 +261,11 @@ public:
.arg(command, 2, 16, QLatin1Char('0'))
.arg(value, 6, 16, QLatin1Char('0'))
.arg(QString::fromStdString(name));
+
+ if (command >= BPMEM_FOGRANGE && command < BPMEM_FOGCOLOR)
+ is_fog = true;
+ if (command == BPMEM_FOGCOLOR)
+ is_fog_color = true;
}
OPCODE_CALLBACK(void OnIndexedLoad(CPArray array, u32 index, u16 address, u8 size))
{
@@ -319,6 +341,8 @@ public:
}
QString text;
+ bool is_fog = false;
+ bool is_fog_color = false;
CPState m_cpmem;
};
} // namespace
@@ -366,13 +390,20 @@ void FIFOAnalyzer::UpdateDetails()
const u32 start_offset = object_offset;
m_object_data_offsets.push_back(start_offset);
+ callback.is_fog = false;
+ callback.is_fog_color = false;
object_offset += OpcodeDecoder::RunCommand(&fifo_frame.fifoData[object_start + start_offset],
object_size - start_offset, callback);
QString new_label =
QStringLiteral("%1: ").arg(object_start + start_offset, 8, 16, QLatin1Char('0')) +
callback.text;
- m_detail_list->addItem(new_label);
+ QListWidgetItem* item = new QListWidgetItem(new_label);
+ if (callback.is_fog)
+ item->setBackground(QBrush{Qt::magenta});
+ else if (callback.is_fog_color)
+ item->setBackground(QBrush{Qt::green});
+ m_detail_list->addItem(item);
}
// Needed to ensure the description updates when changing objects
The expired patent US6580430 covers the fog system in great detail (including the precision of various values, see figure 9). It's a lot of math that I'll need to look into later, though. But I feel like a value of -4 for "a" is somewhat implausible, and is likely the source of this weird behavior.
I'm curious what a fifolog in Docking Bay Access from MayImilae when the issue is not occurring would look like; would it have that same value for "a" or is it something else?
Updated by MayImilae 16 days ago · Edited
I'm curious what a fifolog in Docking Bay Access from MayImilae when the issue is not occurring would look like ...
Here you go.
I more or less recreated what Nystrata did with their fifologs, however I pointed the camera toward the center of the room so for the first ten frames or so you can visually tell if fog is on or off. Of course the fifolog records that, sure, but I like that you can just see it. It's nice.
Updated by pokechu22 15 days ago
The fog config on that one is this, for reference:
BP register BPMEM_FOGPARAM0
A value: 0.00019609928
Mantissa: 1242
Exponent: 114
Sign: +
BP register BPMEM_FOGBMAGNITUDE
B magnitude: 4195438
BP register BPMEM_FOGBEXPONENT
B shift: 1>>2 (1/4)
BP register BPMEM_FOGPARAM3
C value: 0.05882263
Mantissa: 1807
Exponent: 122
Sign: +
Projection: Perspective (0)
Fsel: Linear fog (2)
I'm not super familiar with MP3, but the HUD looks different at the start of your fifolog. The steps to reproduce both here and on #13555 say that you need to activate the scan visor first and then open the pause menu; did you do that, or did you just open the pause menu immediately?
Updated by Nystrata 15 days ago
- File clipboard-202501051406-zuwp7.png clipboard-202501051406-zuwp7.png added
- File clipboard-202501051406-z65lp.png clipboard-202501051406-z65lp.png added
MayImilae wrote in #note-12:
Here you go.
pokechu22 wrote in #note-13:
I'm not super familiar with MP3, but the HUD looks different at the start of your fifolog. The steps to reproduce both here and on #13555 say that you need to activate the scan visor first and then open the pause menu; did you do that, or did you just open the pause menu immediately?
I'm playing it back myself, and the in-game pointer cursor doesn't change before the pause menu opened, so I suspect May's fifo log didn't activate Scan Visor.
Pointer Cursor for non-Scan Visor is the dot with three lines
Pointer Cursor for Scan Visor is a hexagon
May's fifo log doesn't have the second cursor before the menu opened
Updated by pokechu22 15 days ago
Looking at these values again:
A value: -4.015625
B magnitude: 4194319
B shift: 1>>1 (1/2)
C value: 0.05882263
Projection: Perspective (0)
Fsel: Linear fog (2)
Based on renderdoc, the depth value used for fog is 9437185/16777216 (~ .5625), which is 9437185 as an integer. No Z-texturing is used, so z_blend isn't relevant. The value is 9437185 is the case everywhere (which makes sense since they're drawing a rectangle over the whole screen), so z_offset isn't relevant (we compute fog per-fragment, though, while real hardware computes it per-pixel-quad).
The patent does not specify when b shift is used, but does say that the equation is Z_e = a/(b_mag - (Z_s >> b_shf))
so it makes sense to apply it now, so 9437185>>1 = 4718592.
Fog is in perspective mode, so screen to eye space Z conversion applies, and this value is subtracted from the B value (4194319) is subtracted, producing 4194319-4718592=-524273. This is then converted from fixed-point to floating-point, so -524273/16777216 ~ -0.031249; the reciprocal is then taken to produce ~ -32.0009, and then that is multiplied by A to produce a final screen Z value of +128.5; I'm pretty sure this should normally be close to 0-1 (though it will go beyond that for areas that should be completely free of or obscured by fog), so this seems like a particularly big number. (However, this whole section is in floating-point s11e8, so this value is representable.)
Fog range adjustment is disabled, so no multiplication is performed there. The C parameter is then subtracted, producing +128.504-0.058 ~ 128.445.
The patent then says "A clamping operation is then performed at block 612 to provide Zn." The figure labels block 612 as "clamp_fix", and the output as Zn U0.11, so this is also converting to fixed-point, which becomes u0.8 after the various fog type operations at the bottom (which don't apply for linear fog).
They don't provide any information as to how clamping is performed here, but they do describe clamping earlier for choosing the z value for the pixel quad like this:
After the Sampling position is determined, Z_s is computed as
z0+zx*dx+zy*dy in s2.24
. The upper three bits are used for detecting overflow or underflow. Z_s is then clamped to U0.24 as follows:
- 000 No overflow underflow
- 01X Overflow, Z_s is clamped to 1.0 (0xFFFFFF)
- 0X1 Overflow, Z_s is clamped to 1.0 (0xFFFFFF)
- 1XX Underflow, Z_s is clamped to 0.0 (0x000000)
A value of 128 is 10000000, so 000 would be used for overflow/underflow detection, which would mean that .445 is used. That doesn't seem to give the correct results, so I'm not sure what should actually be done.