MAME scanline/shadowmask simulation

Everything Emulator related
Forum rules
ArcadeOtaku forum introduction & rules
User avatar
gargoyle67
Gateau superstar
Posts: 6500
Joined: August 22nd, 2008, 11:33 am
Location: Clacton-On-Sea init
eBay: gargoyle1967

Re: MAME scanline/shadowmask simulation

Postby gargoyle67 » January 15th, 2010, 12:39 pm

cools wrote:
pubjoe wrote:Using mame within linux (windows won't allow this) to feed on-the-fly exact modelines directly to the frame buffer (with no software in between) is the most accurate and most difficult option.


This is, but even then it simply isn't possible to generate some of the modes required to the *exact* refresh rate. For the stuff that you *can* get exact rates for (it varies depending on what graphics card you're using), it works fine.

DZine and myself have spent many, many hours working on this. Short of swapping graphics cards for each set of rates you need, you're not going to be able to get a perfect mode for every (15k) game :)


Yes I've tried all the suggested settings and as cools states there are some combinations of cards and monitors that no matter how much fiddling you do won't sync perfect on certain titles. I'm using the mame dos based version I compiled with no nag plus high score save 8-)
"Yeah lets all get ponys instead, wait no lol trendy cabs" Err I think you meant Ponies didn't you ?
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » January 15th, 2010, 12:43 pm

Yeah, getting a mode that is 99.9999% accurate will still leave a small judder on one frame in every few hundred.

Do you have a perfect one for CPS2, with the ATI? We couldn't get one spot on using a Matrox G400. Could get it to within 0.0001Hz above or below it, but never bang on. Which is fine for side scrolling stuff, not noticeable unless you're looking really hard. But with vertical scrollers it looks nasty.
Image
User avatar
pubjoe
Fosters Political Ambitions
Posts: 10619
Joined: August 19th, 2008, 8:58 am
Location:

Re: MAME scanline/shadowmask simulation

Postby pubjoe » January 15th, 2010, 1:03 pm

I think so. I'd like to just say yes. But I'd better check it with a vertical scroller as it's easily possible I haven't noticed the 0.0001hz difference.

I do remember swapping the soft15khz mode I use for 384x224 for some reason. ...and I've just checked the cps2 refresh and noticed that it's 59.633333hz, so I presume that means it's actually supposed to be 59.63333333333333333333333 etc, which would cause the problem.
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 19th, 2010, 3:24 pm

Er, D3D seems to work like DDRAW in newer builds. But without the performance hit.

Prescale 4 is now fine.

Quickly knocked up effect and demo image... needs further investigation. Things are looking REALLY good now.
Attachments
effect_cools_x4.png
effect_cools_x4.png (213 Bytes) Viewed 3168 times
Image1.jpg
Image
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 19th, 2010, 5:24 pm

Settings:

Code: Select all

rotate                    1
video                     d3d
numscreens                1
window                    0
keepaspect                1
prescale                  4
effect                    effect_cools_x4.png
switchres                 0
screen                    auto
aspect                    auto
resolution                auto
view                      auto
d3dversion                9
filter                    1
waitvsync                 1
autoframeskip             0
frameskip                 0
sleep                     0


Scarily this is spot on, for games that use a 4:3 resolution anyway. It looks damn good.
Image
User avatar
emphatic
Breastfeeds when required
Posts: 6959
Joined: April 7th, 2009, 4:14 pm
Location: Alingsås, Sweden
eBay: jorgen_sjolander
Initials: JOR

Re: MAME scanline/shadowmask simulation

Postby emphatic » April 19th, 2010, 5:38 pm

Wow! :shock: :awe:
User avatar
cRacKh0rN
Custom rank pending return
Posts: 1986
Joined: October 13th, 2008, 11:22 am
Location: North Yorkshire
Initials: DAB

Re: MAME scanline/shadowmask simulation

Postby cRacKh0rN » April 19th, 2010, 6:13 pm

cools wrote:Er, D3D seems to work like DDRAW in newer builds. But without the performance hit.

Prescale 4 is now fine.

Quickly knocked up effect and demo image... needs further investigation. Things are looking REALLY good now.


