Welcome, Guest.
Username: Password: Remember me

TOPIC: Aspect ratio adjustment shader

Aspect ratio adjustment shader 2 months 1 week ago #1

So i've been wondering if there exists any dedicated shader for adjusting vertical or horizontal dimension of the screen, thus making it possible to correct aspect ratio. There're still many older games that don't have widescreen support or such support is simply impossible due to the nature of the game assets (2D backgrounds, for example). Simple shader for stretching or shrinking dimensions could be real life-saver. For example, "zooming" into 4:3 2D adventure game, sacrificing some part of the image in the buttom and/or from above but achieveing unstretched widescreen.
Last Edit: 2 months 1 week ago by Talley Rand.
The administrator has disabled public write access.

Aspect ratio adjustment shader 1 month 3 weeks ago #2

I made shader for that. You can download it by right-clicking on "Raw" button and "Save target as".
github.com/Fubaxiusz/fubax-shaders/blob/...aders/AspectRatio.fx

Tell me if it works fine for you ;)
Last Edit: 1 month 3 weeks ago by Fu-Bama.
The administrator has disabled public write access.
The following user(s) said Thank You: Talley Rand

Aspect ratio adjustment shader 1 month 3 weeks ago #3

Hey Fu-Bama, the shader produces this error:
AspectRatio.fx(35,17-30): error X4502: invalid ps_5_0 input semantic 'SV_POISITION'
It's a pretty easy fix, just letting you know it's there. :)

By the way, is it possible to make the shader a bit more exact? Finding the value to perfectly convert 16:9 to 4:3 for example is just a lot of guesswork and the end result may not be perfect. Maybe inputs for current aspect ratio and target aspect ratio would work? Thanks. :cheer:
The administrator has disabled public write access.

Aspect ratio adjustment shader 1 month 3 weeks ago #4

Thank you, that was good catch. For some reason error did not show up for me, it's fixed now. ;)

Making exact shader is possible, but there is already dedicated feature for that in graphics card control panel Adjust desktop size and position, where you can set up if the game should be stretched, have black bars or be clipped if proportions don't match monitor native.
Warning: Spoiler! [ Click to expand ]


This shader is more for hiding black bars, e.g. Mirrors Edge creates black bars to 16:9 that are painted, so GPU settings don't affect that.
Tell me if it works, or you really want exact values.
The administrator has disabled public write access.

Aspect ratio adjustment shader 1 month 2 weeks ago #5

Or you can simply declare proper custom resolutions and choose "no scaling".
On NVidia GPUs "No scaling" works well with NO GPU forcing (display only scaling) if the height of the frame matches the monitor native one (4:3 -> 1440x1080, 16:10 -> 1728x1080 on a 1920x1080 panel)
Last Edit: 1 month 2 weeks ago by lowenz.
The administrator has disabled public write access.

Aspect ratio adjustment shader 1 month 2 weeks ago #6

Fu-Bama wrote:
I made shader for that. You can download it by right-clicking on "Raw" button and "Save target as".
github.com/Fubaxiusz/fubax-shaders/blob/...aders/AspectRatio.fx

Tell me if it works fine for you ;)

Thank you so much! This is exactly what i was looking for. Fine ratio adjustment with the feature to zoom in. I've tested it with a couple of 3d and 2d games and it worked flawlessly so far.
The administrator has disabled public write access.