It is currently August 30th, 2014, 1:08 am. Last visit was:

MAME scanline/shadowmask simulation

Everything Emulator related

Moderator: Moderators

Forum rules
ArcadeOtaku forum introduction & rules
User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

MAME scanline/shadowmask simulation

Postby cools » April 7th, 2009, 3:35 pm

EDIT: All of the below is outdated. Please see http://wiki.arcadeotaku.com/w/MAME_CRT_Simulation for the fully refined, sexy method.

So you're running MAME on an LCD, and it looks terrible. Sharp edged pixels, no scanlines, no wonky geometry or convergence issues, and you miss how the games look on a CRT. What can be done? Until we get high enough resolution LCDs to simulate a true CRT shadowmask, it'll never look the same - but we can get things looking a lot better than they do untweaked.

There are a few settings to do this effectively in mame.ini (or the individual game .ini file):
Code: Select all
multithreading 1
video ddraw
keepaspect 1
aspect 4:3
prescale 2
hwstretch 1
effect effect_cools

  1. If you've got a multiprocessor or multicore machine (or even plain old P4 hyperthreading) then it's well worth having multithreading turned on - MAME will use a seperate thread to do all the fancy video effects so the emulation performance won't suffer as badly as with it off.
  2. We have to use DirectDraw rather than Direct3D. MAME peforms the scaling and image effects differently with both. In ddraw mode, the image is scaled internally (prescaled), then the effect is applied, then it's fed out to the graphics card. In d3d the image is fed out to the graphics card which handles the scaling, and the card then applies the effect to the scaled image.
  3. We have to force the aspect ratio to 4:3 - this is the aspect ratio of the monitors we're trying to simulate. Allowing MAME to use arbitrary (or so it seems) aspect ratios makes a mess of things. I suspect in most cases MAME looks at the game resolution and works out the aspect ratio from there - wrongly.
  4. We double the image in width and height internally in MAME. This is needed for the effect we wish to apply. Prescaling by a higher amount uses more CPU power, and would need a different effect image suited to the extra scaling. I'd love to see a good "prescale 4" effect but the difference between 2 and 4 in performance on this machine is a 50% framerate drop, and we need the eventual graphics card blurring to complete the effect, which would be lost if we're prescaling up to the output resolution.
  5. We use the graphics card to scale the image up to the monitor resolution. Disabling this is fine if you're running custom resolutions, using a VGA CRT (like in a Naomi), but on a high resolution LCD - I've been testing with a 1280x1024 display - this causes MAME to behave in a similar fashion to using d3d. With it disabled MAME scales the image up to the screen resolution, then applies the effect.
  6. Lastly, the most important bit is a good overlay effect .png image (attached at the post bottom).
    effect_cools_demo.png
    effect_cools_demo.png (346 Bytes) Viewed 17643 times
    This demo image is scaled up by 2000 percent so you can see what's going on. Normally it's a 2x4 image (which is attached). I've been through the ones available elsewhere and I'm not a fan of any (they either do the scanline or the shadowmask, not both), so I've spent a few hours playing about with this one till I'm happy with it. With the settings above, MAME takes this image, and tiles and applies it to the internally prescaled image before handing it over to the graphics card. Since we're prescaling by 2 times, we're doubling the the number of pixels in both directions. The dark lines in the effect dim every second line in our prescaled image so they appear as scanlines, and the alternating light grey/white squares apply a subtle change to the lines we want to see, simulating the ever so slightly speckled effect of a CRT shadowmask. By altering how light or dark the pixels in the effect image are we can control the strength of the scanlines and shadowmask simulation. Most important is to keep the levels far apart - by making the shadowmask effect stronger (darker pixels) or the scanline effect weaker (lighter lines) you end up with a display that simply looks speckled, losing the scanline effect that we're really after.

