Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
5th June 2014, 21:55 | #1 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
CRT emulation with scanline and phosphor effects
Download: crt_display v1.0
This function emulates a CRT display using aperture grille (Trinitron) or Cromaclear technologies. It is slow but gives interesting results. Could be nice to chain after a NTSC defect emulator like dotcrawlplus. It implements various features like:
Requirements: Dither 1.26.0 or above and its dependencies, Avisynth 2.6, RGB colorspace. Detailed instructions in the .avsi file. Prototype: Code:
Function crt_display (clip src, float sw, float sh, float "voff", float "ppp", \ float "cutoff", float "scandist", float "sharpv", float "sharph", \ float "blurh", float "glowgain", float "glowh", float "glowv", \ float "glowsens", float "contrast", float "gamma", float "softclip", \ float "mix", float "beamshape", bool "phosphor", bool "pgrid", \ float "vcs", float "cromaclear", float "maskpp", float "gainb", \ float "halgain", float "halrange", string "pixel_type") Examples of real NTSC footage with aperture grille (left) and Cromaclear shadow mask (right): Code:
ar = 10.0 / 11.0 crt_display (2*ar, 2, ppp=1*ar, blurh=2.0) # Left crt_display (2.5*ar, 2.5, ppp=1.25*ar, maskpp=1.25, cromaclear=1.0, voff=0.25) # right Note that the scanline density (480) makes difficult to reproduce the Cromaclear effect in a limited resolution and exhibits unwanted pattern effects. We would need at least three lines per scanline to give it a better look. But it works very well for upscaling 240p content, especially old-school videogame captures: Sources, point-resized: I don’t know at which gamma these pictures should be viewed so I kept them untouched like if they were in standard sRGB. Cromaclear display type: Code:
ar = 8.0 / 7.0 crt_display (5*ar, 5, ppp=2.5*ar, blurh=1.0, maskpp=2.5, cromaclear=1, scandist=1.5, cutoff=0.9, glowgain=0.125, halgain=0.03) Code:
crt_display (5*ar, 5, ppp=2.5*ar, blurh=0.75, scandist=1, cutoff=0.9, glowgain=0.125, halgain=0.03) Simple scanlines without phosphor effect: Code:
crt_display (5*ar, 5, ppp=2.5*ar, blurh=1.0, maskpp=2.5, phosphor=false, scandist=3, cutoff=0.8, glowgain=1.0, glowh=6, glowv=0, halgain=0.03, sharpv=2) More screenshots here. Default settings are generally OK, but tweaking the parameters can improve the results a lot. My 15 kHz CRT is gone for a long time and I only have half-decent monitor photos for reference, so any advice based on real CRTs is welcome to improve the emulation.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding Last edited by cretindesalpes; 7th September 2018 at 17:04. Reason: Fixed the gallery url |
5th June 2014, 23:41 | #2 | Link |
Registered User
Join Date: Jan 2010
Posts: 709
|
It's look very like my old Sony Triniton!!!
But Triniton have also a defect, there were some horizontal gray lines. http://www.dansdata.com/sg400.htm
__________________
powered by Google Translator Last edited by Motenai Yoda; 5th June 2014 at 23:44. |
6th June 2014, 00:07 | #3 | Link |
Registered User
Join Date: Dec 2007
Location: Germany
Posts: 632
|
Impressive!
Being a CRT expert and lover I definitely have to say this is the most authentic CRT simulation I've seen. Goes very nice especially with old games. I'll have some fun with this, even though I have plenty real CRTs right here. Edit: One thing I noticed is the scanlines in your simulation are more pronounced with the Cromaclear setting compared to the Trinitron setting. Well, in my experience, and I have a Trinitron as well as a shadow mask CRT side by side here, the scanlines are generally more pronounced with Trinitrion masks and slightly less with shadow masks. This is also commonly known among retro gamer "CRT fetishists" on the internet. Trinitrons have slightly more pronounced scanlines compared to shadow masks. Last edited by TheSkiller; 6th June 2014 at 00:18. |
6th June 2014, 00:24 | #4 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
TheSkiller:
Thanks. I agree with the Cromaclear/Trinitron mismatch. I just put different settings to show the versatility of the function, of course it’s possible to increase the scanline effect with the Trinitron. Motenai Yoda: Indeed, I haven’t included the “damping wire” effect. I’m not sure if it’s a wanted feature…
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
22nd September 2014, 13:48 | #12 | Link |
Registered User
Join Date: Sep 2014
Posts: 13
|
To the author of this script/OP of the thread, I know I asked this via e-mail, but is there any way to help with the speed for rendering a video with this? Rendering to an MP4 file on my machine takes sometimes upwards of a day for a five minute recording.
|
22nd September 2014, 22:03 | #13 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
Yes I saw your email but the previous week was quite intense for me IRL and I hadn’t the time to reply. Anyway I’m not sure about what is slow in the script, and if it can be optimized. I’ll try to benchmark it and narrow down the slowest parts in the next days but I cannot guarantee that I can come with significant speed improvement.
EDIT: I just found that vertical resizing/convolution in Dither_resize16 was not multi-threaded… Got a 75 % speed-up just by fixing it. More later.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding Last edited by cretindesalpes; 23rd September 2014 at 12:47. |
23rd September 2014, 18:53 | #14 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
As stated in my previous edited post, updating Dither to v1.26.5 will give a significant speed boost to crt_display. You can also maximize the CPU usage and double again the fps throughput by splitting the source video into 2 or 3 parts and encode them simultaneously.
These are probably the only large speed improvement left without altering the quality and accuracy of the emulation. I think implementing a native Dither_lut16 implementation (instead of a wrapper function around several mt_lutxy calls) could help a little too, as the function is heavily used. Next, there’s a great amount of finetuning to do (like cutting the number of taps to the strict minimum for the gaussian blurs, or reducing the vertical oversampling of the beam), but this is a lot of work for little results.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
4th October 2014, 18:50 | #15 | Link |
Registered User
Join Date: Sep 2014
Posts: 13
|
Thanks greatly for the reply. As I'm using AVISynth 2.6, what would you suggest further to improve? I've updated the dither plugins as suggested, and you've mentioned something about multi-threading. If it helps, here are my specs as well:
CPU: Intel Core i7-920 @2.8GHZ overclock RAM: Corsair XMS3 DDR3-10666 GPU: PNY GeForce GTS-450 Motherboard: Gigabyte X58A-UD3Rv1 PSU: Corsair TX750 HDD: 3x500GB Seagate Barracuda 7200rpm Capture Card 1: Startech PEXHDCAP (for anything above composite or s-video) Capture Card 2: Pinnacle Dazzle DVC-101 [Edit] Here's an error that shows up all too often for me. I wonder what I'm doing wrong? Last edited by NightSprinter; 5th October 2014 at 01:15. Reason: Add error screenshot |
7th October 2014, 00:32 | #16 | Link | |
ангел смерти
Join Date: Nov 2004
Location: Lost
Posts: 9,556
|
Quote:
|
|
9th October 2014, 03:39 | #17 | Link |
Registered User
Join Date: Sep 2014
Posts: 13
|
That seemed to work, though I guess even 6GB of memory may not even be enough to render the 240p deinterlaced image up to 1280x960 in VirtualDub. I had to use AVIDemux and its AVSProxy companion to render the video I had set up in my script.
|
9th October 2014, 08:58 | #18 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
With a regular Avisynth 2.6 version (32-bit single-threaded) you shouldn’t need such a huge RAM amount. Playing back a 224p to 1080p conversion in VirtualDub uses only 700 MB here. What is your script?
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
9th October 2014, 12:59 | #19 | Link |
Registered User
Join Date: Sep 2014
Posts: 13
|
My script looks like this (as I'm using the MT version of AVISynth, and did some deinterlacing of footage captured with a Dazzle at 640x480i)
Code:
SetMemoryMax(512) SetMTMode(3) SetMTMode(2) Import("crt_display.avsi") AviSource("converttorgb.avi") SeparateFields(AssumeTFF) #PointResize(640,480) #Scanlines(STRENGTH=0) ar = 1.0 / 1.0 crt_display (2*ar, 4, ppp=2.5*ar, blurh=1.0, maskpp=2.5, cromaclear=1, scandist=1.5, cutoff=0.9, glowgain=0.125, halgain=0.03) |
Tags |
crt, emulation, phosphor, scanline |
Thread Tools | Search this Thread |
Display Modes | |
|
|