Anyone have a CG version of TheMaister's border shader?

I’m putting the finishing touches on a 8-pass(!) old-school TV simulator .cgp and I hope to release it on the board very soon, it is built on pre-existing shaders but each one is tweaked to achieve what I think is the perfect CRT filter (not that i’m biased or anything…), but to complete the experience I want to overlay a TV graphic as seen on Hunter’s blog

If anyone has it converted I’d really appreciate it.

Also a quick question too, the filter stack i’ve come up with is heavily dependent on Blargg’s CPU filters to make it look as good as it does but naturally there is no shader port of these yet. Whenever I combine a curved CRT shader with the CPU filters, it tends to make the distortion all out of wack. I’ve been able to edit CGWG’s CRT filter to a point where it curves up near the top but unfortunately the bottom of the screen remains flat/square, it almost gives it sort of a trinitron barrel shape which is not bad terrible in itself but obviously i’d love to get it looking perfectly curved equally on all sides. Does anyone know a fix for this?

I think the border shaders from common-shaders do pretty much the same thing: https://github.com/libretro/common-shaders/tree/master/Borders

As for the filter interfering with the shaders, I don’t seem to have that issue :confused: Care to post a screenshot?

Here is what I get using CRT-cgwgr.cg with barrel distortion at .4

When I add NTSC-SVideo.filter (or any other of blargg’s ntsc filters for that matter) I get this

Also I looked at the border shader code but not sure how do I get it to display a 1080p (or 1200p in my case) background.png? When I apply the shader I just get a black screen.

By the way, here is a preview of the shader stack i’ve been working on. It should really be seen in motion as it has a bit of mudlord’s old tv/noise filter but very very faint, just enough though to make the screen come alive instead of being static pixels. I know it’s not everyone’s taste who enjoy razor-sharp thick scanlines with no fringing but it is like the TV I grew up playing nintendo on :slight_smile:

Heh, those look fun. I can relate to your desire to recreate the shitty TV you grew up with. :slight_smile:

Ah, the Cg version definitely exhibited the same issue on my end (I was using the GLSL version before). To fix it, you can modify the radialDistortion function (starts at line 108) from this:

// Apply radial distortion to the given coordinate.
float2 radialDistortion(float2 coord, input ruby) {
    coord *= ruby.texture_size.x / ruby.video_size.x;
    float2 cc = coord - 0.5;
    float dist = dot(cc, cc) * distortion;                
    return (coord + cc * (1.0 + dist) * dist) * ruby.video_size.x / ruby.texture_size.x;
}

to this:

// Apply radial distortion to the given coordinate.
float2 radialDistortion(float2 coord, input ruby) {
    coord *= ruby.texture_size / ruby.video_size;
    float2 cc = coord - 0.5;
    float dist = dot(cc, cc) * distortion;                
    return (coord + cc * (1.0 + dist) * dist) * ruby.video_size / ruby.texture_size;
}

That is, take the *.x part off of the *_size references.

Thanks Hunter, now about the border shader, how do I get it to load a background.png instead of the screen going black?

I used up my 8-passes so I might have to modify things a bit to squeeze in a border on top.

To your cgp, you’ll need to add some things to tell it where to look for the textures. Assuming you’re using border-centered-non-fbo.cg, add this to the bottom of your cgp:

textures = "bg"
bg = relative/path/to/file.png
bg_linear = true

Also, make sure you set the scale_type for that shader pass to ‘viewport’ instead of source.