And the result? Here's R-Type Leo.
rtypeleo_effect_cools.png
Note: I've run this specifically in 640x480 with switchres on to get the screenshot. This is what gets handed off to your graphics card, which will do the final stretch up to the resolution you're running the LCD at - adding in it's own bit of blur which adds to the effect. To see how it looks on your setup, try setting this as your desktop wallpaper - stretched to the edges of the screen.

Hope this lot helps some of you - I've never been satisfied with the current video effects, and I've not seen a decent guide available to exactly what MAME does to the picture and what can be done with it.
Attachments
effect_cools.png
effect_cools.png (143 Bytes) Viewed 17619 times
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
280bpm's too slow
Posts: 3567
Joined: 17th August 2008
Location: London

Re: MAME scanline/shadowmask simulation

Postby yosai » April 10th, 2009, 12:24 am

Thanks for this, works a treat. :awe:
kernow wrote:I'd have my mouth on her **** quicker than a tramp on chips

User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

Re: MAME scanline/shadowmask simulation

Postby cools » May 7th, 2009, 5:27 pm

Here's one for if you use prescale 3

It looks even better, much nicer than at prescale 2 on an LCD - finer scanlines.

Unfortunately prescale 3 utterly destroys performance :)
Attachments
effect_cools_x3.png
effect_cools_x3.png (153 Bytes) Viewed 17445 times
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
Posts: 96
Joined: 17th August 2008
Location: Westmidlands , UK

Re: MAME scanline/shadowmask simulation

Postby mission » May 7th, 2009, 8:39 pm

I can`t seem to download any of your files cools, its just greyed out :wtf: , i`m using firefox

User avatar
Posts: 15
Joined: 2nd March 2009
Location: Somerset UK
eBay: ssDOTshinny

Re: MAME scanline/shadowmask simulation

Postby Shinny » May 7th, 2009, 9:34 pm

It's just a really tiny image. Right click it and "save as".

User avatar
Posts: 96
Joined: 17th August 2008
Location: Westmidlands , UK

Re: MAME scanline/shadowmask simulation

Postby mission » May 7th, 2009, 10:04 pm

Cheers mate :)

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 12th, 2009, 1:58 am

I've been tinkering with lcd friendly scanlines today. Mainly because I'm in the dilemma atm of reducing my cabs to only one - and I want to convince myself that the vewlix CAN be the one cab that I keep.

Anyway, this is what I've come up with (slarp.png):

zoomed in:
Image

