flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.38k stars 168 forks source link

Add a middle ground option between 64 and 128 transparency layers for Retroarch #1610

Open mfigueirido opened 1 month ago

mfigueirido commented 1 month ago

Is your feature request related to a problem? Please describe. I think most users like to use the safest configuration values so a majority of games run without glitches. For this seems like a good idea to set per-pixel and raise the amount of transparency layers. The problem is that in the Retroarch core you can only choose between 64 layers, which is not enough for some games in certain scenarios, or 128 which looks like a bit of an overkill (I guess having so many layers will demand more from hardware).

Describe the solution you'd like Adding a 96 layers option would be a good middle ground between those two, better balancing accuracy and performance.

flyinghead commented 1 month ago

I'm working on an improvement to set the correct number of layers for games that need it. See #622 and #1604. So far I have the following list:

Do you know of other games that require more layers than the default? In particular, ECCO the Dolphin needs it but I don't know the value.

mfigueirido commented 1 month ago

That would be great. I think Shenmue and Shenmue II need more layers too... I'll play those and ECCO and report back the values.

Anyway you might still consider adding intermediate values in RA so the testing can be done on the RA core.

Thank you!

kihato commented 1 month ago

They tend to be explosions, smoke, and magic related.

L.O.L. - Lack of Love (48 Layers) L.O.L. - Lack of Love.state.zip

https://github.com/user-attachments/assets/0135c5dd-e32e-4e45-b728-6f89eea06ada

Gaiamaster - Kessen! Seikioh Densetsu (92 Layers) Gaiamaster - Kessen! Seikioh Densetsu.zip

https://github.com/user-attachments/assets/372deb23-e032-4356-bf19-d4b9006470b8

San Francisco RUSH 2049 (over 100 Layers?) The RocketZX seems to require over 100 layers if you accelerate into a wall. San Francisco RUSH 2049 v1.001 (2000)(Midway)(NTSC)(US)[!].state.zip

https://github.com/user-attachments/assets/a8419291-e30a-4b1f-89d6-c2f81bce36e4

Conflict Zone - Modern War Strategy (128 Layers?) Conflict Zone - Modern War Strategy v1.002 (2001)(Ubi Soft)(NTSC)(US)[!].state.zip

https://github.com/user-attachments/assets/08cf46c2-778a-4a2a-9aad-c4e2f1158460

flyinghead commented 1 month ago

Wow! Thanks a lot @kihato for this work.

flyinghead commented 1 month ago

Fixed on master

mfigueirido commented 1 month ago

I couldn't get the new build but seems like ECCO the Dolphin needs 90 layers to completely fix transparency problems like this one: Ecco the Dolphin - Defender of the Future (USA) (En,Fr,De,Es)-240824-233726 Ecco the Dolphin - Defender of the Future (USA) (En,Fr,De,Es).state.zip

flyinghead commented 1 month ago

I set ECCO to use 96 layers in yesterday's commit so we should be good. I also added a 96 layers option in the libretro core.

mfigueirido commented 1 month ago

Fix confirmed! I'll report back if any other games need extra layers.

kihato commented 1 week ago

BANG! - Gunship Elite (52 Layers?) BANG! - Gunship Elite v1.003 (2000)(Red Storm)(NTSC)(US)[!].state.zip

https://github.com/user-attachments/assets/5fe6a8c1-8dcf-48b5-a324-df37788167a8

MDK 2 (110 Layers) There are many scenes that use more than the default number of layers, but this scene in particular has a large number of layers. MDK 2 v1.100 (2000)(Interplay)(NTSC)(US)[!].state.zip

https://github.com/user-attachments/assets/dccafcd0-f16b-4179-96d8-b86f01916737

Soldier of Fortune (56 Layers) Soldier of Fortune v1.001 (2001)(Crave)(NTSC)(US)[!].state.zip

Flycast-2024-09-17 18-51-24

flyinghead commented 1 week ago

Added custom max layers for these 3 games on master.

Note that to easily spot when max layers is reached, you can use this patch (for vulkan but can be adapted to other renderers):

diff --git a/core/rend/vulkan/oit/oit_shaders.cpp b/core/rend/vulkan/oit/oit_shaders.cpp
index bb99e6b2f..8d857a69b 100644
--- a/core/rend/vulkan/oit/oit_shaders.cpp
+++ b/core/rend/vulkan/oit/oit_shaders.cpp
@@ -433,6 +433,8 @@ vec4 resolveAlphaBlend(ivec2 coords) {

        // Copy and sort fragments into a local array
        int num_frag = fillAndSortFragmentArray(coords);
+       if (num_frag == MAX_PIXELS_PER_FRAGMENT)
+               return vec4(0.0, 1.0, 0.0, 1.0);

        vec4 finalColor = subpassLoad(tex);
        vec4 secondaryBuffer = vec4(0.0); // Secondary accumulation buffer

When the max number of layers is reached, the area will be painted in bright green.

kihato commented 12 hours ago

Thanks for sharing this useful method. It's much easier to find now.

Army Men: Sarge's Heroes (over 128 Layers) Army Men - Sarges Heroes.zip

Spirit of Speed 1937 (64 Layers) Please accelerate. Spirit of Speed 1937 v1.001 (2000)(LJN)(NTSC)(US)[!].state.zip

Zombie Revenge (116 Layers) Turn your back towards the enemy. Zombie Revenge v1.001 (1999)(Sega)(NTSC)(US)[!].state.zip

Demolition Racer: No Exit (44 Layers) Push two cars forward and cause them to collide. (It's difficult.) Demolition Racer - No Exit.zip

Tech Romancer (56 Layers) Defeat it using only the right trigger. Tech Romancer.zip

Vigilante 8 - 2nd Offense (64 Layers) Press the left trigger to shoot flames at the tree in front of you. Vigilante 8 - 2nd Offense v1.000 (1999)(Activision)(NTSC)(US)[!].state.zip

Fighting Force 2 (over 128 Layers) You don't have to do anything until you die. Fighting Force 2 v1.000 (1999)(EIDOS)(NTSC)(US)[!].state.zip