PrismaticFlower / shaderpatch

Improved shaders (and fun stuff for modders) for Star Wars Battlefront II (2005) - Incompatible with Classic Collection
MIT License
39 stars 2 forks source link

First person models can incorrectly appear behind other models when OIT is enabled. #98

Closed PrismaticFlower closed 2 years ago

PrismaticFlower commented 4 years ago

This is likely being caused by the fact the game draws first person models after everything else. And when it does draw them SP doesn't yet know the game is done drawing transparent geometry and it should resolve the OIT. And to save space SP only creates OIT aware shaders for the shaders that use transparency. This results in the shaders drawing the opaque first person models just drawing them directly to the current rendertarget directly. Then when the OIT is resolved (probably immediately afterwards) it is done on top of the first person model, even if it should be behind it.

Fixing this is probably going to be low priority for me for a couple reasons. Firstly you can just switch OIT off if you play in first person, either in the user config or (and I'm ashamed to be suggesting this) the dev screen ingame when you load a map that encourages first person play. Secondly I'm not sure how to fix this exactly, we could also add OIT aware versions of opaque shaders, but SP (as of v1.1) already has 2714 unique pixel shaders, doing that would probably add on another 1000. Not a great solution.

A more promising thing to try and do would be to make the conditions for deciding when to resolve OIT smarter. Possibly by detecting when a shader is bound that doesn't have an OIT aware version and doing it then. It's possible this could have it's own downsides, it'd need more thought and testing before to make sure it worked right.