CRT scan line retro shader effect.

video best viewed fullscreen!

Knowing I would need a render texture to draw on, in order to make a screen effect I simply started with the RayLib letterbox example. Which is a little ironic as I soon discovered that the approach I’m using doesn’t scale well, I’ve ended up limiting the windowed mode and render texture to quarter HD resolution and when in full screen mode scaling the quarter HD to full HD, as its a 1:4 scale it doesn’t mess up the scan line effect.

The shader draws every fourth line much dimmer (rather than making it black) this still gives a good scan line effect but still allows features like text still easily readable. Just a scan line effect on its own isn’t quite enough however so by adding a simple bloom effect with the right parameters we get a bright slightly washed effect with ghosting.

As a final touch I added a small number of random “speckles” to give a slight interference, this looks best if left subtle as you can definitely over do it! in order for the interference not to look too hi res, they are 4×4 rectangles which are alpha blended.

You could take it further and bend the top and bottom areas down and up, so the corners don’t make a sharp rectangle, but on balance the amount of render time that could take probably wouldn’t wouldn’t be worth it.

You can get the working source code here


  1. Hi, I assume your name is Chris based on your YouTube handle. Can I ask if you continued to mess with shaders in C after you made the CRT example? I ask because I can get the bloom post-processing effect to work as it does in the simple Raylib examples, where there is one function (main). But if I try to add bloom to say, something like the example Raylib asteroids, where there are multiple functions (main, initgame, updategame, drawgame) I end up with the bloom visually working, but my MacOS terminal, from which I launched my compiled multi-function example, my MacOS terminal is nonstop scrolling of FBO object and Texture updates. That tells me I am almost there but have something in the wrong place. I am looking for a more suitable example. You don’t know me, and I hate to bug you with a question like this. I politely asked on Discord and the most helpful response I got was… “Are you using a debugger?” Anyway, please let me know if you have created or have encountered such an example. I’d be happy to send you something retro-gaming related for your trouble. Cheers.

Leave a Reply

Your email address will not be published.