In the last HLSL tutorial we got up and running with Mame and HLSL and investigated the now sadly discontinued ini file creator. We learned about tweaking HLSL by making our own .ini files or by using the slider controls in MAME. If you need a refresher, head on over to the first tutorial here.
In this tutorial we’re going to take a look at some of the more advanced things you can do with HLSL. Again, for the most part we’ll simply be borrowing other peoples work, but in order to use the files we’ll be linking to, it helps to have a little understanding of what they do.
The HLSL components
The components used to get HLSL up and running are typically found in the following folders, which all reside in your MAME directory.
hlsl – As you might expect, this folder contains files relating to HLSL. Inside the folder you will find several files with a .fx extension. You can open these files in a text editor and tweak them if you are so inclined. The most commonly edited file is “post.fx”. This controls all the post processing effects, or effects that are applied after scaling has taken place.
ini – This folder contains the ini files. As we discussed in the previous tutorial, you can place per-game settings in an ini file. If there’s no ini file for a specific game, it takes its settings from the mame.ini file which is usually in the root of your Mame folder. Since it’s a gargantuan task to provide an ini file for every game, often HLSL configurations you download from the internet will simply have example files in here. For instance there may be a horizontal.ini and a vertical.ini, it’s up to you to match these to the correct games.
artwork – Some HLSL configurations may use files in the artwork folder. For instance, there may be files called “apeture.png” or “crt_shadow_mask.png”. These are used when emulating CRT shadow masks or aperture grills. Shadow masks and aperture grills are the technologies typically used to manufacture CRT displays. Basically, this file and various techniques in HLSL aim to emulate the CRT at a sub-pixel level, right down to the original dots created by the electron gun hitting the mask or grill. There’s some debate about how accurately this can be done on 1080p displays and we may have to wait until 4k displays are more commonplace before this effect really works well.
One popular reworking of the HLSL system comes from German gamer Jezze. For those readers who can also read German, you can check out the authors original thread here. Jezze’s shaders are known not only for looking great, but being much more efficient too, meaning those of you with older PCs you want to re-purpose as MAME machines need not exclude yourselves from the HLSL revolution. User u-man over on the Shmups forums has produced a modified Jezze-Shader with working .ini files package that you can download as a zip file here. Once downloaded, open the zip file and copy the folders as indicated below.
artwork – Copy the contents of this folder into your Mame/artwork folder.
crt_shadow_mask_ini – Copy the contents of this folder into your Mame/ini folder. The sub folder “Source” appears to contain some incomplete ini files and can be ignored for now.
hlsl_no_reflection and hlsl_with_reflection – Choose either of these folders depending on if you want glass reflection effects or not. Try them both out and see which you like best, all you need to do is copy the post.fx file from either of these folders into your mame/post.fx sub-folder.
Finally, there’s the file “MASK_SETTINGS.txt”. The supplied ini files in this package are for shadow mask type CRTs only. If you happen to know one of your games used a slot mask or an aperture grille type monitor instead, refer to this text document for instructions on how to edit the ini file to correctly use the different artwork files for emulating these monitors.
One other recommended tweak before you start using these shaders is to open your main Mame.ini file and under DIRECT3D-SPECIFIC OPTIONS, change “filter 1” to “filter 0” (without copying the quotes of course). The reason for this is that the filter effect is done by your HLSL configuration and doing it again here simply wastes computing resources.
The basic Jezze shaders have been tweaked even further by emulation enthusiast Cools and these settings can be downloaded here.
Once you download this file, it’s just a matter of unpacking the zip file into your MAME directory. You may wish to take a backup of your existing files first, of course. You should then use the settings in horizont.ini for any games with a horizontal monitor and vertical.ini for any games with a vertical monitor.
If you want to take screenshots of your HLSL setup in action, press the left ALT and F12 keys together. If you press F12 on its own you will get a screenshot of MAME without the HLSL effects applied. You should also edit any .ini files you are using and change the “hlsl_snap_width” and “hlsl_snap_height” entries to whatever size you want your screenshot to be. For technical reasons I don’t fully understand, whenever you take a screenshot of MAME running with HLSL it will produce four separate png images. You will need to manually join these together in a paint package, the free Paint.net package works just fine for this.
Below is a screenshot of the Jezze/Cools shaders in action. The preview you can see has been compressed through WordPress, but if you click on the picture it will link you to an uncompressed Tiff version of the screenshot at 1080p (warning, this is 3.08MB big).