MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Pages: 1

vio
MAME Fan
Reged: 09/30/14
Posts: 8
Send PM


Dynamic Scanlines application
#360297 - 11/11/16 01:29 AM Attachment: sample_output.7z 224 KB (9 downloads)


Hi,

I wrote an application to demonstrate proper generation of scanline effect for LCD-type monitors. You can download the latest version here:
https://github.com/srcstorm/lcd_scanlines/releases

How does it work?
In CRT displays, pixels of black lines are illuminated by active lines. However, this is true for both lines above and below the black line.

In order to simulate a CRT black line, brightness amounts that are coming from each line must be summed.

Static png masks that are used by MAME are not able to achieve this effect (although I prepared some masks that mimic it). So a new method must be used. Maybe HLSL scripts can do this.

Example with 50% scanline brightness:
rgb(200,60,0) ---> pixel of active line above
rgb(75,15,15) ---> pixel of black line
rgb(100,0,60) ---> pixel of active line below

As you see, each active line provides 25% brightness.

I wrote this application as a proof of concept. I'm presenting the idea. If you want to inspect the source code and adapt it to your needs, you can visit the project page:
https://github.com/srcstorm/lcd_scanlines

Edited by vio (11/13/16 11:41 PM)



vio
MAME Fan
Reged: 09/30/14
Posts: 8
Send PM


Re: Dynamic Scanlines application new [Re: vio]
#360307 - 11/11/16 01:47 PM


I couldn't attach multiple image files in forum post so I zipped them in the first post. Here are sample outputs:

Original picture (mirage):


2x scaling:


4x scaling:



Mr Ric
MAME Fan
Reged: 09/25/05
Posts: 251
Send PM


Re: Dynamic Scanlines application new [Re: vio]
#360316 - 11/11/16 07:54 PM


> I couldn't attach multiple image files in forum post so I zipped them in the first
> post. Here are sample outputs:
>
> Original picture (mirage):
>
>
> 2x scaling:
>
>
> 4x scaling:

Looks good!



Jezze
Reged: 03/14/05
Posts: 72
Send PM


Re: Dynamic Scanlines application new [Re: vio]
#360347 - 11/13/16 02:21 PM


You can get quite the same result by using these scan-line settings for HLSL.


Code:

scanline_alpha            0.75
scanline_size 1.0
scanline_height 1.0
scanline_variation 0.0
scanline_bright_scale 1.0
scanline_bright_offset 0.0
scanline_jitter 0.0
defocus 0.0,1.0



The de-focus on the y-axis merges the colors in a similar way.



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


Re: Dynamic Scanlines application new [Re: Jezze]
#360379 - 11/14/16 01:34 AM


> You can get quite the same result by using these scan-line settings for HLSL.
>
> scanline_alpha 0.75
> scanline_size 1.0
> scanline_height 1.0
> scanline_variation 0.0
> scanline_bright_scale 1.0
> scanline_bright_offset 0.0
> scanline_jitter 0.0
> defocus 0.0,1.0
>
> The de-focus on the y-axis merges the colors in a similar way.



scanline_alpha and scanline_size are not in the UI. I looked at the game ini, and they are there. I have alpha set to 0. In the UI I have scanline amount (which is not in the ini) at .5 , and have beautiful stock scanlines. See the discrepency?



Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



Jezze
Reged: 03/14/05
Posts: 72
Send PM


Re: Dynamic Scanlines application new [Re: Traso]
#360380 - 11/14/16 02:06 AM


The names of settings and the descriptions of sliders are not 1:1 the same. The documentation on mamedev.org can tell you which setting is related to which slider.



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


Re: Dynamic Scanlines application new [Re: Jezze]
#360399 - 11/15/16 06:24 PM


> The names of settings and the descriptions of sliders are not 1:1 the same. The documentation on mamedev.org can tell you which setting is related to which slider.


I gathered that, but the value difference between ui setting of one and ini setting of another isn't explained by it.



Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



Jezze
Reged: 03/14/05
Posts: 72
Send PM


