Choosing how to go about CRT (retro arcade screen) effect?

Hello there.

I am trying to get the hang of creating a retro-looking screen for a game I am making. Here is a screenshot:

What I have done is add one 30th of the y coordinates distance to the center y coordinate to x; per pixel of course (these are shaders!).

But I have come across a problem: the shader only seems to be effecting the pixels with a texture bound to them. See the next picture where the view is slightly off of the map:

Correct me if I am wrong; shaders do not effect pixels that are cleared onto the screen every render call. So I could make a background image for the game; but that seems a tad messy, and I wanted to know if there was another way.

So, I want my shader to effect backgrounds; or I could go with another option: use the vertex shader to ‘squeese’ the screen in on itself for a CRT effect. This should solve my problems?

Which do you think I should use?

I personally would just make the background a texture, that seems (in my opinion) far easier. Does the vertex shader process pixels that aren’t being “used”? Like, the pixels that don’t have any geometry being rendered “in” them? (Wow, I’m not making much sense). I don’t believe they do, so I would just go with the texture idea.

G’day Wesley,

Groovy looking effect. No, a fragment shader won’t run unless the fragment contains geometry, and has passed the required tests to be drawn. I’m not quite sure what you are getting at with your vert shader idea. However one approach could be to draw a fullscreen quad prior to rendering the rest of your scene. You could then use a fragment shader on this quad to get the desired background effect. If you are just going for a simple stretching effect on a solid background colour, then there is no need to use textures. You could calculate your colour within the shader.

Obviously drawing a fullscreen quad and running a frag shader for every fragment, even ones that are going to be over-drawn, is inefficient. If this becomes an issue you could probably work out some optimisations; the stencil buffer might be a good place to start. (I’m getting out of my depth here now… so that’s enough from me).