The img itself (right-click, save as and place in mame's 'artwork' folder):
Image

I've found that the best solution is resolution dependent, so it varies for different lcd sizes. The vewlix is 1366x768 so a 3x height scale is almost ideal (width can more comfortably vary) for most old games. Therefore I've made a 3x3 effect to tile across the screen (upped to 6x6 to add a little variation in the aperture grill), which suits my resolution. My settings are a bit different to yours Cools as I just couldn't get on with the stretched scanline effect - possibly due to the screen depth I'm using - but the scanline effect with your settings turned out very jagged for me. On this matter, I found that if I want to stretch up to the absolute maximum screen size, it is far preferable to me to keep the scanlines at a fixed 3 pixel tiling (instead of stretched to align with pixels) EVEN if that means that not ALL pixels are aligned identically to the overlayed effect. The scanlines simply make the image comfortable to look at and during gameplay you never notice the alignment - as apposed to varying random scanline placement, which is very hard on the eye. (I'm not sure how much sense this paragraph will make to anyone who hasn't already spent a long time fiddling with scanlines!)

Anyway, for a 3x stretched image, the result is perfect alignment anyway so I'm happy enough with the result on my screen.

(I'd love to make an effect for a 1200 line screen or greater, because then I could make up to a 5x5 effect which would fit a nice amount of aperture and scan line detail).

Anyway, I'm quite happy with what I've come up with so far. I'm currently fiddling with game brightness to compensate for the overlayed effect, but I'm posting the examples below 'straight'. Here's how it looks...

Image

Image

Image

Image

incase you wondering, I cut the images in half to try and prevent browser scaling. Click on them to view full size.

[edit]Oh, and here are my settings:
Image

User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

Re: MAME scanline/shadowmask simulation

Postby cools » November 12th, 2009, 10:07 am

That's the right idea :D

It is highly dependent on tuning it for your screen settings.

One suggestion - try staggering the alternate "bright" lines and making the scanline line darker.

A Vewlix with MAME inside makes a hell of a lot of sense, as it's a noisy **** anyway so you can get away with a monstrous PC, and running on an LCD is far more straightforward for resolution selection.
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 12th, 2009, 11:18 am

I just disconnected the fan on the vewlix. Might swap it for a quieter one one day (it is a 12cm fan afterall), but it seems okay without it tbh. I can't stand noisy pc or cab fans.

Darker scanlines I didn't get on with so much. Well I like them, but I feel it makes the image get a bit too dark overall - and if I offset this by lightening the other two 'rgb' lines, you get a kinda a too crisp effect, like a gameboy screen. There is of course a lot of personal preference involved.

I'm only using basic gui mame though. Maybe I should look into other versions, because if darker scanlines could be combined with a lighter, saturated image (and maybe with some sort of very slight 'bloom' effect), then I'd love to play around with those settings. On the version I used, everything I did to brighten the image just washed the colours out too much.

It's silly, but I put a fair amount of work into that little group of pixels tbh. I started making a 3x3 grayscale scanline image with very subtle light variation (vertically as well as horizontally). I then found an rgb aperture grill image and reduced it right down in size before picking out the resulting colours. I overlayed the two images and tweaked the colours to simplify it (eg: removed the honeycomb effect of the grill). Then I played with layer opacity and colour satuation. ...I actually ended up with about a 5 layer working file and I tried out loads of different results - all for that small bunch of pixels. :oops:

Could you explain what you mean a bit further about 'staggering' the bright lines?

I did find that if I varied the left 3 pixels to the right 3 too much, the result was a bit wobbly. For example, I tried to keep the aperture grill 'honeycomb' effect at one point (the right 3 lighter pixels were basically flipped vertically) but the resulting effect was too obvious wavy lines. So I had to keep the variation very subtle.

User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

Re: MAME scanline/shadowmask simulation

Postby cools » November 12th, 2009, 11:34 am

Staggering - your bright areas are directly above and below each other. If you look at my first posted one, they're not. This reduces the cross stitch appearance of the image.

I found playing around with darker scanlines and the brightness/contrast/gamma in MAME (it's in your GUI settings) worked quite well, but yeah it's a lot of personal preference with this. Mark will tell you I tend to set up monitors with brightness set for darkest black (no raster lines), contrast set so there's minimum blooming or blurring, and red set a little high (this is down to my colourblindness).

I absolutely loathed the effect when the scanlines were offset from the pixels, for example :)
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 12th, 2009, 11:36 am

Ah, I think I've just twigged what you mean about staggering.

Good idea! :D

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 12th, 2009, 11:49 am

Lol, posted that just before I read your reply.

But yes, I think I'll try that later.

I understand what you mean about loathing the pixel misalignment. I just think, from what I've tried so far, it's preferable to scanlines that vary in thickness - especially during gameplay. How bad that effect is depends on how high your monitor resolution is though. I've noticed just now on my phone, that once I'm already close in, if I zoom in fractionally more on the images on this page, it's not so bad. I guess the 768 lines on the lcd I'm using just aren't enough to get past the hard omg jaggies stage.

User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

Re: MAME scanline/shadowmask simulation

Postby cools » November 12th, 2009, 12:48 pm

Definitely, avoid the the thickness variation at all costs!
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 12th, 2009, 6:02 pm

Cools, can you help me with this?

I've been fiddling with scanline images again, and then realised that mame has SEVERE input lag at the moment. Emulation speed is fine, but the lag is unbearable. It's not constant but, what happens is, if I am holding or pressing multiple buttons at the same time it is building up an input back log which can last for a very long time (I got wonderboy to carry on running and jumping for 20 seconds on his own).

It's not just game inputs, if I pressed esc, then that was taking a while to be recognised too.

First thing I did was put prescale back to "1", as you mentioned that being a performance killer, but it made no difference.

At this point, I started thinking it may be the JVS-pac which I just installed this afternoon. :wtf:

But just now, I have deleted the mame.ini file and it seems to be okay again. Obviously that means it must be some other setting messing things up, but I don't know what it is. Have you ever come across anything like this? As I say, game speed is perfect - it's just very bad input lag.

Bit off topic this, so I would be very happy to receive a PM if you have an answer that is not straight forward.

User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

Re: MAME scanline/shadowmask simulation

Postby cools » November 13th, 2009, 4:43 pm

Multithreading? I've never had any luck with that setting.
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 14th, 2009, 1:06 am

Ah it could have been that. Also, maybe 'refresh game speed', as I had that on.

You have multitgreading set to 'on' yourself though right?

since deleting the ini and starting from scratch, I haven't yet managed to recreate the problem.

It could have been a **** up. I noticed that changing the ini while mame is open, and then opening mame gui settings can really **** things up, so maybe it was that.

User avatar
Armed Police Buttrider
Posts: 11891
Joined: 17th August 2008
Location: Neath, Wales
eBay: hordarian

Re: MAME scanline/shadowmask simulation

Postby cools » November 14th, 2009, 1:17 am

No, I disable multithreading - it's never given me anything other than grief. I believe it is of benefit when running d3d, but when running ddraw, definitely not.

refreshspeed - yes, you could be right there. It's certainly some combination of stuff. I try to change one setting at a time and see what the effect is
Image
markedkiller78 wrote:If by mint, you mean Murray Mint (as it's yellow) then yes.

User avatar
Breastfeeds when required
Posts: 5981
Joined: 7th April 2009
Location: Alingsås, Sweden
eBay: jorgen_sjolander

Re: MAME scanline/shadowmask simulation

Postby emphatic » November 14th, 2009, 1:22 am

Love the thread and your efforts, boys. :awe:

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 14th, 2009, 3:28 am

Since I deleted my ini, Cools' (prescale 2 then hardware stretch) settings look nicer. ...God knows what I had wrong before.

I've changed my default settings to prescale 2 now and I'm using this 2pixel scanline image instead:

Image

zoomed in:

Image

The result:

Image

...and after final hardware stretching (to an uneven screen resolution - 768 lines):

Image

(btw, rainbow islands, with it's large areas of bright flat colour, is a real **** test for scanlines. So if ths looks even half decent, then everything else looks a lot better.)

Although there is unavoidable variation in scanlines, it is not too bad considering it's scaling up FULLY to a messy screen resolution ...and full screen stretch is the best option to have as a default really. Prescale 3 was too much hassel as a default option on my screen and at full screen hardware stretch, the scanlines looked worse.

P.S. I really like this prescale method cools. It is the only way to get half decent pixel regularity while scaling up to screen sizes that aren't an exact multiple of the original image - while still retaining (some) pixel sharpness.

For example, this:
Image

instead of this:
Image

I just wish the same effect could be applied to other low res software...
Last edited by pubjoe on November 14th, 2009, 3:58 am, edited 3 times in total.

User avatar
£100 of meat
Posts: 8672
Joined: 19th August 2008

Re: MAME scanline/shadowmask simulation

Postby pubjoe » November 14th, 2009, 3:37 am

I just wish the same effect could be applied to other low res software...


...As I mention it. Stupid question maybe, but IS there any kind of upscaling pass through software that can be used for programs that don't have their own decent options?

...and if not, WHY not? :awe:

---

And another thing. If only they kept all monitors' resolution height at some multiple of 240, then we wouldn't have to be doing half of this crap.

Next

Return to Emulation Q&A



Who is online

Users browsing this forum: No registered users