Viewing 30 posts - 1 through 30 (of 30 total)
  • Author
    Posts
  • patrickm
    Participant
    Post count: 171

    How to get perfect video scaling

    On a fixed-pixel display, you have to stretch the native resolution of a game by a whole integer amount, otherwise you will get ugly scaling artifacts; some pixels will be larger or of a different shape than others. Scaling artifacts are particularly noticeable when a game is scrolling, and they ruin the look of scanlines. To eliminate scaling artifacts, do the following:

    1. Hold “x” or “m” when launching a game to bring up the launch menu. By default, “video mode” should be blank. If it is not blank, select “remove video mode choice.” This will tell Retroarch to automatically detect the native resolution of your display.
    2. Now scroll to “retroarch render resolution.” Set this to “use video output” if using a raspberry pi model 2. Otherwise leave as is (640×480).
    3. Launch game.
    4. go to RGUI -> settings -> video settings -> integer scale ON
    5. RGUI -> options -> video options -> set custom ratio
    6. Set to whatever looks best. You can’t get to a perfect 4:3 aspect ratio but you can get close if you use the right scaling ratio. For NES for example, 6×5 scaling gets you close to a 4:3 aspect ratio with the top and bottom cropped off (see below)

    A note on 5x scale: If you use 5x scale and wish to use a scanline overlay, you need to use one designed for 5x, which I’ve provided here. It is desirable to set the Y axis to 5x scale for many systems, cropping off the top and bottom of the picture. On a CRT, the “safe area” was 90% of the picture. The safe area was the zone in which important graphics were displayed. The rest was occupied by overscan, which wasn’t meant to be displayed and which was cropped off by CRTs. With 5x scale on the Y axis, or 1200 pixels, you are cropping off 120 pixels on a 1080 display. This is 24 pixels on a 240p console, or 10%, equivalent to the entire overscan area.

    Important Note: depending on the core, crop overscan may need to be turned either ON or OFF. Crop overscan can cause problems with scaling if not set right.

    Note: these resolutions are for a 1080p display.

    NES:
    1024×960
    1280×960
    1280×1200
    1536×1200

    Genesis:
    960×896
    1280×896
    1280×1120
    1600×1120

    SNES:
    1024×896
    1280×896
    1280×1120
    1536×1120

    Doom:
    1280×1000

    Quake:
    1280×1000

    N64:
    1280×960
    1280×1200
    1600×1200

    PSX:
    1280×960
    1280×1200
    1600×1200
    *note: it doesn’t seem possible to get perfect integer scaling with psx at the moment. The sharp-bilinear shader with one of the above resolutions is your best bet for minimizing artifacts, but it will cause a dip in performance.

    PC Engine:
    960×696
    1280×1160
    1600×1160

    More systems will be added as they are tested.

    InsecureSpike
    Participant
    Post count: 571

    awesome work mate

    dishins
    Participant
    Post count: 47

    do you know how i set these options directly in the *.cfg files?

    patrickm
    Participant
    Post count: 171

    [quote=97165]do you know how i set these options directly in the *.cfg files?

    [/quote]

    Look for “integer scale” should be on
    “Crop overscan” should be off
    “Custom viewport” x and y
    “Video fullscreen” x and y

    dishins
    Participant
    Post count: 47

    i did not found “Custom Viewport” in retroarch.cfg, any help?

    patrickm
    Participant
    Post count: 171

    [quote=97171]i did not found “Custom Viewport” in retroarch.cfg, any help?

    [/quote]

    custom_viewport_width

    custom_viewport_height

    Floob
    Member
    Post count: 1629

    Lots of good (and heated!) discussion on custom ratios here:
    http://libretro.com/forums/showthread.php?t=1471

    As they mention, sticking to an arbitrary 4:3 for the sake of it isnt really that relevant, with the goal really being to get close to each systems native output resolution.

    For reference the “aspect_ratio_index” settings are:

    0: 4:3
    1: 16:9
    2: 16:10
    3: 16:15
    4: 1:1
    5: 2:1
    6: 3:2
    7: 3:4
    8: 4:1
    9: 4:4
    10: 5:4
    11: 6:5
    12: 7:9
    13: 8:3
    14: 8:7
    15: 19:12
    16: 19:14
    17: 30:17
    18: 32:9
    19: config (video_aspect_ratio setting)
    20: 10:9 (1:1 PAR)
    21: Core Provided
    22: Custom

    As an example, my Game Gear settings are (on a 720p TV):

    aspect_ratio_index = "22"
    custom_viewport_width = "432"
    custom_viewport_height = "389"
    custom_viewport_x = "423"
    custom_viewport_y = "165"

    As you can see the viewport width/height are a multiple of the native 160×144 to keep the ratio the same.

    Although the more I read the thread below, the more I think I should check out the affect of using Core Provided instead.
    The OP there has said:

    If you want the native core AR then use “core provided” whether they got it wrong or right.
    If you want the nostalgia look whether it’s right or wrong, don’t crop overscan and use 4:3 (display) aspect ratio.
    If you want accurate ratio, check my thread here.
    http://libretro.com/forums/showthread.php?t=1471

    patrickm
    Participant
    Post count: 171

    [quote=97840]

    As they mention, sticking to an arbitrary 4:3 for the sake of it isnt really that relevant, with the goal really being to get close to each systems native output resolution.
    [/quote]

    I read over that thread and actually posted in it as Nesguy.

    That thread has very different goals than this thread. They want to display games in their native resolution, which is incorrect IMO. It isn’t how the games were displayed nor how they were meant to be displayed.

    This thread is about getting perfect video scaling, which is related to but a separate issue from aspect ratio.

    You can accomplish what that other thread is describing by just selected the 1:1 PAR option under video aspect ratio. This will result in perfect scaling, but will also make the picture appear in a small pillarboxed square, wasting a lot of screen space and making the graphics appear squished.

    To keep the perfect scaling with a more authentic and aesthetic aspect ratio, follow the instructions in this thread.

    I provided some example shots below of NES and SNES at 6×5 integer scale. As you can see, what gets cropped off corresponds to the overscan area. On SNES it’s very minimal. If you zoom in you will see that each pixel is the exact same shape and size. This is identical to the output using an XRGB Mini with the 5x profile.

    (Be sure to click enlarge for proper viewing)
    http://s1309.photobucket.com/user/Patrick_McCleery/media/image.jpg2_zpsuohwoiid.jpg.html

    http://s1309.photobucket.com/user/Patrick_McCleery/media/image.jpg1_zpssotkgues.jpg.html

    zonitz
    Participant
    Post count: 11

    [quote=97150]How to get perfect video scaling

    On a fixed-pixel display, you have to stretch the native resolution of a game by a whole integer amount, otherwise you will get ugly scaling artifacts; some pixels will be larger or of a different shape than others. Scaling artifacts are particularly noticeable when a game is scrolling, and they ruin the look of scanlines. To eliminate scaling artifacts, do the following:

    1. Hold “x” or “m” when launching a game to bring up the launch menu. By default, “video mode” should be blank. If it is not blank, select “remove video mode choice.” This will tell Retroarch to automatically detect the native resolution of your display.
    2. Now scroll to “retroarch render resolution.” Set this to “use video output” if using a raspberry pi model 2. Otherwise leave as is (640×480).
    3. Launch game.
    4. go to RGUI -> settings -> video settings -> integer scale ON
    5. RGUI -> options -> video options -> set custom ratio
    6. Set to whatever looks best. You can’t get to a perfect 4:3 aspect ratio but you can get close if you use the right scaling ratio. For NES for example, 6×5 scaling gets you close to a 4:3 aspect ratio with the top and bottom cropped off (see below)

    A note on 5x scale: If you use 5x scale and wish to use a scanline overlay, you need to use one designed for 5x, which I’ve provided here. It is desirable to set the Y axis to 5x scale for many systems, cropping off the top and bottom of the picture. On a CRT, the “safe area” was 90% of the picture. The safe area was the zone in which important graphics were displayed. The rest was occupied by overscan, which wasn’t meant to be displayed and which was cropped off by CRTs. With 5x scale on the Y axis, or 1200 pixels, you are cropping off 120 pixels on a 1080 display. This is 24 pixels on a 240p console, or 10%, equivalent to the entire overscan area.

    Important Note: depending on the core, crop overscan may need to be turned either ON or OFF. Crop overscan can cause problems with scaling if not set right.

    Note: these resolutions are for a 1080p display.

    NES:
    1024×960
    1280×960
    1280×1200
    1536×1200

    Genesis:
    960×896
    1280×896
    1280×1120
    1600×1120

    SNES:
    1024×896
    1280×896
    1280×1120
    1536×1120

    Doom:
    1280×1000

    More systems will be added as they are tested.

    [/quote]

    patrickm, could you please provide your recommendations for, PSX, Mastersystem, PC-Engine as well? Sega CD seem to differ from genesis and 32x as well.

    patrickm
    Participant
    Post count: 171

    [quote=99052]
    patrickm, could you please provide your recommendations for, PSX, Mastersystem, PC-Engine as well? Sega CD seem to differ from genesis and 32x as well.

    [/quote]

    I updated the op and added some more systems. Note that Floob’s video manager tool will soon make this obsolete. You will be able to easily configure all systems at once without having to edit config files :)

    Floob
    Member
    Post count: 1629

    @patrickm
    Could you repost your patrickm-scanlines1920x1080-5x.png file so I can make sure I’ve got the right version in the video manager?

    I have your settings for SNES, Megadrive, NES, PSX, Doom, Quake in the tool using the image I mention above. This is all without shaders.

    patrickm
    Participant
    Post count: 171

    [quote=99087] @patrickm
    Could you repost your patrickm-scanlines1920x1080-5x.png file so I can make sure I’ve got the right version in the video manager?

    I have your settings for SNES, Megadrive, NES, PSX, Doom, Quake in the tool using the image I mention above. This is all without shaders.

    [/quote]

    Here it is:
    https://www.dropbox.com/s/88bj4jqgeqzx1c6/scanlines1920x1080-5x.png?dl=0

    Floob
    Member
    Post count: 1629

    Thanks, thats definitely in the tool now.

    Do you want me to add 4x options, or look at shaders next?

    patrickm
    Participant
    Post count: 171

    [quote=99091]Thanks, thats definitely in the tool now.

    Do you want me to add 4x options, or look at shaders next?

    [/quote]

    Thanks Floob.

    Could you also incorporate the 5x settings for N64 and PCengine? Then we can work on the 4x settings, which I sent you the resolutions for. Let me know if you need anything.

    Floob
    Member
    Post count: 1629

    New version up with PC Engine added. Want to try it?
    https://github.com/biscuits99/rp-video-manager

    Can you write a one sentence description of why the 5x or other version should be used? i.e. under what conditions would the 4x be more suitable.

    Then do you want a new option for 720p handhelds – which settings for the other systems here – the 3x?

    patrickm
    Participant
    Post count: 171

    [quote=99137]New version up with PC Engine added. Want to try it?
    https://github.com/biscuits99/rp-video-manager

    Can you write a one sentence description of why the 5x or other version should be used? i.e. under what conditions would the 4x be more suitable.

    Then do you want a new option for 720p handhelds – which settings for the other systems here – the 3x?

    [/quote]

    [quote=99137]New version up with PC Engine added. Want to try it?
    https://github.com/biscuits99/rp-video-manager

    Can you write a one sentence description of why the 5x or other version should be used? i.e. under what conditions would the 4x be more suitable.

    Then do you want a new option for 720p handhelds – which settings for the other systems here – the 3x?

    [/quote]

    thanks Floob, I’ll take a look.

    I think 5x is preferable for most systems that displayed on a CRT TV such as NES, SNES, and Genesis because it doesn’t show any of the overscan that was cropped on a real CRT and it doesn’t result in any letterboxing of the image, which takes full advantage of the screen/TV’s display area.

    However, some people might prefer 4x because the scanlines are slightly bolder/thicker at that scale, and some people like bolder scanlines. Or, someone might simply want to see every line put out by the console, even if it wasn’t meant to be displayed.

    Actually, I was hoping to have the issue with my aperture grill overlays solved by now, so that there could be a separate option for that. But, I’m still seeing a strange diagonal line down the middle when it’s applied in Retroarch.

    eventually, I would like to see the following options:

    configure consoles for 1080p/i displays:
    -5x w/scanlines
    -4x w/scanlines
    -5x w/aperture grill
    -4x w/aperture grill

    configure consoles for 720p/i displays:
    -3x w/scanlines
    -3x w/grid (at this resolution, the aperture grill becomes a regular grid. I’ll send this to you)

    configure handhelds for 1080p/i displays:
    (6x overlay for GBA, 7x for Gameboy, Gameboy Color, Game Gear)
    -w/scanlines
    -w/grid

    configure handhelds for 720p/i displays:
    (4x overlay for GBA, 5x for GB, GBC, Game Gear)
    -w/scanlines
    -w/grid

    So, a total of 10 options in 4 categories. I think that should cover it for the overlays.

    Floob
    Member
    Post count: 1629

    Thats helpful. Will keep me busy for a while! :)

    Anonymous
    Inactive
    Post count: 42

    Hi patrickm, can you please provide your recommended resolutions for neo geo?

    shadowmoses
    Participant
    Post count: 8

    It doesn’t work well here.

    I have problems to keep my settings saved in Retroarch GUI. When i use the “save new config” option, it will save but not in retroarch.cfg

    Floob
    Member
    Post count: 1629

    [quote=102521]It doesn’t work well here.

    I have problems to keep my settings saved in Retroarch GUI. When i use the “save new config” option, it will save but not in retroarch.cfg

    [/quote]

    Yes, you’ll need to rip some settings out of the file that was created (or you could just rename it retroarch.cfg, but that will screw with a few things.).

    If you are feeling brave you can use this tool (although PLEASE make a backup – as I cant guarantee it wont break other settings):
    https://mega.co.nz/#!2NAUwbAL!BrgkCCWMerAxKDDE_0LYtR2qKjkDN26QZbDrIuIJ_28

    Put it in your home (/home/pi) directory and

    unzip -o rp-video-manager-11-JUL-2015.zip
    rm rp-video-manager-11-JUL-2015.zip
    cd /home/pi/rp-video-manager
    chmod 755 videomanager.sh
    ./videomanager.sh

    shadowmoses
    Participant
    Post count: 8

    wow this tool is the solution, very easy to install and apply.

    You should start a specific topic to document it online for noobs like me.
    (I noticed the info.txt file now i understand a bit more the different settings)

    The only issue i had is that i was unable to quit and had to shutdown the pi.

    thank you very much floob

    Floob
    Member
    Post count: 1629

    Thanks for the feedback. I really need to write more documentation for it and update it a bit more. The issue is that it is really difficult not to get it to affect users settings if they have heavily customised them. I’ll try to update it soon, and when its a bit more stable I’ll create a new topic.

    dragonjab
    Participant
    Post count: 27

    ok so after finally having time to work on this all day, since school is out. I figure it out. Thanks to all the good posts and people that help out. Thanks Patrickm, Floob, and patl. I’m going to post what I did.

    I first follow floobs video.

    and I also added patrickM scanlines both the regular and 5x. I generated a cfg file for both and then I put them in the folder 16-9 found in floobs guide.
    http://smartretro.co.uk/forums/viewtopic.php?f=3&t=85

    I then use this thread to find the correct scaling I found out that for the snes 1280×1120 is perfect 5×5 scaling. I didn’t want to go through the whole RGUI setup because I could never find how to save it. So in the idividual retroarch file for everysytem I put this created by patl

    This one is for the snes, but you can easily adjusted for other systems just change the width and height. I also added video_scale_interger = “true” to the list of commands. Without this on my retroarch file I was getting a crop image from the bottom. Below is the edited code.
    video_shader_enable = false
    # We dont need them
    video_fullscreen_x = 1920
    # Horizontal Monitor resolution
    video_fullscreen_y = 1080
    # Vertical Monitor resolution
    custom_viewport_width = 1194
    # Horizontal emulator resolution
    custom_viewport_height = 896
    # Vertical emulator resolution
    custom_viewport_x = 363
    # The first X pixel of the emulator image
    custom_viewport_y = 92
    # The first Y pixel of the emulator image
    aspect_ratio_index = 22
    # Aspect Ratio set to custom
    video_scale_interger = “true”
    # This is to what I added to the instructions
    input_overlay = /opt/retropie/emulators/retroarch/overlays/16-9/TV_16-9_SNES-MD.cfg
    # Overlayimage
    input_overlay_enable = true
    # Overlay Image enable
    input_overlay_opacity = 1.000000
    # opacity of the overlayimage
    input_overlay_scale = “1.000000”
    # Scalesize of the overlay image
    video_smooth = true
    # Smoth the emulated image, not the overlay, If you set it to false, it will remain sharp but blocky.

    dragonjab
    Participant
    Post count: 27

    Ok so after trying everthing out. I can’t seem to make the n64 emulator work.

    *Never mind I got it to work I just had forgotten to add it to the videomodes.cfg file. Everything works flawlessly. I just added to video modes. lr-mupen64plus_render=”config”

    dragonjab
    Participant
    Post count: 27

    Ok so here my settings for videomodes.cfg
    settings for all emulators.
    and FBA settings it works for most games, you just have to mess around with the width and height.

    dragonjab
    Participant
    Post count: 27

    here are my N64 settings and snes settings

    dragonjab
    Participant
    Post count: 27

    here are my megadrive and psx settings

    dragonjab
    Participant
    Post count: 27

    Here are Mame settings. Can someone please merge all this posts into one. Thanks.

    patrickm
    Participant
    Post count: 171

    [quote=102926]Here are Mame settings. Can someone please merge all this posts into one. Thanks.

    [/quote]

    For accurate video scaling, video smooth needs to be turned off. Nearest neighbor filter displays the source material without altering it. Bilinear filter runs the source material through an algorithm and distorts the image by finding an average color based on adjacent pixels.

    You might prefer the smoother image, but it causes pixels to bleed over the scanlines, and it alters the source material, making it less accurate.

    In addition, bilinear filter/ video smooth WILL introduce additional input lag vs. nearest neighbor, although the difference probably isn’t significant enough to be noticeable to most.

    dragonjab
    Participant
    Post count: 27

    [quote=103173]

    Here are Mame settings. Can someone please merge all this posts into one. Thanks.

    For accurate video scaling, video smooth needs to be turned off. Nearest neighbor filter displays the source material without altering it. Bilinear filter runs the source material through an algorithm and distorts the image by finding an average color based on adjacent pixels.

    You might prefer the smoother image, but it causes pixels to bleed over the scanlines, and it alters the source material, making it less accurate.

    In addition, bilinear filter/ video smooth WILL introduce additional input lag vs. nearest neighbor, although the difference probably isn’t significant enough to be noticeable to most.

    [/quote]

    Yeah you are right. I did some tweaks to my system last week that I didn’t post here. Yes is noticeable on fighting games like street fighter 3rd strike.

Viewing 30 posts - 1 through 30 (of 30 total)
  • The forum ‘Video Output on RetroPie’ is closed to new topics and replies.