Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparency of foreground pixels ignored by 3D objects #352

Closed
snouz opened this issue Apr 7, 2024 · 12 comments · Fixed by #521
Closed

Transparency of foreground pixels ignored by 3D objects #352

snouz opened this issue Apr 7, 2024 · 12 comments · Fixed by #521
Labels
- Feature request - Qol, enhancement... - Limitation - Current engine limitation that could be broken

Comments

@snouz
Copy link
Collaborator

snouz commented Apr 7, 2024

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 snouz added the - Feature request - Qol, enhancement... label Apr 7, 2024
@snouz
Copy link
Collaborator Author

snouz commented Apr 7, 2024

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 snouz added the X No current plan but if someone wants to do it, go ahead label Apr 10, 2024
@snouz
Copy link
Collaborator Author

snouz commented Apr 15, 2024

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

@snouz snouz removed the X No current plan but if someone wants to do it, go ahead label Apr 15, 2024
@julianxhokaxhiu
Copy link

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 :)

@SamsamTS
Copy link
Contributor

@Tirlititi
Copy link
Collaborator

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.

@julianxhokaxhiu
Copy link

julianxhokaxhiu commented Apr 17, 2024

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?

@snouz
Copy link
Collaborator Author

snouz commented Apr 18, 2024

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.

@julianxhokaxhiu
Copy link

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

@julianxhokaxhiu
Copy link

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.

@snouz snouz added the - Limitation - Current engine limitation that could be broken label May 16, 2024
@EricHu33
Copy link
Contributor

EricHu33 commented Jun 9, 2024

image
The jar's render queue is transparent(defined in abr_none shader), while the character is transparent+1
image

Modifed the queue to transparent+2 will make the transparency work. but probably not intended by default.
Since abr_none are supposed to be the background layer. I guess.

IIRC, the jar itself is not transparent in original game, anyway, at least this provide an option to workaround it.

For anyone want to try themself -> modify "Your FF9 Folder\StreamingAssets\Shaders\PSX\FieldMap_Abr_None.txt"'s transparent queue to transparent+2.

@snouz
Copy link
Collaborator Author

snouz commented Jun 9, 2024

Holy shit that works!
image

2024-06-09.14-19-55.mp4
2024-06-09.14-26-25.mp4

This fixes so many problems, just changing that!

Thank you so much for looking at it!

@snouz
Copy link
Collaborator Author

snouz commented Jun 9, 2024

It also works with smoke or other effects!
2024-06-09 14_47_55-FINAL FANTASY IX - Map_ 605 (L  Castle_Serpent’s G ) _ Index_Counter_ 45_3700 _ without
2024-06-09 14_49_08-FINAL FANTASY IX - Map_ 605 (L  Castle_Serpent’s G ) _ Index_Counter_ 45_3700 _ with

snouz added a commit to snouz/Memoria that referenced this issue Jun 9, 2024
Fix by EricHu33

Co-Authored-By: EricHu <13420668+erichu33@users.noreply.github.com>
@snouz snouz linked a pull request Jun 9, 2024 that will close this issue
@snouz snouz closed this as completed in #521 Jun 9, 2024
snouz added a commit that referenced this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Feature request - Qol, enhancement... - Limitation - Current engine limitation that could be broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants