|
It is currently 2010-09-02 at 10:43 PM
|
View unanswered posts | View active topics
phosphor3x: CRT-Style Scaler - Feedback Needed!
| Author |
Message |
|
xythen
Joined: 2009-04-11 at 12:06 AM Posts: 39 Location: Scotland
|
 phosphor3x: CRT-Style Scaler - Feedback Needed!
. LATEST VERSION HERE. Video of it in action HERE (50MB direct download, no waiting!)  Ever since I first came across psiga's photoshopped CRT image I've been hoping someone would recreate it for emulators to use. I thought the Georgia Tech CRT simulator was pretty decent for a first attempt (though others clearly didn't). The recent thread on this board got me thinking about it again, especially after reading the discussions by the original creator of the image. Well, I got tired of waiting, so I decided to get off my arse and have a go at it myself. Since bsnes is the emulator I use the most, and byuu has expressed interest in seeing a filter like this up and running, I thought this would be as good a place as any to get some feedback & help. I've only been working on it for 4 days, so please be kind!  Ok, so based on the discussions between NFG & PSIGA, the algorithm currently does the following: 1. Each source pixel is represented by three rectangular red, green, & blue "phosphors", which are 2 pixels long. 2. There is a dark scanline every 3rd line. 3. "Phosphor bloom" is calculated independently for each phosphor. 4. Phosphors bleed more strongly into adjacent phosphors, and less so into the scanlines (not just a square gaussian blur!). I spent some time looking at other options, such as simulating a dot based shadow mask CRT, but after a lot of messing around this definitely seems the best looking (and easier) option. There's still plenty of additional things that could be added in the future, and lots of tweaking to be done I'm sure! Here's some comparison shots of the scaler in action:  <--- I like the smoke & text in this one       Combined with Blargg's NTSC filter:  An animated PNG (need recent version for Firefox or Opera to view):  It's currently all written in Matlab (I'm a physicist, not a programmer!  ), so once all the maths behind it has been hammered out I'll probably need some help converting it into C so it's actually useable. In terms of speed, it currently takes ~40% longer than a Matlab implementation of the optimised scale2x algorithm which I wrote from the description here. The algorithm is still in the very early stages, so feedback and suggestions are welcomed. In particular, the phosphor bloom response is purely based on what I think looks good. I tried to make it so that in very bright areas (e.g. white text) the phosphor structure and scanlines disappear, but still having darker areas barely bleed at all, and keeping the colours & gamma as close as possible to the original image. It's a fine line, so I'm interested to hear what other people think. Thanks!
_________________ CRT-Style Scaler - Feedback needed!
Last edited by xythen on 2009-07-14 at 09:40 PM, edited 8 times in total.
|
| 2009-07-05 at 08:18 AM |
|
 |
|
Ver Greeneyes
Joined: 2009-04-10 at 04:38 PM Posts: 1022 Location: The Netherlands
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
Me like  Could you upload the matlab code or give some technical specifications? (i.e. is the scanline completely dark without the bloom? What are the gaussian functions you're using to filter with? Thankfully it doesn't matter in which order you apply these, horizontal first or vertical first, so long as you use the output from one as the input for the other)
_________________ bsnes compilation guide for Windows (need to add x64 build instructions) Frequency Test 1.6, or Frequency Test 2.0 (for use with my updated Direct3D driver)
|
| 2009-07-05 at 01:16 PM |
|
 |
|
Screwtape
Joined: 2009-04-11 at 04:21 AM Posts: 378
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
xythen wrote: Well, I got tired of waiting, so I decided to get off my arse and have a go at it myself. Muahahaha, that's exactly what I had hoped would happen. :D Thanks for doing this! Quote: 4. Phosphors bleed more strongly into adjacent phosphors, and less so into the scanlines (not just a square gaussian blur!). As I understand it, this is an attempt to replicate the 'halo' effect of a bright light-source against a dark background (see: twinkling stars, lens-flare) rather than the scanline-smearing produced by NTSC (the emulation of which is blargg's job. :) Therefore, wouldn't a square gaussian blur be a better model? The only effect I can spot from psiga's photoshop demo that seems to be missing here is what I originally called 'beam misalignment', but which is probably just the effect of a larger blur radius. The key is probably in this post from Tursi - the ideal filter is not a blur but some kind of glow... perhaps like a bloom filter? At any rate, I'm mighty impressed with what you've done and I'm looking forward to see what you do next.
|
| 2009-07-05 at 03:02 PM |
|
 |
|
creaothceann
Joined: 2009-04-10 at 06:17 PM Posts: 620 Location: Germany
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
I'd like a 4:3 aspect ratio, but it's already looking good so far!  The filter combined with the NTSC emulation sounds promising...
_________________ vSNES | Delphi 10 BPLs bsnes launcher with recent files list
|
| 2009-07-05 at 03:19 PM |
|
 |
