Memoria icon indicating copy to clipboard operation
Memoria copied to clipboard

Transparency of foreground pixels ignored by 3D objects

Open snouz opened this issue 2 months ago • 1 comments

image

Background alpha is working correctly between background layers (so I can have soft edges between foreground and scrolling sky for example) but if a layer is on top of a 3D object, it will appear as alpha 1 or 0, never in between.

In the same way anti-aliasing turned out to be an easy feature, maybe this is fixable as well?

snouz avatar Apr 07 '24 14:04 snouz

A good example here

image

Alpha on the jar is partially transparent, showing parts of the layer under, but never a 3D object. If someone is knowledgeable in shaders...

image

snouz avatar Apr 07 '24 17:04 snouz

@SamsamTS, Tsuna mentioned that you might know some things about this? This has been itching me since I began working on the mod.

snouz avatar Apr 15 '24 01:04 snouz

Hey @snouz Tsuna brought me here. I don't have direct experience with Unity shaders but I might try to help you on the general concept. But before doing that, would you be so kind pointing me where can I find the shader code ( if any around ) and where the shader logic is applied for those specific cases? Thanks :)

julianxhokaxhiu avatar Apr 15 '24 20:04 julianxhokaxhiu

@julianxhokaxhiu There is this https://github.com/Albeoris/Memoria/tree/main/Memoria.Patcher/StreamingAssets/Shaders Unsure if it's of any help.

SamsamTS avatar Apr 15 '24 20:04 SamsamTS

The shaders used for field objects are mainly:

  • PSX/FieldMapActor for the 3D models of the characters,
  • PSX/FieldMap_Abr_None for the backgrounds (there are also other Abr shaders used, in particular the FieldMap_Abr_1 for most semi-transparent background layers, like lights, but I think Abr_None is what is involved in all those problems anyway as it originally wasn't meant to handle gradual transparency at all).

Also, it might help to look at my C# code in FieldCreatorScene because it's a relatively compact class that handles the rendering of the fields, with much fewer subtleties than the usual in-game machinery. In particular, it setups the parameters _OffsetX, _OffsetY, _MatrixRT etc. that are used in the shader's code.

Tirlititi avatar Apr 15 '24 21:04 Tirlititi

Thanks a lot for the comments. I'll try to run some investigations here and I'll let you know my findings :) Is this a core issue or happening only with Memoria installed? If the latter, which version can I use to test? latest is good? Also can you please provide a save game where I can repro the scene above?

julianxhokaxhiu avatar Apr 17 '24 18:04 julianxhokaxhiu

Thanks for looking at this! Here are saves for the whole game: SavedData_ww.zip You can see this happening all through the game, here's the same example from vanilla: image You can see it happening, because instead of having pixels from the model, we have pixels from the underlayer in green In fact you can even see the scrolling: image image And since there are no grey alpha pixels in vanilla, this is actually a result of the smoothing between black and white alpha pixels that become grey at the display level.

I don't know much about the issue, only that the result of my work is greatly reduced by this limitation. whether I leave grey alpha or limit myself to 2 colors, it will look like shit at the limit with models.

snouz avatar Apr 18 '24 20:04 snouz

Thanks a lot @snouz I'll investigate and come back to you

julianxhokaxhiu avatar Apr 19 '24 08:04 julianxhokaxhiu

So I did try to start looking into this, thank you very much for the save game. Have you got experience using RenderDoc on top of FF9? I did try and so far I'm not able to make it work, it seems to not detected the rendering API somehow. I wanted to start from there as it's amazing way to look at what the GPU is doing.

I did try with the vanilla installation, but let me know. I'll try also with Memoria just in case, but this is where I am so far. I'll keep you posted.

julianxhokaxhiu avatar Apr 20 '24 15:04 julianxhokaxhiu