Just stumbled on this thread and always keen to get mame working better.
Can you explain how the prescale 4 is calculated and its relevance? Are you running on a 15khz monitor?

Cheers,

Dave
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 19th, 2010, 7:36 pm

This is not for CRT use.
Image
User avatar
pubjoe
Fosters Political Ambitions
Posts: 10619
Joined: August 19th, 2008, 8:58 am
Location:

Re: MAME scanline/shadowmask simulation

Postby pubjoe » April 19th, 2010, 7:55 pm

Nice work cools.

Personally, when I tried a single scanline every 4 pixels, I felt it looked too fake... too sharp and perfect pinstripes. Kinda reminded me of a gameboy screen.

It'd be cool if mame could add a little colour bleed/glow (like that 'bloom' effect) over the scanlines.

...I say that, but I have not tried your exact settings you just posted (with your .png), so I should probably try that before moaning.
User avatar
invzim
Posts: 466
Joined: August 17th, 2008, 5:26 pm
Location: Oslo, Norway

Re: MAME scanline/shadowmask simulation

Postby invzim » April 19th, 2010, 9:00 pm

Must admitI haven't read ALL the posts in this thread, but this stuff is REALLY not that complicated.
All you need is here:
http://jvspac.kirurg.org/?page=mame

refreshspeed option tunes the game speed to the refresh-rate you're currently using, so if your game originally runs 59.9 hz, and your monitor runs at 60hz - it slightly increases the speed in mame so that it matches up with 60hz - tearing problem solved.

For modelines (soft15khz), all you need is a close vertical refresh (hz), and exact horizontal resolution.
In The Name of Science!
User avatar
emphatic
Breastfeeds when required
Posts: 6959
Joined: April 7th, 2009, 4:14 pm
Location: Alingsås, Sweden
eBay: jorgen_sjolander
Initials: JOR

Re: MAME scanline/shadowmask simulation

Postby emphatic » April 19th, 2010, 10:03 pm

invzim wrote:I haven't read ALL the posts in this thread


This thread is to get a CRT look on an LCD screen. :awe:
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 20th, 2010, 10:15 am

pubjoe wrote:Nice work cools.

Personally, when I tried a single scanline every 4 pixels, I felt it looked too fake... too sharp and perfect pinstripes. Kinda reminded me of a gameboy screen.

It'd be cool if mame could add a little colour bleed/glow (like that 'bloom' effect) over the scanlines.


With x4 you have the ability to feather the scanlines more nicely than x3. What would be really nice is if we had a bilinear or similar filter to scale the image up by, and apply the scanline effect on top of that.
Image
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 20th, 2010, 11:49 am

Don't know if it's just me, but using D3D on any non 4:3 games gives a bad effect.
Image
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 20th, 2010, 12:40 pm

cools wrote:
pubjoe wrote:Nice work cools.

Personally, when I tried a single scanline every 4 pixels, I felt it looked too fake... too sharp and perfect pinstripes. Kinda reminded me of a gameboy screen.

It'd be cool if mame could add a little colour bleed/glow (like that 'bloom' effect) over the scanlines.


With x4 you have the ability to feather the scanlines more nicely than x3. What would be really nice is if we had a bilinear or similar filter to scale the image up by, and apply the scanline effect on top of that.


Oh look - that's precisely what D3D does!

prescale 1
effect cools_effect_x4.png

Still only working for 4:3 resolutions though :think:
Attachments
untitled.JPG
Image
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 20th, 2010, 4:04 pm

Okay. Feeling quite pleased with this.

Teh (mostly) definitive method for scanline/shadowmask in MAME.

Needs to be done per game. Per resolution really but copying and pasting per game anyway.

Lets take TNZS.

My monitor has a maximum resolution of 1280x1024 (5:4). TNZS is 256x224 (8:7).

So lets set the standard MAME settings up.

Code: Select all

video                     d3d
window                    0
keepaspect                1
prescale                0
effect                    none

Now, we create a scanline PNG (alpha transparency!) and a game layout file. I've used a resolution of 768x672 (256x224 x3) - even though I could fit an x4 resolution I've found D3D does something weird with it and it looks a mess.
256x224x3.png
(6.17 KiB) Not downloaded yet