|
Ver Greeneyes
Joined: 2009-04-10 at 04:38 PM Posts: 1022 Location: The Netherlands
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
creaothceann wrote: I'd like a 4:3 aspect ratio, but it's already looking good so far!  That's tough unfortunately. Since stretching 8:7 to 4:3 means stretching it by 7/6, and you want to split the pixels up into 3 phosphors, that means each pixel will be stretched by 21x18. Obviously that detail is going to be lost in the final image displayed on your monitor, and anyway no filter would output at that size. (ready for your 5376x4032 filter output?  ) You could in theory have it output the input scaled by 7x6 and blend the phosphors together itself, which might look -slightly- better than if bsnes did it post-filtering from a stretch of 3x3. You'd also have to set bsnes to 4:3 manually to avoid stretching artifacts (and enable aspect ratio correction) due to how the filtering system works, and it would still be scaled down for your monitor.
_________________ bsnes compilation guide for Windows (need to add x64 build instructions) Frequency Test 1.6, or Frequency Test 2.0 (for use with my updated Direct3D driver)
|
| 2009-07-05 at 03:44 PM |
|
 |
|
creaothceann
Joined: 2009-04-10 at 06:17 PM Posts: 620 Location: Germany
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
Here's the SoM2 image stretched:  It's not perfect (the 'columns' are a bit wider than in the source image), but quite good for a cheap solution imo. EDIT: How about going backwards from the monitor? Let's say we have a 1280x960 screen, divide each line by 3 to get the number of phosphor cells, and distribute the SNES signal evenly over this line.
_________________ vSNES | Delphi 10 BPLs bsnes launcher with recent files list
|
| 2009-07-05 at 04:49 PM |
|
 |
|
xythen
Joined: 2009-04-11 at 12:06 AM Posts: 39 Location: Scotland
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
Well I'm glad there seems to be some interest in this!  Thanks for all the comments so far! Ver Greeneyes wrote: is the scanline completely dark without the bloom? Yes, every third line in the pre-bloom image is black. Screwtape wrote: Quote: 4. Phosphors bleed more strongly into adjacent phosphors, and less so into the scanlines (not just a square gaussian blur!). As I understand it, this is an attempt to replicate the 'halo' effect of a bright light-source against a dark background (see: twinkling stars, lens-flare) rather than the scanline-smearing produced by NTSC (the emulation of which is blargg's job.  Therefore, wouldn't a square gaussian blur be a better model? My original implementation used a 5x5 gaussian kernel, but I wanted to try and simulate an effect metioned by NFG: Quote: on the old CRTs, a brighter signal (more power to the firehose) would result in a wider scanning beam, which in turn would create an illuminated line that was thicker, and would encroach on the dark spaces (scanlines) between the beams. I felt that using this kernel gave a closer approximation to that, but it's certainly something I'll be looking at again. It's fairly trivial to change the size and shape of the bloom kernel. Screwtape wrote: The only effect I can spot from psiga's photoshop demo that seems to be missing here is what I originally called 'beam misalignment' I'm not too sure what you mean by this. I assumed the effect you mentioned was the red/blue halos present at high contrast edges, which are easy to see in the FFVI image around the text. Could you elaborate on what "beam misalignment" is, and how it manifests itself in the final image? Screwtape wrote: the ideal filter is not a blur but some kind of glow... perhaps like a bloom filter? Sorry if I wasn't too clear. I am in fact employing a bloom filter; each phosphor bleeds and combines additively with its surrounding pixels, determined by the form of the sliding kernel. creaothceann wrote: How about going backwards from the monitor? Let's say we have a 1280x960 screen, divide each line by 3 to get the number of phosphor cells, and distribute the SNES signal evenly over this line. That could actually be a best solution to the non-3x scaling problem. I'll give it a go and see how it turns out! 
_________________ CRT-Style Scaler - Feedback needed!
|
| 2009-07-05 at 05:46 PM |
|
 |
|
Ver Greeneyes
Joined: 2009-04-10 at 04:38 PM Posts: 1022 Location: The Netherlands
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
creaothceann wrote: How about going backwards from the monitor? Let's say we have a 1280x960 screen, divide each line by 3 to get the number of phosphor cells, and distribute the SNES signal evenly over this line. Well, that assumes we have access to information about the screen resolution, the scale factor that bsnes is set to, and whether aspect ratio correction is on (and what the correction factor is). Let's see ... Code: temp = [is aspect ratio correction turned on] ? [aspect ratio correction factor] : 1.0; if(scale == max) nPhosphors = [monitor y-res] * (8/7) * temp / 3; else nPhosphors = scale * [SNES x-res] * temp / 3; Or some such.
_________________ bsnes compilation guide for Windows (need to add x64 build instructions) Frequency Test 1.6, or Frequency Test 2.0 (for use with my updated Direct3D driver)
|
| 2009-07-05 at 06:16 PM |
|
 |
|
tetsuo55
Joined: 2009-06-01 at 09:57 PM Posts: 279
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
Wow good stuff! Thank you!! thank you!! NTSC+phospor3x looks really good. Here are my musings (with some help by blargg) http://security-emulation.blogspot.com/ ... ation.htmlImho the current version of your filter makes the image slightly too soft.
|
| 2009-07-05 at 08:37 PM |
|
 |
