flycast icon indicating copy to clipboard operation
flycast copied to clipboard

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

Open mfigueirido opened this issue 1 year ago • 16 comments

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.

mfigueirido avatar Aug 23 '24 09:08 mfigueirido

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:

  • Blue Stinger: 80 layers
  • Panzer Front: 64 layers
  • Time Stalkers: 72 layers

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.

flyinghead avatar Aug 23 '24 19:08 flyinghead

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!

mfigueirido avatar Aug 23 '24 20:08 mfigueirido

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

kihato avatar Aug 24 '24 09:08 kihato

Wow! Thanks a lot @kihato for this work.

flyinghead avatar Aug 24 '24 09:08 flyinghead

Fixed on master

flyinghead avatar Aug 24 '24 15:08 flyinghead

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

mfigueirido avatar Aug 24 '24 21:08 mfigueirido

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.

flyinghead avatar Aug 25 '24 09:08 flyinghead

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

mfigueirido avatar Aug 25 '24 10:08 mfigueirido

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

kihato avatar Sep 17 '24 10:09 kihato

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.

flyinghead avatar Sep 18 '24 09:09 flyinghead

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

kihato avatar Sep 27 '24 15:09 kihato

Fixed on master

flyinghead avatar Oct 03 '24 16:10 flyinghead

Thanks for adding it!

I think Fighting Force 2 hits layer 128 just before the player dies. Fighting Force 2_128

This is an addition.

Evil Dead: Hail to the King (over 128 Layers) If the enemy burrows into the ground and escapes, you have failed. Evil Dead - Hail to the King v1.002 (2000)(THQ)(NTSC)(US)[!].state.zip

https://github.com/user-attachments/assets/fd9b8ca8-7f64-404d-b7f9-816d88d12c64

Nightmare Creatures II (118 Layers) Press the right trigger. The cases where it goes beyond layer 117 are very rare and occur when there is a good overlap with the player's texture. Nightmare Creatures II v1.000 (2000)(Konami)(NTSC)(US)[!].state.zip

Nightmare Creatures II_128

kihato avatar Oct 04 '24 02:10 kihato

By the way, just tested now Blue Stinger. The maximum layers override seems to be working in standalone but not in Libretro: imaxe

This is another topic but, maybe having an "auto" setting enabled by default would be better? This way the app acts in a more transparent way. If you select 32 layers you'll get only 32, if you select auto it will use the overrides.

mfigueirido avatar Oct 07 '24 21:10 mfigueirido

The OIT Max Layers overrides were indeed ignored in the libretro core. Should now be fixed on master.

flyinghead avatar Oct 08 '24 15:10 flyinghead

Fix confirmed.

mfigueirido avatar Oct 08 '24 20:10 mfigueirido