Code: Select all

<?xml version="1.0"?>
<mamelayout version="2">
   <element name="overlay">
      <image file="256x224x3.png" />
   </element>

   <view name="Scanlines">
      <screen index="0">
         <bounds left="0" top="0" right="8" bottom="7" />
      </screen>
      <overlay element="overlay">
         <bounds left="0" top="0" right="8" bottom="7" />
      </overlay>
   </view>
</mamelayout>

These are saved in mame\artwork\tnzs as 256x224x3.png and tnzs.lay respectively. Note that the values for right and bottom in the layout file match with the aspect ratio of the game!

Which gives the following result:
Image6.jpg

What we've done here is let the graphics card scale the game image to the monitor resolution - with no prescaling so it stays slightly blurry (alter the prescale level to 2 for a sharper image, personal preference!), and also scale the scanline overlay to the monitor resolution before overlaying it onto the game image. Since the scaled game image and the scanline image have the same aspect ratios (and the scanline image resolution is an exact multiple of the game resolution) they fit together perfectly. You can use a x2 overlay image just the same, but it won't look as good.

Ideally you'd specify an monitor resolution of exactly the same number of lines as the scanline image, and disable any built in scaling in the monitor. I'm not able to do that here, but it should look superb if done correctly! This'd eliminate the compressed scanlines effect that's visible, particularly with vertical motion.

Note that I've not spent a huge amount of time on the scanline/mask image here - it's certainly possible to do far better but my interest only lies as far as proving it's achievable. :awe:
Image
User avatar
pubjoe
Fosters Political Ambitions
Posts: 10619
Joined: August 19th, 2008, 8:58 am
Location:

Re: MAME scanline/shadowmask simulation

Postby pubjoe » April 20th, 2010, 4:17 pm

Wow, I think that's the best result I've seen yet.

At first, I thought the lines weren't exactly aligned, but then noticed that's the antialiasing leaking over ...which actually gives it a bit of a glow effect. I like.

Only one thing now imo. The image needs compensatory brightening. No matter how much I've tried to do this, I've lost colour vividness. Maybe it's something to tweak in the graphics card settings instead of mame?
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 20th, 2010, 4:33 pm

pubjoe wrote:At first, I thought the lines weren't exactly aligned, but then noticed that's the antialiasing leaking over ...which actually gives it a bit of a glow effect. I like.

Only one thing now imo. The image needs compensatory brightening. No matter how much I've tried to do this, I've lost colour vividness. Maybe it's something to tweak in the graphics card settings instead of mame?


Yeah, the alignment is down to the graphics card processing and the output resolution. I'd love to see it on a correct multiple output res :D But it's not bad as is.

As far as the brightness goes - I think getting to a precise x4 scale would resolve that completely. Pushing the contrast up just a touch in MAME seems to work well though!
Image
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 20th, 2010, 4:49 pm

Here's Bakraid (320x240 4:3) at prescale 1, with a x3 scaled overlay (same texture as TNZS, but flipped upside down so the first dark line is right at the top of the image), and the contrast boosted to 1.2.
Image11.jpg


With more resolution it can only be done better :)
Image
User avatar
cools
Armed Police Buttrider
Posts: 13547
Joined: August 17th, 2008, 4:49 pm
Location: Wales, United Kingdom
eBay: hordarian
Initials: CLS
Contact:

Re: MAME scanline/shadowmask simulation

Postby cools » April 30th, 2010, 3:43 pm

Some more playing about. Think I've found the final flaws :) So now wikied! http://wiki.arcadeotaku.com/w/MAME_CRT_Simulation
Image
User avatar
emphatic
Breastfeeds when required
Posts: 6959
Joined: April 7th, 2009, 4:14 pm
Location: Alingsås, Sweden
eBay: jorgen_sjolander
Initials: JOR

Re: MAME scanline/shadowmask simulation

Postby emphatic » April 30th, 2010, 9:31 pm

Good man! :thumbup: :-D

Return to “Emulation Q&A”



Who is online

Users browsing this forum: No registered users