TASEmulators / desmume

DeSmuME is a Nintendo DS emulator
http://desmume.org
GNU General Public License v2.0
3.02k stars 552 forks source link

Pokemon Ranger (E) - Swapped Layer order on OpenGL 3.2 Render #24

Closed DarkSwan86 closed 7 years ago

DarkSwan86 commented 7 years ago

On the character selection screen, on OpenGL render the character silouette is in front of the character itself:

0986 - pokemon ranger e ogl

Softrenderer is fine: 0986 - pokemon ranger e soft

--- ROM INFO --- ROM game code: ARGP ROM serial: NTR-ARGP-EUR ROM chipID: 00001FC2 ROM internal name: POKE RANGER ROM developer: Nintendo

--- PC INFO --- CPU: Intel i5-4670K GPU: AMD Radeon 7950 Driver version: Crimson ReLive Edition 16.12.2 (December 2016) OS: Windows 7 x64

rogerman commented 7 years ago

This is a regression from r5372, which attempted to rework shadow polygon rendering.

What you're seeing here is the OpenGL renderer's inability to handle a special rendering condition: If a translucent polygon's fragment is to render on top of another fragment with the same TRANSLUCENT polygon ID, then reject the fragment.

SoftRasterizer does handle this special condition. In r5371, OpenGL also handled this special condition by using the stencil buffer to store TRANSLUCENT polygon IDs. But in r5372, the stencil buffer was repurposed for handling OPAQUE polygon IDs to improve shadow polygon rendering, so the ability to handle TRANSLUCENT polygon IDs in the stencil buffer was lost. In the current revision of the code, OpenGL still continues to use the stencil buffer for OPAQUE polygon IDs for the purpose of emulating shadow polygons properly.

So this issue hits on one of the two remaining special rendering conditions that the OpenGL renderer still needs to emulate. It will take some time to figure out exactly how to do this, but fixing this one will not only help this game, but also help a myriad of other games that depend on emulating this special condition.