[HN Gopher] Simulating a CRT TV with C++ and OpenGL
___________________________________________________________________
Simulating a CRT TV with C++ and OpenGL
Author : ingve
Score : 66 points
Date : 2022-09-25 06:18 UTC (1 days ago)
(HTM) web link (nicktasios.nl)
(TXT) w3m dump (nicktasios.nl)
| 71a54xd wrote:
| Does anyone have experience doing this purely with FFMPEG?
| naikrovek wrote:
| yes the int10h font guy has some blog posts about it, with
| accompanying code on GitHub.
|
| https://int10h.org/blog/
| ncmncm wrote:
| I was hoping it would distort the image to round the corners and
| compress the edges.
|
| Extra credit for added snow.
| jeffbee wrote:
| These seem to regularly pop up on HN but the new ones never seem
| to describe the ways in which they differ from the now-20-years-
| old xanalogtv hack.
| dtx1 wrote:
| Quite interesting. The hardest part would probably not be the
| simulation but actually displaying what is simulated (in real
| time). You would need pretty high peak brightness and an insane
| refresh rate.
| jeroenhd wrote:
| I think modern (HDR with loads of nits of brightness, 144+ fps)
| gaming monitors should be able to get the effect down quite
| well. Nothing you'll find in a productivity oriented laptop but
| with the right tools you should be able to come quite close.
| dtx1 wrote:
| The peak brightness is there but not in per pixel dimmable
| displays (OLEDs) and you would need well above 15000 Hz to
| simulate a CRT.
| MarkusWandel wrote:
| This may not be perfectly realistic, but it's getting close and
| can be made closer. Not long ago, replacing a dead 26" colour CRT
| (say, in an arcade game machine) with a suitably masked 4K LCD
| panel would have been ludicrous. But we're pretty much there now.
|
| I thought when incandescent bulbs pretty much went away that I
| would miss the bare filament in a clear bulb look. I kind of do,
| but not much. I have a chandelier with the fake-filament LED type
| bulbs in it. Despite dubious cooling of the LEDs they seem to be
| holding up just fine in extended use, and while it doesn't look
| _quite_ traditional, it 's good enough.
|
| And emulation of older video game systems has moved into the
| browser!
| atum47 wrote:
| I did a project a few weeks ago where I was trying to emulate CRT
| images as well. End up creating a CRT converter for still images.
|
| https://victorribeiro.com/CRT/
|
| I guess each one of us remember CRT a little bit differently,
| since my images end up with vertical stripes instead of
| horizontal ones.
| mrandish wrote:
| Wow, I consider myself a pretty obsessive retro-gaming enthusiast
| (a custom-built arcade with 25-inch multi-scanning CRT, hacked
| graphics card and hand-tweaked GroovyMAME build) but damn,
| physically simulating a cathode ray tube is next level. Respect.
| simonblack wrote:
| _but damn, physically simulating a cathode ray tube is next
| level. Respect._
|
| Definitely. While I have simulated monitor screens that _were_
| originally physical CRTs, I still simulated them as though they
| were digital monitors with defined pixels.
|
| Definitely respect.
| some-guy wrote:
| I used a CRT for the first time in a long time a few months ago
| (embedded in a PowerMac 7200 all-in-one), and I forgot how
| stunning the picture looked compared to LCD/LED screens
| throughout the 2000s.
|
| Big problem though, I forgot how much they made my eyes _hurt_. I
| couldn't handle using it for more than 30 minutes. Increasing the
| refresh rate to 75hz helped a little bit, but wasn't enough to
| get me to stop causing a headache. I'm all for nostalgia but I
| think in the end it is good that we moved away from CRT
| technology (for many reasons).
| anthk wrote:
| NFSU2 on CRT looked glorious and vibrant. On LCD's it's pretty
| much bland and faded off.
| VikingCoder wrote:
| If you enjoy this look, I recommend checking this out:
|
| https://github.com/Swordfish90/cool-retro-term
| 323 wrote:
| Has author actually seen a CRT TV image in real life?
|
| Because it didn't look like that, you didn't have those clear
| distinct lines.
|
| Color CRT displaying a game, no lines:
| https://i.imgur.com/eI2yb7Y.jpeg
|
| Black & white CRT, you can barely make out the lines:
| https://d23gn3985hkc32.cloudfront.net/wp-content/uploads/202...
| an1sotropy wrote:
| Another way to think about the horizontal scanlines is that
| within the lines, there is really a continuous analog signal,
| undergoing various (analog) filters along the way from initial
| detection up through final display, but between scanlines there
| is discrete sampling. This can be emulated by digital filters,
| but even if the final display doesn't show the scanlines, there
| should be a different point-spread-function in the horizontal
| versus the vertical direction.
|
| There's also the possibility of emulating how the time
| resolution could be less than the refresh rate (sometimes
| sluggish phosphors create a kind of motion blur).
|
| Really old tv transmissions also had an effects like a high-
| pass filtering (I think to show better detail within limited
| dynamic range)[1], and how really bright spots would be
| surrounded by dark halos [2]. The distinctive "look" of old TV
| has a lot to do not just with the CRT display, but the
| characteristics of the analog method of video signal
| generation, in a video camera tube [3] that had its own cathode
| raw sweeping across the source image.
|
| [1] look at the edges of the desk at around 0:36 in
| https://www.newsweek.com/wmttv-black-white-color-first-time-...
|
| [2] https://movies.stackexchange.com/questions/113358/whats-
| with...
|
| [3] https://en.wikipedia.org/wiki/Video_camera_tube
| werdnapk wrote:
| I recall as a kid, getting right up close to the screen and
| looking at the picture on the TV and noticing the lines.
| Further away from the TV, then yes, the lines were not visible.
| mras0 wrote:
| Guess it depends. I haven't had a CRT TV for many years, but I
| have an old multisync CRT monitor and I can clearly see the
| individual raster lines (close up of 320x200 progressive scan:
| https://i.imgur.com/Osc4ZMm.jpeg). At normal viewing distances
| it's not noticeable though.
| smusamashah wrote:
| > At normal viewing distances
|
| Yes thats what it was all about. The pixelated game graphics
| were made with that and other CRT properties in mind.
| mras0 wrote:
| Yeah, and I seem to recall reading an article about some of
| the good old tricks (think it was about the Aladdin game?),
| but unfortunately I can't seem to find it now. Doing the
| dithering (by hand) just right would give a good effect in
| practice. Things made for real higher resolution monitors
| looked bad on lowres CRTs though (with very distinct
| scanline effects) as I recall like the menubar in my screen
| cap, even at a distance.
| MarkusWandel wrote:
| It would make sense to adjust the "line width" (focus!) of
| the scanlines so they blur into each other. But on a
| multisync monitor, this would be matched to the highest
| resolution it can display. Without fancy defocusing
| circuitry, of course if you display only 200 scanlines on a
| monitor capable of 5x as many, you're going to get a lot of
| black space between them. This bothered me personally, in
| those days, in my case with a 20" CRT monitor and emulation
| of my old C64 environment. Modern "CRT emulation" is better
| than the real thing, in this case.
| hulitu wrote:
| > multisync CRT monitor
|
| > 320x200
|
| 21" by chance ? Why would someone use 320x200 on a monitor
| when only the very old DOS games need such a mode ?
| mras0 wrote:
| 14" 1994 vintage Microvitec. Very popular monitor for Amiga
| systems because it supports 15KHz horizontal refresh rate
| modes (PAL/NTSC TV standard - for games/demos) up to 31KHz+
| (VGA) for nice flicker free 640x480 60Hz display
| ("productivity") modes for serious stuff.
| dm319 wrote:
| Deluxe Paint, ah! fond memories!
| wormik wrote:
| Imho electron gun alignment topic - see
| https://www.javatpoint.com/computer-graphics-color-crt-monit...
| ogurechny wrote:
| Along with different properties of the beam other comments
| mention, there was also a question of dot pitch, i. e.
| properties of the phosphor grid. Also, the circuits generating
| the signals in consumer hardware often did not have that much
| of the full bandwidth, or the most correct wave forms.
| SyneRyder wrote:
| _> Color CRT displaying a game, no lines:
| https://i.imgur.com/eI2yb7Y.jpeg_
|
| Try loading the 4000x3000 version of that image you linked and
| zooming to full size. Especially on the green character's
| outfit, you can see the scanlines on that color CRT display.
| 323 wrote:
| If you put your eyeball to the screen, sure, just like you
| can see the pixels of an LCD screen. But it's not how you're
| supposed to look at it.
| naikrovek wrote:
| I had a consumer CRT as a child (the family TV in the living
| room) whose scanlines were apparent even at 6ft away, and it
| was only a 19" screen.
|
| maybe my eyes were better than most, I don't know, but I
| distinctly remember trying to adjust the settings so the lines
| would go away, thus reducing the annoyance of my "all I can see
| is colored lines" brother.
| hulitu wrote:
| It seems that he didn't. And he also does not understand how a
| cathodic tube works (i.e. persistence).
| Asooka wrote:
| Some CRTs do have visible scanlines, some do not. Check out
| this thread
| https://shmups.system11.org/viewtopic.php?f=6&t=63197 .
| Personally I'd like the simulated CRT to have no scanlines,
| rather what I want is temporal ghosting (previous frame
| blending in the next one, used for transparency effects in
| games by blinking two images rapidly); and a filter to make
| pixels less blocky and implement colour bleed. Given the great
| number of CRTs out there you probably can't have a single one
| be the best ever, but perhaps emulating several known ones by
| twiddling the parameters of the shader and letting people pick
| would be the best.
| rikroots wrote:
| I _think_ I understood your requirements, so I tried to knock
| up a 2d canvas filter demo[1] which met them. Sadly I don 't
| think I met them, but I did end up creating a crazy weird
| motion blur effect (that's new to me) so thank you for
| helping me to accidentally create it!
|
| [1] - https://codepen.io/kaliedarik/pen/OJZzJJB ... warning:
| demo requests access to the device camera.
| jeroenhd wrote:
| When I look at CRT emulation, I always feel like I'm going
| crazy. It's been years since I last saw a CRT image but I
| don't remember visible scanlines at all.
|
| I know the retro space is often specifically emulating old
| hardware, was thing a thing in the 80s, perhaps? Or were
| visible scanlines more common in America than in Europe? I
| know the weird colours and lowered resolution of some
| (emulated) games are an artifact of differences in
| NTSC/PAL/etc., could that explain the difference?
| jerf wrote:
| They seem obsessed with simulated really _bad_ CRTs. I
| think you could see such scanlines if you were hooking up
| your Atari 2600 to a TV that was already a decade old, then
| sat right on top of it instead of across the living room
| because the cords were short and you wanted to see your
| games. I 've seen it on some arcade games, for similar
| reasons. But in general, CRTs didn't have those plainly
| obvious lines, no, because... the engineers would have
| engineered them out! And did. They're plainly unsightly and
| it isn't that hard to remove them, after all.
|
| I imagine part of it is the need to have visible
| differences strongly emphasized so it looks like the
| filters are doing something. A true CRT filter would be
| much more subtle and people might not thing anything has
| happened when you turn it on.
| orbital-decay wrote:
| _> They seem obsessed with simulated really bad CRTs. ...
| I imagine part of it is the need to have visible
| differences strongly emphasized so it looks like the
| filters are doing something._
|
| The main reason for that is that games of the era were
| targeted at the most common hardware, using very cheap
| composite circuits and CRTs as medium for artistic
| expression. In many games, you could easily miss
| gradients, rainbow effects, transparency, or something
| else with a high-end CRT.
| hulitu wrote:
| I played spectrum games on the spectrum connected to PC .
| Spectrum had a graphics resolution of 256x192 px and no
| scan lines were visible on a 24" TV.
| Asooka wrote:
| That seems pretty far-fetched. Do you have examples of
| such effects being shown wrong on CRTs without scanlines?
| doubled112 wrote:
| I don't think they're referring to scanlines
| specifically.
|
| Something like the waterfalls in Sonic the Hedgehog come
| to mind.
|
| https://gamedev.stackexchange.com/questions/167804/did-
| retro...
|
| There's an image on this page. The waterfalls don't look
| very good with sharp pixels. A CRT would blur and blend,
| and you'd have to assume the game designers knew it would
| happen. It's probably not just a happy accident.
| speeder wrote:
| doubled112 comment is excellent.
|
| Another example that is harder to show, is that many
| games used intentional flickering or other tricks to
| create some funky effects only possible with CRT.
|
| For example: if you transmit the data correctly (one
| frame is only odd lines, next frame only even lines) and
| flicker sprites at certain speeds, you can achieve some
| fancy transparency and overlay effects.
|
| Another trick is toy with timings to screw with
| resolution, color range and pixel shape.
|
| A less reliable trick is sub-pixel anti-alias relying on
| the TV geometry, since each manufacturer had their own
| patented geometry this was more problematic (for example
| Sony's Trinitron was aperture grille, each pixel was
| composed of columns of each color. Many other
| manufacturers went for triangular pixels instead. With
| the 3 primary colors arranged as round dots in a
| triangular pattern).
| acuozzo wrote:
| > They seem obsessed with simulated really bad CRTs.
|
| I think it's quite the contrary. They seem obsessed with
| simulating high end CRT studio monitors like the Sony BVM
| line which were very sharp and had a highly pronounced
| negative scanline space.
|
| The image on the left is from a BVM:
| https://i.imgur.com/cu4PdgF.jpg
| dehrmann wrote:
| > They seem obsessed with simulated really bad CRTs.
|
| Good PC flat screen CRTs towards the end of the CRT era
| looked as good as you could ask for. By modern standards,
| all that was missing was 120 Hz and hidpi.
| hulitu wrote:
| There were some who could do 120 Hz although for small
| resolutions. But hidpi was common. It took LCD monitors
| 10 years to catch up with hidpi and the colours are still
| problematic on the majority of LCDs.
| gattilorenz wrote:
| 120Hz was not that uncommon in the last years of CRTs,
| they could actually go higher:
| https://www.youtube.com/watch?v=ySQzXpYETXc
|
| I guess it all depends on what you define as "small
| resolutions". My stupid ADI monitor from 97 could do
| 1024x768@85Hz
| ogurechny wrote:
| > 120 Hz
|
| It always irks me that everyone seem to have completely
| forgotten that CRT monitors were routinely used in 75 Hz
| and 85 Hz (and even higher rates) and with various
| resolutions instead of the one and only 60 Hz in native
| resolution as with most LCD monitors. 60 Hz meant "I
| can't configure Windows" or "my video card or monitor
| can't handle more than that with resolution that high".
| 323 wrote:
| Because it sacrificed pixel accuracy - the horizontal
| lines were a continuous signal and the pixels kind of
| blurred into each other. Looking at a CRT monitor side by
| side with a LCD one was quite revealing - even a last
| generation 2005 CRT monitor with digital controls and OSD
| was a blurry mess.
|
| If you want both fast refresh rates and pixel accuracy,
| well, you kind of need today's technology. Not possible
| back then.
| 323 wrote:
| Really really old monitors had visible scan lines, like
| before 1985 or so: https://i.redd.it/o6gezzyw8dv61.jpg
| ogurechny wrote:
| It could be the opposite. Big high resolution multisync CRT
| monitors had to have fine dot pitch and finely focused
| beam. However, in lower resolutions the distance between
| scanlines was more noticeable, as there was limit to how
| wide and powerful electron beam could be. As for the lowest
| res CGA/EGA modes, VGA and later adapters simply had to use
| double scan to output anything decent on the CRT, so it was
| part of the standard.
|
| So people might be trying to mimic running 1987 games on
| 1997 hardware and not the look of original CGA/EGA/VGA
| monitors. Recreating some style is an artistic choice
| altogether anyway, and I think it's better to discuss it
| this way.
| bjt2n3904 wrote:
| Yeah -- it seems that so many of the CRT simulations way
| overemphasize the scan lines. I think if they added a bit of
| "bloom" to each pixel, it would make them less obvious?
| jeffbee wrote:
| They over-emphasize the negative space between the scan lines
| without getting the details of the raster scan correct. The
| forward scan lines are not horizontal, they are slightly
| tilted, because the vertical sweep is continuous. The retrace
| is also slightly slanted, but less because the retrace is
| faster. So in the diagram on this site the solid lines should
| be the ones that slope, and the dashed retrace lines should
| be the ones that are nearly horizontal.
| toast0 wrote:
| > The forward scan lines are not horizontal, they are
| slightly tilted, because the vertical sweep is continuous
|
| You can slightly tilt the yoke to make the horizontal lines
| more horizontal (although then vertical lines will be less
| vertical, tradeoffs everywhere)
| kevin_thibedeau wrote:
| That is a late 90s television with a small tube. You can most
| definitely see the scanlines on old arcade CRTs. The shadowmask
| on a color CRT enhances the lines so comparison to B&W isn't
| meaningful.
___________________________________________________________________
(page generated 2022-09-26 23:02 UTC)