Main » Emulation » SNES HD mode 7 » New reply
    Alert
    You are about to bump an old thread. This is usually a very bad idea. Please think about what you are about to do before you press the Post button.
    New reply
    Post help

    Presentation

    [b]…[/b] — bold type
    [i]…[/i] — italic
    [u]…[/u] — underlined
    [s]…[/s] — strikethrough
    [code]…[/code] — code block
    [spoiler]…[/spoiler] — spoiler block
    [spoiler=…]…[/spoiler]
    [source]…[/source] — colorcoded block, assuming C#
    [source=…]…[/source] — colorcoded block, specific language[which?]
    [abbr=…]…[/abbr] — abbreviation
    [color=…]…[/color] — set text color
    [jest]…[/jest] — you're kidding
    [sarcasm]…[/sarcasm] — you're not kidding

    Links

    [img]http://…[/img] — insert image
    [url]http://…[/url]
    [url=http://…]…[/url]
    >>… — link to post by ID
    [user=##] — link to user's profile by ID

    Quotations

    [quote]…[/quote] — untitled quote
    [quote=…]…[/quote] — "Posted by …"
    [quote="…" id="…"]…[/quote] — ""Post by …" with link by post ID

    Embeds

    [youtube]…[/youtube] — video ID only please
    Thread review
    creaothceann https://www.reddit.com/r/emulation/comments/btcw7i/bsneshd_beta_6_bsnes_1073_formally_hd_mode_7_mod/
    Screwtape I've started tracking DerKoun's releases in a branch of the unofficial higan repo, so (for example) you can review the actual beta 4 changes instead of the complete copies of modified files in the official release archive.
    creaothceann HD Mode 7 mod, beta 4 (bsnes 107.3): WideScreen (fullscreen 1080p)
    hunterk I just pushed up a variant of the super-xbr-3d shaders that combines the 2x and 4x versions into one and should react to resolution changes with the appropriate codepath. It's called super-multi-xbr-3d. Let me know how it goes :)
    MamiyaOtaru
    Posted by byuu


    with DerKoun's beta 3 in Mario Kart the internal resolution (if that makes sense) is now different on the track than it is on the title screen and menus.


    That one was my change. It's the same way hires and interlace modes work, the output resolution is the smallest size that will fit the game content. This is a fairly important speedup (outputting 4K pixels in *software* is going to be intensely painful even without any emulation at all), and it's also necessary to output at 256x240 for most shaders to work.

    It does look bad when changing modes, but the alternative is relegating 90% of hunterk's quark shader repository to non-working status.

    Any upscaling shaders in the quark shader repository are already non-working in HD mode 7. The only exception is super-xbr-3d (that hunterk ported over specifically in response to HD mode 7). Which is broken in menus now due to them not rendering at the same resolution as the mode 7 parts of games.

    Outputting that many pixels isn't something I'd want to do all the time for sure, but if I already (optionally!) have HD mode 7 on and am outputting that many when in mode 7 anyway, I wouldn't mind doing so in menus too, if at least one upscaling shader would work for the whole game. Currently with HD mode 7 I can either apply a single upscaling shader to the menu, or to the on track portion of Mario Kart, but not both, which was possible before.

    Whether that's a good reason to change things or not, am I at least making sense (phobia of sounding dumb)? Have you tried running HD mode 7 in conjunction with any upscaling shaders? Would you consider that something worth being able to do?

    Anyway, really grateful for your work!
    CaptainJistuce To add on, the graphics chipset offers eight background modes of varying capabilities. And instead of descriptive names like "high-res mode" and "cool 3D effects mode", they were officially identified by the numbers 0 through 7. The numbers were assigned because they were the number you had to feed the PPU to make it shift into the desired mode.
    creaothceann
    Posted by Kawa
    screen mode

    To be more precise, it's a 'background (decoding) mode'. It tells the SNES how to fetch and translate the graphics for the background layers, and can be specified per line. Sprites are not affected.

    There are several screen modes, depending on some bits:
    - 224 or 239 lines per field (basically, NTSC or PAL)
    - progressive (default) or interlaced fields (most useful for BG modes 5 and 6)
    Kawaoneechan
    Posted by MT
    Sorry if this was already asked and answered somewhere, but what does the 7 digit mean in the mode title? Thanks.
    It's a screen mode number. On the SNES, various screen modes allow different amounts of backgrounds and color depths per background. Mode 7 specifically is the only one that allows affine transformation at the cost of flexibility, though you wouldn't think so when you can just switch modes mid-frame.

    https://www.youtube.com/watch?v=5SBEAZIfDAg
    https://www.youtube.com/watch?v=3FVN_Ze7bzw

    It's such a typical effect that any game with a flat map projected into perspective like Super Mario Kart and F-Zero do, no matter what system the games run on, it's still called "Mode 7", even if that's a completely different video mode on that system. For example, Wacky Wheels has a "mode 7 effect" (being a kart racer), even though on a PC, mode 7 isn't even graphical.
    MT Sorry if this was already asked and answered somewhere, but what does the 7 digit mean in the mode title? Thanks.
    Near
    On the track-select screen, I can switch between resolutions and toggle "Perspective correction" with impunity. Once I reach the actual time trial, I can still switch resolutions but the moment I touch "toggle perspective", boom!


    Very strange. I'll look into it, thanks.

    with DerKoun's beta 3 in Mario Kart the internal resolution (if that makes sense) is now different on the track than it is on the title screen and menus.


    That one was my change. It's the same way hires and interlace modes work, the output resolution is the smallest size that will fit the game content. This is a fairly important speedup (outputting 4K pixels in *software* is going to be intensely painful even without any emulation at all), and it's also necessary to output at 256x240 for most shaders to work.

    It does look bad when changing modes, but the alternative is relegating 90% of hunterk's quark shader repository to non-working status.

    If we were willing to kill all but the OpenGL driver (which lacks exclusive mode support), I could include an option to upscale the video to a set size using point sampling, then apply shaders to output the final image. Shaders themselves could also be updated to be given hints as to the underlying resolution as well, but every single one would have to be updated.

    Ugh. I went back to look at the bilinear filtering, and it's just not good. I won't be doing that.


    Ah, darn =(

    Well, this is just a gimmick after all. It also can't really work with mode 7 mosaic by design, and the 3D perspective correction option is hit-or-miss depending on the game. Makes for some amazing screenshots, though.
    BearOso
    Posted by BearOso

    However, I'm personally not up for the challenge at the moment. Bilinear filtering looks particularly easy to bring back, so I might start with that.

    Ugh. I went back to look at the bilinear filtering, and it's just not good. I won't be doing that.
    MamiyaOtaru with DerKoun's beta 3 in Mario Kart the internal resolution (if that makes sense) is now different on the track than it is on the title screen and menus. So Hyllian's Super-xbr-3d (meant to smooth 2d elements like sprites while ignoring a 3d background) works on the track (see my screenshots earlier on page 2) but makes the menus garbled. Conversely regular shaders like scalefx work in the menus but not on the track. In the initial beta the menus were at the same internal resolution, and super-xbr-3d could handle the whole game.

    tl;dr internal resolution increases when mode7 is in use but not otherwise, but this confuses shaders. Could it stay consistent? Allows for http://chattypics.com/files/superxbr_v6ho1f2s4w.png
    nyanpasu64
    Posted by BearOso
    I'd just check if any of the parameters of the normal change sign. You create a new interpolation point on that scanline.
    That may fail to detect that soccer game, since it goes from zero distortion to nonzero, without a strict sign change? IDK
    BearOso
    Posted by byuu

    I think the perspective option can be enhanced in the future to detect when a frame isn't really in perspective, and to disable the option for said frames. Could even design it to split the frame into multiple chunks, so eg Terranigma can be made to look good. Probably won't be trivial, though. Certainly it's above my head, mathematically.

    I'd just check if any of the parameters of the normal change sign. You create a new interpolation point on that scanline.


    Also, upon implementing this, I can see that unfortunately this will be a nightmare for other emulators to implement, especially for FPGAs.

    Snes9x could turn off the PPU and DSP output and run ahead to fetch all the parameters needed then warp back to the first scanline. The extra CPU cost would easily be dwarfed by the overhead of the extra rendering.

    However, I'm personally not up for the challenge at the moment. Bilinear filtering looks particularly easy to bring back, so I might start with that.
    Screwtape I got it to crash. Steps to reproduce:

    - Boot Super Mario Kart
    - Start a 1P time trial as Mario, on Mario Circuit 1
    - when Lakitu shows with the traffic light, open Emulation settings, turn the scale from 240p up to 480p and untick "Perspective correction"

    Backtrace:

    terminate called after throwing an instance of 'nall::array<nall::Natural<15u> [256]>::operator[](unsigned int)::out_of_bounds'

    Thread 1 "bsnes" received signal SIGABRT, Aborted.
    __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
    50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    (gdb) bt
    #0 0x00007ffff61698bb in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
    #1 0x00007ffff6154535 in __GI_abort () at abort.c:79
    #2 0x00007ffff6570983 in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #3 0x00007ffff65768c6 in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #4 0x00007ffff65759d9 in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #5 0x00007ffff65762d5 in __gxx_personality_v0 () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #6 0x00007ffff6326e33 in () at /lib/x86_64-linux-gnu/libgcc_s.so.1
    #7 0x00007ffff6327391 in _Unwind_RaiseException () at /lib/x86_64-linux-gnu/libgcc_s.so.1
    #8 0x00007ffff6576b27 in __cxa_throw () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #9 0x000055555568bc6d in SuperFamicom::PPUfast::Line::renderMode7HD(SuperFamicom::PPUfast::IO::Background&, unsigned int) ()
    #10 0x000055555568bfd5 in SuperFamicom::PPUfast::Line::renderMode7(SuperFamicom::PPUfast::IO::Background&, unsigned int) ()
    #11 0x000055555568c7c3 in SuperFamicom::PPUfast::Line::renderBackground(SuperFamicom::PPUfast::IO::Background&, unsigned int) ()
    #12 0x000055555568f79d in SuperFamicom::PPUfast::Line::render() ()
    #13 0x000055555568fa90 in SuperFamicom::PPUfast::Line::flush() [clone ._omp_fn.0] ()
    #14 0x00007ffff633de0f in GOMP_parallel () at /usr/lib/x86_64-linux-gnu/libgomp.so.1
    #15 0x0000555555689998 in SuperFamicom::PPUfast::Line::flush() ()
    #16 0x000055555568ff67 in SuperFamicom::PPUfast::writeIO(nall::Natural<24u>, nall::Natural<8u>) ()
    #17 0x00005555556966e0 in nall::function<void (nall::Natural<24u>, nall::Natural<8u>)>::member<SuperFamicom::PPUfast>::operator()(nall::Natural<24u>, nall::Natural<8u>) const ()
    #18 0x000055555567722f in SuperFamicom::CPU::dmaRun() ()
    #19 0x0000555555677af8 in SuperFamicom::CPU::read(nall::Natural<24u>) ()
    #20 0x000055555574c56c in Processor::WDC65816::instructionResetP() ()
    #21 0x000055555574e317 in Processor::WDC65816::instruction() ()
    #22 0x000055555567572f in SuperFamicom::CPU::main() ()
    #23 0x0000555555675907 in SuperFamicom::CPU::Enter() ()
    #24 0x0000555555631420 in crash ()
    #25 0x0000000000000000 in ()


    On the track-select screen, I can switch between resolutions and toggle "Perspective correction" with impunity. Once I reach the actual time trial, I can still switch resolutions but the moment I touch "toggle perspective", boom!

    > I think the perspective option can be enhanced in the future to detect when a frame isn't really in perspective, and to disable the option for said frames. Could even design it to split the frame into multiple chunks, so eg Terranigma can be made to look good. Probably won't be trivial, though. Certainly it's above my head, mathematically.

    How about using a moving average of the parameters to detect perspective changes?

    - from the third to the last scanline, extrapolate from the previous two scanlines to predict the current scanline
    - if the predicted value of any parameter is (configurable threshold) different from the recorded value, this scanline is the beginning of a new chunk
    - once the screen is divided into chunks, treat each chunk like the current code treats the whole screen
    - for interpolated scanlines between chunks, you could just leave them black, or use the extrapolated values from the previous two scanlines, or just treat that as a very tiny chunk and interpolate between the previous and next scanlines.

    You don't want to make the threshold too small, or you'll reproduce the rounding errors of the original hardware too closely. You don't want to make the threshold too large, or a "curved" effect like Terranimga would wind up broken into straight segments. Hopefully there's some sensible value that works acceptably well for all games.

    EDIT: /u/geearf on Reddit points out that the bsnes makefile has copied higan's "do not run make install as root" message, but (unlike higan) bsnes does not actually have any writable resources, so it should be fine to "make install" as root.
    Near I implemented DerKoun's work, and I understand it now.

    By default it just interpolates between two real scanlines nearest to the virtual scanline being output.

    The perspective option instead scans up and down the frame to find the first and last mode 7 scanline, and takes the matrix transform parameters from there. So yeah, HDMA effects that do something other than a standard affine-style transformation won't work, but most games do that so it's usually fine.

    I think the perspective option can be enhanced in the future to detect when a frame isn't really in perspective, and to disable the option for said frames. Could even design it to split the frame into multiple chunks, so eg Terranigma can be made to look good. Probably won't be trivial, though. Certainly it's above my head, mathematically.

    Also, upon implementing this, I can see that unfortunately this will be a nightmare for other emulators to implement, especially for FPGAs.

    The only reason this is possible is because of my new parallel PPU renderer that builds up an entire frame worth of scanlines (I/O registers and palette RAM.) If you don't implement this, you won't be able to do the critically important perspective correction. You can probably manage the non-perspective variant by averaging between the current and previous scanline mode 7 parameters, though. Then it's just a matter of some gruesome code to scale up mixed-mode backgrounds and sprites to your larger canvas.
    Screwtape Somebody in the Reddit thread posted screenshots of Super Soccer, which happens to be another good example of what the Assume 3D Perspective option does.
    Screwtape
    Posted by hunterk
    For anyone who knows: what size is the final framebuffer that's coming out? it's not still 512x480, is it? That is, is it scaling up with the mode7?

    There's a slider so you can pick your output resolution: 1× (disabled), 2× (480p), 3× (720p), 4× (960p). It defaults to 960p.
    Kawaoneechan Oof that's painful.
    nyanpasu64
    Posted by sureanem
    Posted by jimbo1qaz
    xBR https://kayo.moe/5dG7cBao.png
    xBRZ https://kayo.moe/OELJLahD.png

    Those links don't appear to work.

    works for me, including in private browsing mode.

    I've uploaded to Dropbox too:

    https://www.dropbox.com/s/ywuctnjoyxu7ujo/magnifier-xbr4.png
    https://www.dropbox.com/s/eg54tt6z7c53ivn/magnifier-xbrz4.png
      Main » Emulation » SNES HD mode 7 » New reply
      Yes, it's an ad.