CRT Shader?

This topic contains 39 replies, has 9 voices, and was last updated by  therevills 1 year, 4 months ago.

Viewing 15 posts - 1 through 15 (of 40 total)
  • Author
    Posts
  • #11812

    therevills
    Participant

    On the NES MonkeyX1 compo back in 2015, the entry EpicFox had a cool CRT shader effect.

    https://pixelpaladin.itch.io/epicfox

    PixelPaladin kindly supplied the source code too.

    Is there a way to port this MX1 to MX2 to produce a CRT effect? The original code used the class “Material”…

    #11814

    Ethernaut
    Participant

    Not the same shader, but I just made a CRT shader while “forcing” myself to learn shaders & mojo…
    Still WIP, and does not offer curvature/rounded corners yet, but shouldn’t be that hard to implement.

    https://github.com/DoctorWhoof/Mojo-Shader-Tests

    Test 7 is the CRT test.
    Have NOT tried this feeding an animated image, though. Have no idea how it will perform…

    Here’s how it looks in action. Textures are optimized for HiDPI screens like a MacBook Retina monitor. There will be texture scaling in lower resolutions, resulting in a messier shadow mask (the RGB dots on a CRT monitor) pattern.

    (right click and “open image in new tab”, then zoom in to see full resolution)

    #11844

    therevills
    Participant

    Cool! I’ll have a play soon! Thanks!

    #11847

    therevills
    Participant

    Hmmm… I’ve got no idea how to use that with real time graphics – lol!

    #11853

    Ethernaut
    Participant

    Yeah, I haven’t tried it yet.

    I wonder if there’s a way to “run” the shader on the image.Texture itself, instead of passing a new texture via image.Material.SetTexture like I’m doing here.

    Then again, maybe doing it like this is fast enough? You could render to an image canvas, then “feed” that image texture into the shader on every frame, then simply draw that back into the main canvas. Haven’t had time to test it out yet, but my guess is that it’ll be a little slow (I’m aiming for hidpi, so something like 2880×1800 at 60fps would be necessary).

    #11854

    Hezkore
    Participant

    I’m no expert on this subject, but couldn’t you just make a fullscreen shader?
    I have this outline shader that I just apply to the canvas itself 🙂

    #11855

    Ethernaut
    Participant

    I know that’s pretty basic, but how do you “feed” the canvas texture into the shader (in other words, how do you access it on the shader side so you can get the RGBA value of each pixel before you manipulate it)?

    In my case, I have a

    in the shader that needs to be updated on every frame. Is there a better way?

    #11856

    Hezkore
    Participant

    I can give it a try without changing your code too much…

    #11857

    Hezkore
    Participant

    Alright, I made a red square just moving about on the screen using the “updated” shader.
    It’s real ugly, but as a proof of concept 🙂

    Here’s the shader using m_ImageTexture0 for ‘blur’ and ‘sharp’ texture:

    And I massacred your M2 example as well heh:

    #11858

    Ethernaut
    Participant

    Awesome, thanks! This is exactly what I was asking!
    Will give it a try when I get home later today.

    🙂

    #11863

    Diffrenzy
    Keymaster

    Awesome, thanks! This is exactly what I was asking!
    Will give it a try when I get home later today.

     

    and then you’ll come hang out with us on #monkey2 on https://freenode.net/ like you used to! 😀

    #11880

    therevills
    Participant

    @ethernaut, just downloaded the git master zip and I cant compile examples 4, 7 and 8:

    4:

    7:

    8:

    This is using v1.1.08…

    #11881

    therevills
    Participant

    @hezkore – and I cant compile your example either 🙁

    #11882

    Ethernaut
    Participant

    Try the latest one. Just made some modifications with today’s M2 dev branch. Example 08 never worked, I just replaced it with an improved CRT “beam renderer” test. Now the scanline ends are more rounded, and the color blur looks better. Beam rendering still needs some tweaks before I add curvature.

    There’s something wrong with 4 – it compiles fine, but the shader has a weird red noise. Will look into it tomorrow.

    @hezkore – and I cant compile your example either

    That one is probably just the shader file name wrong somewhere, since those tags seem correct.
    That said, you seem to be in Windows, and I’m too lazy to boot in Windows to test it! 😛

    #11883

    therevills
    Participant

    Yep they both work (MojoShaders_07_CRT and MojoShaders_08_BeamCRT) although had to resize them 😉 Still running at 1920×1080 😛

    Now we need it in real time 🙂

Viewing 15 posts - 1 through 15 (of 40 total)

You must be logged in to reply to this topic.