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

Question about forcing an aspect ratio that isn't the same as the current resolution #11738

Closed
mrfixit2001 opened this issue Jan 21, 2019 · 16 comments
Milestone

Comments

@mrfixit2001
Copy link
Contributor

So the issue at hand is that if I select a 4:3 resolution on a widescreen monitor/tv, most of these displays have a native aspect ratio of 16:9. These displays have a setting in them that will automatically stretch the 4:3 display to take up the full screen, which obviously distorts the image. Not all displays have the ability to turn this off. So the workaround for it would need to be a setting that could be turned on and off. I don't know of such a feature currently in ppsspp.

I recently had to fix this in another emulator by editing the rendering math to detect if the current resolution aspect was 4:3 and then (if a config setting was set to on) it would recalculate what the 16:9 resolution would be and render a distorted (skinny) display so that when the monitor stretched the image it actually resulted in the correctly scaled display.

For example, (and using some rounded numbers) 800x600 (which is 4:3) is stretched by the monitor to an emulated 16:9, which is 1067x600. So even though the output is 800x600 it's stretched to 1067x600. In order to properly render the image that would stretch back to the correct display ratio I had to force it to render 533x600, as that will stretch it back out to 800x600. Crazy, right?

I'm looking at a need to do the same edit to ppsspp (if I have to), but you guys are usually really responsive to my questions so I wanted to ask if ANYTHING like this exists somewhere in your code already. Is there anywhere for me to override the detected resolution? If not, can you please at least point me to the right location in your code so that I can start doing some testing? My system is an ARM SBC using SDL and GLES on a Mali 450 GBM driver. So I assume I should be starting somewhere in your GLES rendering code. Thanks in advance!

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 21, 2019

Look into Display Layout Editor stretching options, if I recall it had a weird almost 4:3 stretching for BlackBerry devices in the past. It could possibly also support custom stretching, through it doesn't as cases like yours are extremely rare/weird and only ruin the quality. Just to note you could as well just stretch the image with a custom postprocess shader.

Edit: Actually I was overthinking. Just using normal stretching instead of automatic scaling(in display layout editor) should be enough in what you want. Stretching to fill 16:9 display does slightly deform PSP resolution which isn't exactly 16:9, but this is soo minimal it's only a concern of pixel perfect quality, not really giving a noticeable deformation for aspect ratio and quality in your case is already ruined by abusing modern display outside of it's native res&ratio.

@hrydgard
Copy link
Owner

Yeah, stretching to display should do it. But what kind of monitors are you using that still don't support native 16:9 resolutions? Some strange widescreen arcade monitors?

@mrfixit2001
Copy link
Contributor Author

Thank you both! I'll test this and close if I'm able to get it working. Sounds promising.
Just for more info, it's not that the monitor doesn't support 16:9, it's that the resolution with optimal performance is a 4:3 resolution, so I want to set that resolution as a default but I don't want to assume that a user's widescreen monitor will have the option to turn off the stretching feature.

@mrfixit2001
Copy link
Contributor Author

So I'm trying to get the display layout editor to work but the interface doesn't seem to be working correctly. I can set the scale and orientation but selecting move or resize does nothing and the selection cursor seems to disappear often. I'll try a newer commit than I'm on, maybe it was a bug that got fixed. But just in case, can sometime give me a quick tutorial on how the specific settings in the INI file work?

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 22, 2019

Move and resize change what you do with touch/mouse cursor when interacting with the screen visualization(grayish rectangle). What you were told to do through doesn't involve neither moving or resizing, you simply have to swith "Options" from default "auto scaling" to "stretching".

This screen was made for touch/mouse input and can't be fully utilized by keyboard/gamepad only. The selection doesn't really disappear, it's just that pressing direction buttons can cycle through noninteractive parts of the interface since again it was made for touch or mouse input only.

@mrfixit2001
Copy link
Contributor Author

mrfixit2001 commented Jan 22, 2019 via email

@mrfixit2001
Copy link
Contributor Author

Will continue messing with it, but so far have not yet been successful. Using the mouse and clicking/dragging was the missing element to using the display layout editor, so thank you greatly for that. Thus far we haven't been able to figure out how to change the resulting aspect ratio to be "thinner".

@mrfixit2001
Copy link
Contributor Author

mrfixit2001 commented Jan 23, 2019

