massimilianodelliubaldini / ac7-ultrawide

Mod AC7 to work at ultrawide resolutions.
MIT License
80 stars 24 forks source link

Mission 7 HUD backgrounds changed #6

Closed massimilianodelliubaldini closed 5 years ago

massimilianodelliubaldini commented 5 years ago

A game update must have changed which shaders are used for the HUD backgrounds when you get struck by lightning. I may have to fix these too, but the game has more updates to come... What else could change?

WinkelCode commented 5 years ago

It would probably be worth it to look into some way of automatically detecting and correcting these shaders.

I highly recommend joining the 3Dmigoto Discord: https://discord.gg/tXHYhNK (My username is MartinsDiscordAccount#9854)

I don't know how to go about creating some detection mechanism but it's worth a try if we can coordinate it and get some help from the 3Dmigoto devs on the server.

massimilianodelliubaldini commented 5 years ago

I'm on that discord as well.

Combing through the d3dx.ini file, I found out that 3Dmigoto supports real-time regex replacement of shader calculations. After doing a little finagling, not only was I able to make the HUD work without any other shader files (except for the subtitles one), I also fixed the regression in Mission 7 and the SP Mission HUD as well!

All I did was remove all the shader files, except the one for subtitles, and added these lines to the d3dx.ini file:

[ShaderRegex2]
shader_model = ps_5_0

[ShaderRegex2.Pattern]
(mul r\d+\.[wxyz]{1}, cb1\[127\]\.y, l\(1\.77777779\)[\S\s]+\K)movc (?P<register>r\d+\.[wxyz]{1}), r\d+\.[wxyz]{1}, r\d+\.[wxyz]{1}, r\d+\.[wxyz]{1}

[ShaderRegex2.Pattern.Replace]
${0}\nadd ${register}, ${register}, l(-0.1719)

I'll put this in a pull request in a little bit to explain what's going on.

There's also still the issue of replacing the 0.1719 value with a calculation based on the user's monitor, but we can make that replacement in the ini itself.

WinkelCode commented 5 years ago

Awesome! I already suspected that someone with Regex experience could build a proper solution here. (This also means we are avoiding issues related to modified shaders that are based on an older dump)

The subtitle thing might also be worth another look I think, it works well enough for the moment but I really don't like that it affects both the bottom text during cutscenes and the normal top one, this usually isn't an issue but sometimes the top text shows during parts where it still thinks there is a cutscene, resulting it offset text and missing/misplaced avatar background.

It might be possible to determine the actual position of the rendered text using a Regex pattern instead of the current workaround by checking for the presence of I believe I used some HUD related shader.

massimilianodelliubaldini commented 5 years ago

Fixed with PR #8. I'll open a new issue for improving the subtitle handling.