Normal Map Screen Curvature Shader Demo

Wondered if I could get a CRT curvature shader going using a texture, seems to work well enough. Smooth edges and it doesn’t hit my framerate all that hard, still above 700 fps on a potato.

It’s slower than the “dot(cc, cc) * distortion” method used in the cgwg CRT shaders and several others but it does allow for arbitrary displacements and warping. For example you could modify it to use a small warp texture that follows the mouse for a lightgun scope that zooms in with some distortion at the edges, or perhaps a projector aimed at an uneven surface, or separate it into 3 textures for individual RGB displacements and simulate a magnet on your simulated CRT.

Here’s a demo with aliaspider’s GLSLdev testing program and a quark shader. https://mega.nz/#!J0M0xSDB!JriDsvxNEUAEqIpm44F34OH7rDq4Ei3mjILORFwHB-s

libretro GLSL shaders are really unclear to me with all the bits and bobs everywhere, so this will mostly just serve as reference should anyone want to use the concept.

1 Like

The slang shaders are a lot cleaner, and have similar uniforms/syntax to the quark shaders you’ve been writing, though they don’t work with the GL driver, only vulkan and d3d10/11/12 (and Wii U). The GLSL shaders are a mess because they have to include a bunch of compatibility macros for different GPUs/compilers, but it allows the shaders to work everywhere, which is nice.

We hope to one day get GL over to using slang shaders, as well, which would make my life a lot easier :). In the meantime, I’m happy to help clean-up/convert shaders as needed.