literally spent hours trying different things... here's what I learned...

  • the display layout editor screen is awful to navigate :(
  • the screen does not allow me to adjust anything with the mouse except position and scaling when I select scaling. If I select anything else there is nothing I can do with the mouse at all, I cannot adjust HOW the screen is stretched.
  • selecting partial stretch adds black bars above and below the screen, but I need them on left and right
  • the latest commit has a display glitch with SDL/GLES and doesn't display in the center of the screen (not even the menu), identical config with any other version does not have this issue. This is fixed by adding "--fullscreen" to the parameters but obviously that's not actually what I need to accomplish per this issue

So let me ask again, please, is there a way to stretch the screen's height and width separately at different scales to result in a non-standard aspect ratio? And if so, can you PLEASE provide some tips on how to set this in the INI file rather than using the screen?

@hrydgard
Copy link
Owner

hrydgard commented Jan 23, 2019

stretch

The "Stretching" mode here does what you want on Windows. It's possible that there's some bug on SDL, need to look into that. Tagging for 1.8.0

Also, the display layout editor is not the best, it needs a rework or removal...

@hrydgard hrydgard added this to the v1.8.0 milestone Jan 23, 2019
@mrfixit2001
Copy link
Contributor Author

Thanks @hrydgard for the screenshot. I can definitely see that screen, but I cannot interact with the box at all to actually change it's shape/size. Can you please provide some guidance on the settings in the INI file so that I can try to adjust this manually without the screen?

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 23, 2019

As said above there's no way to edit the aspect ratio / width and height separately neither on that screen or ini files. The only way you can do that without building your own, customized ppsspp version is to use post process shader to resize the screen for you in a way you desire, ie a shader like this:

uniform sampler2D sampler0;
varying vec2 v_texcoord0;

void main() {
        float xdivision = 1.0;
        float ydivision = 1.0;
	vec3 color = texture2D(sampler0, vec2(v_texcoord0.x * xdivision - (0.5 + xdivision / 2.0 - 1.0), v_texcoord0.y * ydivision - (0.5 + ydivision / 2.0 - 1.0))).xyz;
	gl_FragColor.xyz=color;
	gl_FragColor.a = 1.0;
}

Or similar, I wrote that quickly based on basic fxaa.

Display Layout Screen was made when people were requesting integer zoom and ability to place smaller window into any place on the screen they wanted(ie to not be obscured by on screen touch controls which btw uses pretty much same interface and is also not possible to use via gamepad. That screen is neither useless nor bad, it simply was never made for what you want and if the stretching doesn't do the job on your system, it's probably some platform specific issue since stretching should fill the display and it does so as planned when setting modern 16:9 display into 800x600 resolution and launching ppsspp under Windows 10.

@hrydgard
Copy link
Owner

Ignore the square, just by setting it to "Stretching" it should be ok, right?

If not, try to tweak the settings in the .ini file, memstick/PSP/SYSTEM/ppsspp.ini

@mrfixit2001
Copy link
Contributor Author

mrfixit2001 commented Jan 23, 2019

@LunaMoo - thanks for the reply!! I am sorry if I made the display layout editor screen sound useless, I simply mean that I am currently unable to use it the way you are asking. I am not familiar with custom shaders or fxaa, and don't understand the math you've written into that shader. If you think it will work the way you have written it then I will try your code in a shader. Please let me know.

@hrydgard - when I set it to stretching it makes the problem worse. It appears to try and stretch the display to what it thinks is a 16:9 display, but that is not the solution. The resolution is 4:3 - 800x600 and the monitor stretches it to look like it's 1067x600 (without changing the resolution), which causes the image to be distorted. The software is not aware of this happening. So I need to change the output dimensions of the display to be 533x600 so that when the monitor stretches it out, it results in the correctly scaled display.

I have tried to tweak settings in the INI file but I do not know which settings to change or what values to set them to. Which settings does the display layout editor use and what values do you recommend I try?

@mrfixit2001
Copy link
Contributor Author

In preparation of a possible patch, I'm reading over your SDLMain.cpp code...
At first I was thinking of changing your "--scale" argument into "--x-scale" and "--y-scale" as separate parameters, but then I noticed you accept the parameters of "--xres" and "--yres". I won't be able to test until later tonight, but would I be able to use these settings to meet this need?

I may still need to add a patch to provide the x and y position for the SDL window, because right now they are being set as undefined and the resulting window is not positioned correctly unless I force it to --fullscreen.

I welcome both of your expertise and feedback!

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 23, 2019

If you want to try quick solution here's a ready shader for you:
CustomAspectRatio.zip

just extract into your assets/shaders and edit .fsh file to scale X and Y separately. Then in PPSSPP just select that post process shader(requires buffered rendering ofc).

@mrfixit2001
Copy link
Contributor Author

I'm good to go! :) thank you for being so responsive and helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants