Wednesday, 26 October 2011

JClampy's HLSL 'Rendered Snapshots' Shadow Mask

The HLSL 'Rendered Snapshots' feature can be used to create large resolution pre-rendered screenshots that can be of a resolution beyond what our video cards or monitors can even display. The image is pre-rendered by the computer in the background and is saved to file's instead of being sent to the monitor. The pre-rendered image is broken into four parts (each corner of the screen) and then saved to four files, all we need to do then is use an image editor to paste the four seperate images into one large image. This process of splitting the image into four sections is how it is possible for the video card to render an image larger than what would normally be possible. Each of the four corner images can have a resolution of up to the maximum texture size limit of your video card.

In MAME a normal snapshot can be taken by the [F12] key. For a 'rendered snapshot' you have to press the [LEFT ALT] & [F12] keys at the same time. The 'rendered snapshots' will appear in your 'MAME/SNAP/game name/' folder as four seperate file names; for example 0005_0.png + 0005_1.png +0005_2.png +0005_3.png. Alternatively a normal snapshot would have a filename like 0005.png, notice the difference. To finish making our 'rendered snapshot' we just need to paste the four numbered files into one large image using our favourite image editing software (I prefer the excellent free GIMP). file number '0' is for top left corner, '1' top right corner, '2' bottom left corner, '3' bottom right corner.

To choose the resolution that we want our final 'rendered snapshot' we use these settings in our hlsl.ini:
hlsl_snap_width       2560
hlsl_snap_height      1920
Ideally you should be using a 'magnification' (multiplication/zoom) of the games original resolution. In this example I am doing a 8x magnification of a 320x240 game.

At the moment this is doing a kind of 'software zoom' and can produce some blurriness to the image. To get around this we can use 'pre-scaling' which is what I will call 'hardware zoom'. This uses the power of the video card to pre-magnify the image without causing the unwanted blurriness. To use this feature we can use these settings in our hlsl.ini:
hlsl_prescale_x       8
hlsl_prescale_y       8
In this example I am getting the video card to pre-scale the image up to the 8x magnification before hand so to eliminate blurriness. Your video card must have enough 'Video RAM' to perform this; in this example it used about 350MB.

Hot off the press, this is a new 'Shadow Mask' aperture file that I put together today. I was able to put some new theories into practise and got this working.

I have created a 'Shadow Mask' aperture for producing 12x magnification 'rendered snapshots'. You can get the file here;

You need to extract the NEW Shadow Mask .png file to your MAME or MESS artwork folder. At the moment I have only tested and calculated settings for one resolution;

320x240 original game resolution output to 3840x2880 12x magnification:
hlsl_prescale_x     12      (12x zoom)
hlsl_prescale_y     12      (12x zoom)
hlsl_snap_width     3840   (rendered snapshots resolution width at correct output ratio for game pixels to shadow mask alignment)
hlsl_snap_height     2880    (rendered snapshots resolution height at correct output ratio for game pixels to shadow mask alignment)
shadow_mask_alpha      0.250000    (my personal preference)
shadow_mask_texture        JClampyAperture12xPatternA.png
shadow_mask_x_count       256
shadow_mask_y_count       128
shadow_mask_usize         0.860000
shadow_mask_vsize         0.500000

effect             none      (old visual effects off)
scale_effect    none      (old visual effects off)
switchres           1        (enable resolution settings)
sleep                0        (power saving sleep mode off)
keepaspect        1        (maintain aspect ratios)
prescale            1        (no software prescale)
hwstretch          0        (hardware stretching off)
filter                 0        (bilinear filtering off)
artwork_crop      0        (crop border artwork off)

This 12x prescale required 800MB of video RAM going from 320x240 to 3840x2880.
Here is a zoomed in area of the final image showing the shadow mask;

Finding correct settings is a long, difficult, and slow process. If you
think you could help with this process then please contact me.

Please do not steal or use my work or settings without crediting me.
Otherwise I will take everything offline for my personal use only.

Special credit/thanks to Ryan Holtz aka 'Just Desserts', Bat Country Entertainment, cgwg and all those involved in creating and maintaining the HLSL filter for MAME and MESS.

No comments:

Post a Comment