RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Using MAME Overlays/Bezels and shaders with RetroArch in RetroPie

    Scheduled Pinned Locked Moved General Discussion and Gaming
    124 Posts 29 Posters 129.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pjftP
      pjft @Rion
      last edited by

      @Rion @Higgy

      Sure, what's up?

      That script I put together can be saved as a file in the config files folder, and then on the command line you can run

      chmod 755 <script filename>

      in order to give it permissions to be executed.

      You can find its content here:

      http://pastebin.com/fnf4HCnS

      It was some weeks ago, and I didn't have a lot of time, so it was a very scrappy job here - no points on making it elegant.

      I made that to work for a single file, and since I didn't quite know off the top of my head how to retrieve all files in the folder and run that for each (which I'm sure there's a 2-3 line solution for), I just dumped the contents of the folder in a separate batch file, and got it to invoke this one for each of the config files.

      Here's the content of that main file:

      http://pastebin.com/hk7gn9Mu

      As you can tell, I named my first script (the earlier one) "batch.sh".

      Once again, you'll need to save the content of the main file on the config-file folder, and then run

      chmod 755 <filename>

      on it as well.

      A couple of things, which I believe I mentioned earlier:

      a) it doesn't handle the invaders.cfg files correctly, because it has some commented lines that relate to the settings we're trying to change. Do remove those two or so commented lines on the invaders files before running the batch file - they'll start with # custom_viewport_width or something to that effect. As there were only three, it was easier for me to fix them, though fixing the processing should also be fairly easy, given time.
      b) It will output the files to the same folder, but append ".new" to their end. In my case, I just moved those files to a separate folder and bulk renamed them, removing the .new extension. I'm sure you can tweak the script's FILENAME_OUT variable to output to wherever you want. For instance, you may create a new folder beforehand in the same directory you're running it from, say "output" and then set FILENAME_OUT = "output/$1" and it should work, alleviating the need for renaming the files afterwards.
      c) It currently is set to adjust the proportions to 2/3, which is 1080 to 720. If you want a different proportion, just replace the 2/3 in the script by the new proportion, for both height and width.

      Hope these help.

      Let me know if you have any problems running it - I ended up not using it as weirdly enough it seems I am currently running on a 1080p screen, so I can't promise it works, but theoretically it should.

      Best.

      H 1 Reply Last reply Reply Quote 1
      • H
        Higgy @pjft
        last edited by

        @pjft
        Thanks for replying.
        The problem is I am such a Linux noob :)

        I have spent sooo many hours manually working my way through the configs, so I created a new folder 'test' (/home/pi/test).

        I copied the *.zip.cfg files to it. I created batch.sh and bulk_process.sh and gave them the correct file permissions.

        then within /home/pi/test/ I type ./bulk_process.sh and get -

        -bash: ./batch.sh: /bin/bash^M: bad interpreter: No such file or directory

        Also a couple of questions assuming I get it to work. I have added some more games, so what command do I type to create a 'bulk_process.sh' with the ROMS I have?
        And because my res is a little odd, I need to carry out another maths function, so does this:

        NEWLINE='custom_viewport_width = "'$((CUSTOM_VIEWPORT_WIDTH * 2/3))'"';

        become:

        NEWLINE='custom_viewport_width = "'$(((CUSTOM_VIEWPORT_WIDTH * 5/6)-80))'"';

        To go from 1920 to 1440 I first have to divide by 5/6 to get 1600 which is at the correct aspect ratio, I then need to subtract 80 pixels to centrailise the image as I have 1440 not 1600 (80*2 = difference 1600-1440).

        Sorry for being such a dope ;)

        pjftP 1 Reply Last reply Reply Quote 0
        • pjftP
          pjft @Higgy
          last edited by

          @Higgy

          No need to apologize whatsoever, I'm not in any way an expert Linux user either. :)

          On my phone at the moment, so will reply in more detail tomorrow when I'm at a laptop, but wanted to point you in the right direction in regards to the error you're facing.

          I googled it and found this which may help:

          http://stackoverflow.com/questions/2920416/configure-bin-shm-bad-interpreter

          As for the resolution maths, I'm not sure what the best way is. If the aspect ratio of the screen is the same as the 1080p one, then I'd suggest just dividing by the right number, otherwise you'll need to do a different subtraction on the other axis, I suspect.

          What's the exact resolution?

          Hope these help for the moment. Let me know how it goes. I'll answer the remainder tomorrow but at least this should help you move forward for the time being.

          For the file names, I simply did a folder listing, piping it to a new file. So, if I recall correctly,

          ls > main.sh

          Or something to that effect. Then with my text editor just replaced all newline character in the main.sh file with the bash file we needed to run for each and newline again.

          Very scrappy, I know. Sorry. :)

          Let me know if this helps. Best.

          1 Reply Last reply Reply Quote 0
          • RionR
            Rion
            last edited by Rion

            Thank you for joining the discussion @pjft!

            I'm in no way a linux expert when it comes to bin/bash scripting. But a good friend of mine by the name of Rickard whom have not joined here yet (read have not gotten his thumb out of his xxx yet) helpt me out with your script @pjft.

            It's a little bit altered from line 3-4.

            from

            FILENAME_OUT="$1.new"
            rm $FILENAME_OUT
            

            to

            FILENAME_OUT="output/$1"
            

            Basically it outputs the altered file in the "output" directory. You need to create the folder "output"

            Then he helped me make a batchrunner.sh script with the function of scanning all *zip.cfg files in the same folder.

            #!/bin/bash
            for i in `ls *.zip.cfg`
            do
                echo "Editing $i ..."
                ./1080p_to_720p.sh"$i"
            done
            

            The files @pjft mentions that reports back errors are the following.

            invaddlx.zip.cfg
            invaders.zip.cfg
            invadpt2.zip.cfg

            Before running the script just comment out the "#" before custom_viewport_width & custom_viewport_height and the back again in the new file in the output folder.

            Here is the altered script
            1080p_to_720p.sh

            Here is
            batchrunner.sh

            How to make

            Paste in contend of 1080p_to_720p.sh

            nano 1080p_to_720p.sh
            

            Paste in contend of batchrunner.sh

            nano batchrunner.sh
            

            How to run from terminal

            mkdir output
            sudo chmod a+x 1080p_to_720p.sh
            sudo chmod a+x batchrunner.sh
            ./batchrunner.sh
            
            • Now we just need the mathematical formula to convert from all of the common resolutions.

            I'm wondering of you could convert from a lower resolution to 1080p or something else.
            I was thinking about this because both @Zigurana & @Higgy both have converted @Floob 's Todo list from rp-video-manager (52 files)

            Ps. From 1080p to 720p i did not resize the Arcade Bezels *.png

            Edit:

            The Default path to the shaders in floobs cfg files are

            "/opt/retropie/emulators/retroarch/shader/arcade-bezel-shader/crt-pi-vertical.glslp"
            &
            "/opt/retropie/emulators/retroarch/shader/crt-pi.glslp"

            So if you are batch converting and want to use the default path instead of floobs and a more realisitic look using the "curvature" shader change these lines.

            • Vertical

            From

            "/opt/retropie/emulators/retroarch/shader/arcade-bezel-shader/crt-pi-vertical.glslp"
            

            To

            /opt/retropie/emulators/retroarch/shader/crt-pi-curvature-vertical.glslp"
            
            • Horizontal

            From

            "/opt/retropie/emulators/retroarch/shader/arcade-bezel-shader/crt-pi.glslp"
            

            To

            /opt/retropie/emulators/retroarch/shader/crt-pi-curvature.glslp"
            

            Same goes for the overlays

            From

            /opt/retropie/emulators/retroarch/overlays/arcade-bezel-overlays/
            

            To

            /home/pi/RetroPie/roms/mame-libretro/overlays/
            

            FBNeo rom filtering
            Mame2003 Arcade Bezels
            Fba Arcade Bezels
            Fba NeoGeo Bezels

            pjftP 1 Reply Last reply Reply Quote 1
            • pjftP
              pjft @Rion
              last edited by

              @Rion said in Using MAME Overlays/Bezels and shaders with RetroArch in RetroPie:

              I'm wondering of you could convert from a lower resolution to 1080p or something else.
              I was thinking about this because both @Zigurana & @Higgy both have converted @Floob 's Todo list from rp-video-manager (52 files)
              Ps. From 1080p to 720p i did not resize the Arcade Bezels *.png

              Thanks for the detailed reply and for making sense of what I had stated. The for loop to iterate and generate the main file is an elegant solution - considering the scrappy script I had provided, with its current limitations and constraints :)

              As for your questions:

              • Converting from lower resolution to 1080p: this should conceptually be feasible, the main thing to look out for is potential rounding errors, because of potential non-standard resolutions. That being said, it will probably only be a couple of pixels off, at most, so it wouldn't be the end of the world. The image, though, should be of high resolution otherwise it may become blurry, distorted or pixelated (in case you're thinking of using other images).
              • Resizing the images is probably not necessary. I didn't try it, as I mentioned, but I'm assuming they will scale to the right resolution. You could perhaps gain something in memory or performance by not using images larger than your screen resolution as overlays, but should have minimal impact, if any.

              Thanks.

              H 1 Reply Last reply Reply Quote 1
              • H
                Higgy @pjft
                last edited by

                @Rion @pjft

                I have also created .cfg for games not on @Floob 's list.

                We need a little CMD script program like Floob's initial program so you select which screen res you want to convert to.

                Hopefully this explains what I am trying to do. I am trying to keep the game window size as large as possible and just remove non-essential graphics.
                alt text

                TV screens - 16:9, only really 1920x1080 & 1280x720 - simple scaling

                PC Monitors - 16:10 1440x900 & 1280x800 - need to account for cropping to avoid reducing game area and having black bars on overlay.

                1 Reply Last reply Reply Quote 1
                • pjftP
                  pjft
                  last edited by

                  @Higgy

                  I see. You maths do seem to make sense, then, got it. The way you had originally suggested to change the script, then, seems to be the right one.

                  As for putting together a more robust script, with user inputs and such, that is something I am not able to do at the moment, but I'm more than happy if anyone wants to take my script and run with it or incorporate it into Floob's scripts or something. To be honest, what I did was so scrappy and not particularly complex, so feel free to use it in any way that benefits the community. I wanted to share it as it was as I hoped it'd help others, so I'm happy it did to some extent.

                  1 Reply Last reply Reply Quote 1
                  • RionR
                    Rion
                    last edited by Rion

                    @Higgy There where quite a lot of arcade-bezel-retroarch-configs from @Floob that did not contain

                    custom_viewport_width
                    custom_viewport_height
                    custom_viewport_x
                    custom_viewport_y

                    Would you mind posting the ones you are finishes with so i can see if i can convert them to 1080p & 720p?

                    Here is also a DPI Calculator / PPI Calculator i found if that helps..

                    FBNeo rom filtering
                    Mame2003 Arcade Bezels
                    Fba Arcade Bezels
                    Fba NeoGeo Bezels

                    FloobF 1 Reply Last reply Reply Quote 0
                    • FloobF
                      Floob @Rion
                      last edited by

                      @Rion Thats because those games are running in a multiple of their original res, limited only by integer_scaling.
                      You could apply the overrides to these if you wanted.

                      Please read the Docs before asking a new question.
                      RetroPie Help Guides: https://goo.gl/3gcNsT

                      RionR 1 Reply Last reply Reply Quote 0
                      • RionR
                        Rion @Floob
                        last edited by Rion

                        @Floob said in Using MAME Overlays/Bezels and shaders with RetroArch in RetroPie:

                        @Rion Thats because those games are running in a multiple of their original res, limited only by integer_scaling.
                        You could apply the overrides to these if you wanted.

                        But i still have to manually edit them one by one in 1080p adding

                        custom_viewport_width
                        custom_viewport_height
                        custom_viewport_x
                        custom_viewport_y

                        Or am I missing/misunderstood something?

                        FBNeo rom filtering
                        Mame2003 Arcade Bezels
                        Fba Arcade Bezels
                        Fba NeoGeo Bezels

                        FloobF 1 Reply Last reply Reply Quote 0
                        • FloobF
                          Floob @Rion
                          last edited by

                          @Rion You only have to add the viewport settings if you want to specify exactly where and how large the video image should be.

                          If you leave the defaults on, and enable interger_scaling it will only be a multiple of the original resolution.
                          http://emulation-general.wikia.com/wiki/Scaling

                          Obviously with MAME (as many games can be slightly different from one another) the end result will be slightly different (as opposed to consoles) but the end result is what the bezel was designed for, so its fine. You could specify the viewports for all the games, but as the native res (with multiplier) fits the bezel fine there is no need to specify on those (if you are on 1080p).

                          Hope that makes sense.

                          Please read the Docs before asking a new question.
                          RetroPie Help Guides: https://goo.gl/3gcNsT

                          RionR 1 Reply Last reply Reply Quote 0
                          • RionR
                            Rion @Floob
                            last edited by

                            @Floob I think i got it. Going to try some more.
                            I'm building a retropie setup for my father in law and his tv is 720p only.

                            All the overlays in 1080p fits like they should.

                            FBNeo rom filtering
                            Mame2003 Arcade Bezels
                            Fba Arcade Bezels
                            Fba NeoGeo Bezels

                            1 Reply Last reply Reply Quote 0
                            • H
                              Higgy
                              last edited by

                              @Rion @Floob @pjft

                              I think it best to concentrate our efforts on creating a script to convert the config files.
                              Ignore a menu etc, we can just have a separate script to match the common resolutions.

                              Creating the bezels is ok. I am sure I found a GIMP plugin that I could even run to do my re-size then cropping.

                              I have a 1yr old at home so it is difficult getting the time to sit down and try and get my head around the Linux commands etc. Doing the simple but long winded way of modifying each config file was easier as I don't have to think :) ! - thinking about I I have forgotten which game I got to! Letter 'G' i think LOL!!

                              I did find that files with no config seemed to fill up the screen and did not seem to scale as per Floob's comment, so I had to create them.

                              @Rion - I will try and get the 'Not Done' files with resolution numbers added.

                              I need to create 'Kung Fu Master' that does not seem to be on there!

                              FloobF 1 Reply Last reply Reply Quote 1
                              • FloobF
                                Floob @Higgy
                                last edited by

                                @Higgy To clarify, if there is no per game config at all, there it will just run with the defaults, but if there is a per game config that has integer_scaling set to on, it will scale appropriately. The viewports are only needed if a multiple of the native res wont fit the bezel properly.

                                Please read the Docs before asking a new question.
                                RetroPie Help Guides: https://goo.gl/3gcNsT

                                RionR H 2 Replies Last reply Reply Quote 0
                                • RionR
                                  Rion @Floob
                                  last edited by

                                  @Floob

                                  Ok from what i found out today and this may sound stupid because i was using my Desktop to go over the files that did not contain

                                  custom_viewport_width = 
                                  custom_viewport_height = 
                                  custom_viewport_x = 
                                  custom_viewport_y = 
                                  

                                  I was using Retroarch 1.3.6 (stable) and i did not see this on my Desktop ( with a 1080p Monitor) even if the cfg file was named correctly and in the right "folders" Roms & Overlay, or using the exact same settings as the cfg file for reference.

                                  If a game for example After Burner 2 (aburner2.zip.cfg ) only contained these lines at the end of the cfg file.

                                  aspect_ratio_index = "0"
                                  video_scale_integer = true
                                  

                                  And i went in to the Settings->Video->

                                  The only thing showing was
                                  aspect_ratio_index = 4:3
                                  custom_viewport_x = 0
                                  custom_viewport_y = 0
                                  custom_viewport_width = XXX
                                  custom_viewport_height = XXX
                                  video_scale_integer =On

                                  But if a started the same game on my Retropie setup hocked up to my 1080p tv and did the same thing, low and behold everything i needed was right there.

                                  aspect_ratio_index =  4:3
                                  custom_viewport_x = 362
                                  custom_viewport_y = 92
                                  custom_viewport_width = 1196
                                  custom_viewport_height = 896
                                  video_scale_integer =On
                                  

                                  Change it to this for 720p

                                  custom_viewport_width = "796" 
                                  custom_viewport_height = "596"
                                  custom_viewport_x = "241"
                                  custom_viewport_y = "61"
                                  
                                  aspect_ratio_index = "22"
                                  

                                  Change config.txt from

                                  1080p
                                  hdmi_group=1
                                  hdmi_mode=16

                                  to

                                  720p
                                  hdmi_group=2
                                  hdmi_mode=85

                                  Connected the pi to my old 720p tv. And everything fits nicely like it should in After Burner 2.

                                  This is going to take a while but at least now i don't have to guess and do it manually by resizing every game by hand to fit the Bezel in 720p.

                                  For NeoGeo games its a lot easier because everyone of them uses the same bezel and resolution..

                                  I wonder why these settings only show on the pi and not on my desktop pc?

                                  Ps
                                  I will input the setting for 1080p in the cfg files so they are easy to convert to any other resolution

                                  FBNeo rom filtering
                                  Mame2003 Arcade Bezels
                                  Fba Arcade Bezels
                                  Fba NeoGeo Bezels

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Higgy @Floob
                                    last edited by

                                    @Floob

                                    Here is a picture from my system (1440x900) without:

                                    custom_viewport_width
                                    custom_viewport_height
                                    custom_viewport_x
                                    custom_viewport_y

                                    In the config file. Integer_scaling=true

                                    alt text

                                    1 Reply Last reply Reply Quote 0
                                    • pjftP
                                      pjft
                                      last edited by

                                      @Higgy

                                      Interesting. What system and ROM are you playing?

                                      I suppose that, conceptually, it may be that for these "non standard" TV resolutions, their resolution on one of the axis is effectively an integer multiple of the original resolution, making it so that for the TV resolutions - 1080p, 720p, etc - forcing integer scaling will effectively not fully occupy the screen, whereas in this resolution it will.

                                      That being said, for the sake of sanity checking, would you open the Retroarch menu in-game, and under Options > Video check that Integer Scaling is effectively set to True/Yes/1? On a PS3 pad, it should be accessible via Select+Triangle.

                                      Thanks.

                                      H 1 Reply Last reply Reply Quote 0
                                      • H
                                        Higgy @pjft
                                        last edited by Higgy

                                        @pjft

                                        Raspberry Pi 3, MAME 2003, Game - Spatter (SEGA Arcade - just one I found which I had not added in the correct resolution yet).

                                        While trying @Rion's comment of writing down the video settings, I went into the RetroArch menu (Coin + P1 Button 3 on my bartop!) and I believe Integer Scaling was effectively set to True/Yes/1.

                                        1 Reply Last reply Reply Quote 0
                                        • pjftP
                                          pjft
                                          last edited by

                                          @Higgy

                                          Sounds good. According to http://segaretro.org/File:Spatter_title.png the game's original resolution is 240 x 224 .

                                          I'm unsure how reliable the source is, but your resolution of 1440 x 900 suggests that it can fit it at 4x resolution (so, each pixel takes up 4 pixels in your screen), resulting in an effective screen real-estate of 960 x 896. That's why you end up with a screen that takes up the entire vertical estate in your case (except for 2 pixels on top and 2 pixels at the bottom).

                                          In a 1080p (1920 x 1080), with integer scale turned to ON it would interestingly be the exact same 4x resolution (896px height), as 5x would make it 1120, which is more than the vertical resolution of 1080. As such, in a 1080p screen we'd have a black border of 184px - likely 92 on top and 92 at the bottom.

                                          So, summarizing: your settings are indeed correct, but it seems that for your particular screen resolution you need a bit more tweaking than necessary.

                                          @Floob I wonder, can the overlays overflow the screen (i.e. could one set the overlay start position to a negative number in the vertical axis?). I doubt that is the case, but worth checking - it could make your life easier if you'd just make the default system configuration take that into account, for the ones without cfg files.

                                          Alternatively, on the RetroArch menu, in the Overlays section (Options > Overlays something), select the option that shows the overlay in the menu as well (I think it's RGUI something), and play with the overlay scale. Increase it until it actually matches what you're looking for, and then add that value to the default options file - there should be an Overlay Scale value that's set at 1.00x. This might be the best way to achieve what I was suggesting in the previous paragraph.

                                          You need the overlay to be displaying while in the menu though, otherwise changing the Overlay scale will likely crash Retroarch and boot you back to emulation station.

                                          Hope this helps - and anyone, please correct me or add to this.

                                          1 Reply Last reply Reply Quote 0
                                          • RionR
                                            Rion
                                            last edited by

                                            Here are all the cfg files that don't contain

                                            custom_viewport_x =
                                            custom_viewport_y =
                                            custom_viewport_width =
                                            custom_viewport_height =

                                            ToDo 1080p

                                            So all i have to do now is to start one game at a time from the pi and find these values.
                                            Then add/replace /remove
                                            aspect_ratio_index = "xx" to aspect_ratio_index = "22"
                                            video_scale_integer = true to # video_scale_integer = false

                                            FBNeo rom filtering
                                            Mame2003 Arcade Bezels
                                            Fba Arcade Bezels
                                            Fba NeoGeo Bezels

                                            C 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.