Re: Dynamic Scanlines application new [Re: Traso]
#360404 - 11/15/16 08:22 PM


You know there is a hierarchy of .ini files in which settings of lower .ini files will be overridden by higher ones.

The (incomplete) order is:
[driver].ini
[system].ini
raster.ini
mame.ini

What .ini files are involved in your case?



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


Re: Dynamic Scanlines application new [Re: Jezze]
#360410 - 11/16/16 02:22 AM


> You know there is a hierarchy of .ini files in which settings of lower .ini files
> will be overridden by higher ones.
>
> The (incomplete) order is:
> [driver].ini
> [system].ini
> raster.ini
> mame.ini
>
> What .ini files are involved in your case?


I meant the game ini, which should have final say. In any case, I zero'd out the settings and created new inis. Fine now.



Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



vio
MAME Fan
Reged: 09/30/14
Posts: 8
Send PM


sRGB color space added new [Re: vio]
#360685 - 11/28/16 02:18 PM Attachment: sample_output.7z 400 KB (1 downloads)


New feature: sRGB color space aware processing option has been added. You can switch to this mode in Settings tab.

All images we see on our computers today are encoded in sRGB color space. sRGB is said to have non-linear gamma. This issue is thoroughly explained in this page:
http://www.4p8.com/eric.brasseur/gamma.html

sRGB standard was created based on CRT behavior. Gamma function of sRGB is an outcome of electrical characteristics of a CRT pixel. A table from Mr. Brasseur's article is shown below.


A CRT pixel uses no power when showing black color, and max power when showing white. But for any given color in between, the power usage is unpredictable (non-linear).

There is a non-linear scanline brightness phenomena, which was discussed here:
http://eab.abime.net/showthread.php?t=63009

I suppose sRGB gamma and non-linear scanlines are related. The brightness of a CRT pixel could be proportional to its power usage.

Through gamma function of sRGB, we can calculate the "real" brightness of each pixel. Hopefully in this mode, non-linear scanline brightness will be simulated in a technically correct way.


To demonstrate this new mode, I added the "Full" preset to settings. In linear mode this preset means %100 scanline brightness. However in sRGB mode the result is like this:



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


Your settings compared to.... new [Re: Jezze]
#360715 - 11/29/16 09:27 AM Attachment: bubbles jezze settings.png 176 KB (0 downloads)


> You can get quite the same result by using these scan-line settings for HLSL.
>
> scanline_alpha 0.75
> scanline_size 1.0
> scanline_height 1.0
> scanline_variation 0.0
> scanline_bright_scale 1.0
> scanline_bright_offset 0.0
> scanline_jitter 0.0
> defocus 0.0,1.0
>
> The de-focus on the y-axis merges the colors in a similar way.



HLSL stock except for scanline_alpha at .5 . They look the same to me. Or maybe paint messed them both up?

[ATTACHED IMAGE - CLICK FOR FULL SIZE]

Attachment



Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


two posts for two images because I can't be bothered with registering with lame image sites..... new [Re: Traso]
#360716 - 11/29/16 09:28 AM Attachment: bubbles - hlsl (05 alpha).png 176 KB (0 downloads)




[ATTACHED IMAGE - CLICK FOR FULL SIZE]

Attachment



Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Dynamic Scanlines application new [Re: vio]
#361631 - 12/23/16 06:12 AM


I've been always dissatisfied how the native scanline mask looks like so I started digging in the code and I found a solution. The screenshots are from my test build of GroovyMame, but it can be applied to the original mame.
Details in the link below

http://forum.arcadecontrols.com/index.php/topic,152660.0.html



vio
MAME Fan
Reged: 09/30/14
Posts: 8
Send PM


Re: Dynamic Scanlines application new [Re: Oomek]
#361660 - 12/23/16 09:48 PM


Thanks. I couldn't find the download link for the modded mame, but if it's working as seen on your screenshots, I'm looking forward to get a copy.


Pages: 1

MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 25 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2689