|
xythen
Joined: 2009-04-11 at 12:06 AM Posts: 39 Location: Scotland
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
It seems the scaling issue really boils down to a CRT dot pitch issue. There are two ways to go about it: perform the filtering at 3x then scale the filtered image to the output res (eg 1600x1200), or scale the original image to the output res then perform the filtering. Here's a comparison of that:  For reference, here's the above images scaled without the filter applied:  The effect then is to essentially change the number of phosphors which represent a source pixel. The first case is like having a tv where the dot pitch matches the input resolution (each phophor triplet = 1 input pixel), and the second is like having a fixed dot pitch which fills your screen, with the input image scaled to match your resolution. The second case is how a CRT actually works, but I kinda like the first case too cause you seem to lose some of the nice bloom effects. It may just be that I need to change how the algorithm works to make the second case look better. Thoughts anyone? Incidentally, for any resolution less than 3x you need scale to 3x, filter, then scale back down, otherwise you run into aliasing issues due to undersampling. Interesting musings! I actually remember following a thread you started on the zsnes board a while ago when you were having a rather heated discussion about various aspects of CRT simulation with blargg and others.  (I think it was you anyway, my memory may be failing me...)
_________________ CRT-Style Scaler - Feedback needed!
|
| 2009-07-05 at 09:38 PM |
|
 |
|
creaothceann
Joined: 2009-04-10 at 06:17 PM Posts: 620 Location: Germany
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
xythen wrote: The effect then is to essentially change the number of phosphors which represent a source pixel. Could that be made an option, or is the current way just how the algorithm works? The "phosphor triplet = input pixel" statement seems a bit incredible to me - is the analog nature of the TV really that exact? Maybe I just don't know enough about the phosphor layer. On the other hand, the second picture clearly shows a grid that is too fine, so that idea doesn't really help.
_________________ vSNES | Delphi 10 BPLs bsnes launcher with recent files list
|
| 2009-07-05 at 09:54 PM |
|
 |
|
Ver Greeneyes
Joined: 2009-04-10 at 04:38 PM Posts: 1022 Location: The Netherlands
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
creaothceann wrote: On the other hand, the second picture clearly shows a grid that is too fine, so that idea doesn't really help. We could always experiment with different scale factors. i.e. say it corresponds to the phosphor layer on a particular model of TV, which happens to have a certain resolution.
_________________ bsnes compilation guide for Windows (need to add x64 build instructions) Frequency Test 1.6, or Frequency Test 2.0 (for use with my updated Direct3D driver)
|
| 2009-07-05 at 09:58 PM |
|
 |
|
xythen
Joined: 2009-04-11 at 12:06 AM Posts: 39 Location: Scotland
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
creaothceann wrote: xythen wrote: The effect then is to essentially change the number of phosphors which represent a source pixel. Could that be made an option, or is the current way just how the algorithm works? It could be made an option. I guess you would just define how many phosphor triplets you want per line, then scale the image to 3x that number, stretching the final image to the desired display resolution. Not sure how well it would work, but I'll try it out and see. creaothceann wrote: The "phosphor triplet = input pixel" statement seems a bit incredible to me - is the analog nature of the TV really that exact? Haha, not really. If you did have a tv where the dot pitch matched the input resolution the screen would be about 2 inches big. And like you say, the analog conversions mean it doesn't really work like that in real life, so the second option (scale the image up, then filter it) is actually the more realistic way of doing it.
_________________ CRT-Style Scaler - Feedback needed!
|
| 2009-07-05 at 10:05 PM |
|
 |
|
Firebrandx
Joined: 2009-04-10 at 11:51 PM Posts: 224
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
My only problem with these filters is how blurry it makes the images look. An interesting novelty effect, but I prefer sharp and well-defined pixels for serious play. I remember chasing after better and better image quality on the SNES itself. First I started off with composite video, then a friend turned me onto S-Video, then still later I ended up making my own RGB cable and hooking the SNES up to an arcade monitor. Imagine that phosphor effect only with sharp pixels and that's pretty much how it looked.
|
| 2009-07-05 at 10:55 PM |
|
 |
|
byuu
Joined: 2009-04-10 at 03:00 PM Posts: 3068
|
 Re: phosphor3x: CRT-Style Scaler - Feedback Needed!
So far, it's really exceptional!! Thank you so very much for actually attempting this :D If we get the algorithm down, I'll do my best to convert it to C++ and optimize it.
Right now, my concerns are that it's 3x (much slower to upscale, and I can't work with hires / interlaced mode at that size), and that it lacks much of the bloom effect of the original. For instance, the waterfall and hat at the top-right lacks the kind of halo glow you see in the source pic. The original also didn't look as checker-boarded from the phosphors, most likely a result of being only 2x.
But those are downsides only against the source image. The source is a bit surreal and 'better-than' a real TV, whereas yours looks a lot more like staring at a TV up close :D
_________________ Elements of the past and the future, combining to make something not quite as good as either.
|
| 2009-07-06 at 01:21 AM |
|
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
|
|