Page 3 of 9

Re: MAME scanline/shadowmask simulation

Posted: January 15th, 2010, 12:39 pm
by gargoyle67
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-)

Re: MAME scanline/shadowmask simulation

Posted: January 15th, 2010, 12:43 pm
by cools
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.

Re: MAME scanline/shadowmask simulation

Posted: January 15th, 2010, 1:03 pm
by pubjoe
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.

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 3:24 pm
by cools
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.

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 5:24 pm
by cools
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.

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 5:38 pm
by emphatic
Wow! :shock: :awe:

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 6:13 pm
by cRacKh0rN
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

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 7:36 pm
by cools
This is not for CRT use.

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 7:55 pm
by pubjoe
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.

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 9:00 pm
by invzim
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.

Re: MAME scanline/shadowmask simulation

Posted: April 19th, 2010, 10:03 pm
by emphatic
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:

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 10:15 am
by cools
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.

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 11:49 am
by cools
Don't know if it's just me, but using D3D on any non 4:3 games gives a bad effect.

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 12:40 pm
by cools
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:

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 4:04 pm
by cools
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

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:

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 4:17 pm
by pubjoe
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?

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 4:33 pm
by cools
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!

Re: MAME scanline/shadowmask simulation

Posted: April 20th, 2010, 4:49 pm
by cools
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 :)

Re: MAME scanline/shadowmask simulation

Posted: April 30th, 2010, 3:43 pm
by cools
Some more playing about. Think I've found the final flaws :) So now wikied! http://wiki.arcadeotaku.com/w/MAME_CRT_Simulation"

Re: MAME scanline/shadowmask simulation

Posted: April 30th, 2010, 9:31 pm
by emphatic
Good man! :thumbup: :-D