Fix Image Distortion: ScaleFX9 In Ymir Emulator

Alex Johnson
-
Fix Image Distortion: ScaleFX9 In Ymir Emulator

Hey guys! Let's dive into fixing that annoying image distortion you might be seeing when using the ScaleFX9 shader with the Ymir emulator in fullscreen mode. This issue seems to pop up specifically when you're rocking a 4K display and have DPI scaling disabled. So, if your 2D games are looking a bit wonky, you're in the right place!

Understanding the Issue

So, you're firing up your Ymir emulator – maybe to relive some classic Saturn goodness – and decide to use ShaderGlass to make those pixels shine with the ScaleFX9 shader. Everything seems cool until you notice something's off. The image looks warped, kind of like it's bulging in the middle, and straight lines? Forget about them! They're all curvy and weird. This is particularly noticeable in 2D games, where those straight lines are super important. Now, here's the kicker: when you use the same shader in RetroArch, everything looks perfect. So, what gives? Well, it seems like ShaderGlass is interpreting the projection or geometry pass differently, especially when running in fullscreen on a 4K monitor with custom DPI settings. The problem appears when the ScaleFX9 shader is applied through ShaderGlass. The image gets a barrel-shaped distortion, and the vertical and horizontal lines lose their alignment, regardless of the aspect ratio settings. This doesn't happen when the same shader is used in RetroArch. Knowing this we can narrow down the possibilities of where the issue is coming from and what possible fixes we can try, to resolve this issue.

Basically, the shader should upscale the image cleanly, keeping that classic 4:3 aspect ratio without any of that barrel distortion or weird curving at the edges. It's all about maintaining the correct proportions and keeping those lines straight and true.

Why This Happens

This issue seems to be related to how ShaderGlass handles the scaling and projection in fullscreen mode, especially when DPI scaling is disabled. When DPI scaling is off, the emulator and ShaderGlass need to work together to properly scale the image to fit your 4K display. It looks like there's some miscommunication happening, leading to the distortion. This is why RetroArch, which likely has its own way of handling scaling, doesn't run into the same problem.

Think of it like this: your emulator is trying to send a perfectly square image, but ShaderGlass is stretching it out of shape before it hits your screen. This is why you see that warping effect, and it's super noticeable on anything with straight lines or geometric shapes.

Steps to Reproduce the Distortion

Want to see if you're experiencing the same issue? Here’s how you can reproduce the distortion:

  1. Run your Ymir emulator in fullscreen mode.
  2. Open up the ShaderGlass overlay.
  3. Load the scalefx-9x.slangp shader.
  4. Set the pixel size to 9x (to match your 4K resolution).
  5. Disable DPI scaling on the Ymir executable (this is key!).
  6. Launch a 2D game (like Marvel vs. Street Fighter for Sega Saturn) and observe the distortion, especially on the character select screen.

If you see warped images and misaligned lines, you've got the same issue we're talking about!

Proposed Solutions to Fix Image Distortion

Alright, let's get down to brass tacks and talk about how we can fix this. Here are a few ideas that could help:

1. Disable Geometry Warping

One potential solution is to add an option in ShaderGlass to completely disable any geometry warping. This would ensure pixel-perfect scaling, which is exactly what we need for shaders like ScaleFX9 that don't require any curvature or special effects. This “Flat Output Mode” toggle would force a 1:1 rectangular projection for 2D content, ensuring that every pixel is displayed correctly without any distortion.

2. Improve Scaling Alignment

Another approach is to improve how ShaderGlass handles scaling when system DPI scaling is disabled. The goal is to match the behavior of RetroArch, which seems to be doing things right. This might involve tweaking the scaling algorithms or how ShaderGlass interacts with the emulator's output.

3. Debug Overlay

A handy tool for users would be a debug overlay that shows the active aspect ratio and warp values. This would allow you to see exactly what ShaderGlass is doing to the image and help verify whether the geometric correction is working as expected. It's all about transparency and giving you the information you need to troubleshoot.

Diving Deeper into the Technical Aspects

So, what's really going on under the hood? This issue seems to stem from how ShaderGlass interprets the projection or geometry pass in fullscreen mode on 4K monitors with custom DPI settings. When you disable DPI scaling, you're essentially telling Windows to leave the scaling up to the application (in this case, Ymir and ShaderGlass). This can lead to inconsistencies if the application doesn't handle scaling correctly.

The same shader file works perfectly in RetroArch because RetroArch likely uses a different scaling method or has specific code to handle DPI scaling. It's all about the implementation details, and it seems like ShaderGlass needs a bit of tweaking to play nice with Ymir in this particular setup.

How You Can Help test fixes or beta builds for this issue

If you're feeling adventurous, you can help test any fixes or beta builds that address this issue. The more people who can try things out and provide feedback, the better the chances of finding a solid solution. It's a team effort, and your input is valuable!

To help, you'll want to:

  • Stay tuned for updates from the ShaderGlass developers.
  • Download and test any beta versions or experimental builds.
  • Provide detailed feedback on your experience, including what worked, what didn't, and any observations you have.

Conclusion

So, there you have it! Image distortion when using the ScaleFX9 shader in fullscreen mode with the Ymir emulator can be a real headache, but hopefully, with a few tweaks and improvements, we can get things looking pixel-perfect. Whether it's disabling geometry warping, improving scaling alignment, or adding a debug overlay, there are plenty of potential solutions to explore. Stay tuned for updates, and happy gaming!

For more information on shaders and retro gaming, check out Libretro.

You may also like