DeVRAND

A lightweight programming blog for distraction-free reading.

A New Take on the CRT Shader

2018-08-03

The first somewhat-serious post-processing shader I wrote and released is now gone. I mean, it still lives in the depths of a version control system, but it is extremely likely that I am not going to touch it ever again. The fragment shader has been making the game look retro for as long as 24 updates, or in human terms, 175 days. Your lines of code will always be remembered. Rest in peace, crt.frag!

Why the Necessary Loss

Tears and mourning aside, let me explain the sudden change. To effectively do that, please have a look at the old shader first.

Arena Old Shader

It is made out of 3 different features during a single post-processing step. The most obvious one is the 3D screen bending effect that warps the corners and gives the feeling of a real game screen in front of you. I had many of you tell me you liked it on first sight which I was very glad about. This is fine, I am ready to move on and only receive hate-mail from now on.

This is fine

Secondly, note the horizontal scanlines, which - believe it or not - were moving! Bet your mind is blown by now. Lastly, the third component is a noise effect which makes everything blend in much nicer, but it has been a huge pain. Why, you ask? Video encoding and file size. As you can imagine, noise made the whole thing virtually impossible to compress, resulting in super high CPU while recording and large mp4 files.

Speaking of problems, let’s return to the screen bending effect for a short rant. That thing is evil as well. I bet it could work great with non-pixel-art visuals or with anti-aliasing in the pipeline, but Arena has neither of those. It warps text and pixel art to the point where it is unreadable, jagged and awkward. Notifications that appear in the corners look more like ancient runes or alien alphabets rather than human letters.

The Compromise

I will let you look at the new visuals straight away.

Arena New Shader

The new shader is also featuring 3 effects. First of all, the CRT, which is looking more realistic than ever - if you zoom in, you can see the red, green and blue pixels separately. What a time to be alive! Number two is the vignette so the screen does not look perfectly flat - it is not going to bend the screen as much as the actual screen bending does (wow, really?) but it does leave a nice bit of depth (is that a pun?). Lastly, there is gamma for color correction with a perfect balance of washing out colors and giving a pleasant tone. Alright, I just made that up, it probably does not do too much.

The screenshot of the new shader is 5 times smaller than the old one. Recording gameplay footages no longer turn my laptop into a reverse thermal power station. I can put text on the screen and the players will be able to read it. There are no jagged pixels all over the place. The noise is gone! You can probably tell that I am happy about this change. It fixes quite a few issues at the cost of looking less unique, but that is a trade-off I can live with.

Back to all posts