Homepage Forums RetroPie Project Video Output on RetroPie crt-pi a Pi2 friendly CRT shader

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #109836
    davej
    Participant

    Here is the Pi2 friendly CRT shader I promised in another thread.

    It does:

    Curved screens.
    Scan lines that match the curved screen.
    Multi-sampling to reduce the effects of moire.
    Scan line bloom (brighter lines are wider).

    All while keeping a high frame rate. (I might have been a bit optimistic aiming for 1080P@60Hz but it’s faster that all those shaders that do scan lines and curved screens.)

    I’ve abandoned the two fancy filtering effects I’d been trying. The simple one I had originally planned to use looks just as good and is a bit faster. Turning off the screen curvature and multi-sampling speeds things up a bit too.

    The shader itself is called [b]crt-pi[/b].

    Unzip the file into your shaders/crt directory

    The zip file also includes two bonus shaders:

    [b]crt-pi-barrel[/b] is the screen curvature only shader I posted about a month ago updated to allow different levels of distortion horizontally and vertically.

    [b]crt-pi-mask[/b] is to help people producing overlays. It ignores the contents of the game screen and displays black pixels where the screen should be and white pixels where the border would be. Take a screen shot of this and it’s the perfect shape to be used a mask for defining the hole for the screen area in an overlay.

    Let me know what you think.

    davej

    #109841
    Floob
    Member

    Really impressive. I like it!

    I’ve put a quick video together here showing it in action

    #109854
    stathman
    Participant

    Thanks a lot!

    This is by far the most pleasing to my eyes shader and it is not slowing things down.

    Well done!

    Is it possible to skip the screen distortion somehow?

    Thanks again.

    #109870
    gizmo98
    Participant

    Thank you davej!
    I have added your zip file to our shader repo. If retroarch is installed/updated from source all new shaders will be fetched. So everyone can test these shaders easily.
    https://github.com/gizmo98/common-shaders/commit/7097eb6b093dc0c7722a988553d741f30b45d4fc

    #109890
    davej
    Participant

    [quote=109854]Is it possible to skip the screen distortion somehow?

    [/quote]
    There are some variables set at the top of the shaders/crt-pi.glsl file that can be used to control some aspects of the shader.

    #define MULTISAMPLE
    #define CURVATURE
    #define BARREL_DISTORTION_X 0.15
    #define BARREL_DISTORTION_Y 0.25
    #define MASK_BRIGHTNESS 0.65
    #define SCAN_LINE_WEIGHT 6.0
    #define BLOOM_FACTOR 1.5
    #define INPUT_GAMMA 2.4
    #define OUTPUT_GAMMA 2.2

    You can change the curvature by changing the BARREL_DISTORTION_X and BARREL_DISTORTION_Y values (0.0 will turn it off for that dimension). Better, you can turn if off entirely by commenting out the CURVATURE line (put a double slash // at the start of the line). This will cause it to skip the distortion code and speeds up the shader a bit. The barrel and mask shaders can be similarly controlled but just have the BARREL_DISTORTION_X and BARREL_DISTORTION_Y values.

    You can similarly comment out the MULTISAMPLE line and speed things up a bit by skipping the multi-sample code – at the risk of increasing moire effects.

    MASK_BRIGHTNESS controls how bright the screen will be.

    You’re best leaving the others alone. Altering SCAN_LINE_WEIGHT and BLOOM_FACTOR will likely make moire effects worse. The two GAMMA values affect brightness and should not need changing on a correctly configured monitor (and if you monitor is not correctly configured, fixing that is a far better idea).

    It’s perhaps worth pointing out that the shader is designed to be used with linear filtering. CRT electron beams are not square and the combination of linear filtering with scan lines and bloom makes the edges of bright pixels next to dark pixels rounded which looks a bit more accurate. People are of course free to set filtering to nearest if they prefer.

    I’ll see if I can get the shader parameter editing that works with .cg shaders working with .glsl ones next week. The automatic conversion process normally used strips them out but I don’t know if that’s because they won’t work or just because it’s just a deficiency in the conversion process.

    davej

    #109920
    stathman
    Participant

    Thanks for the info davej.

    #110342
    davej
    Participant

    I’ve tried the shader configuration editing that CG shaders support with GLSL shaders and it does work, so here’s an updated version of my shaders. You can now edit most of the configuration parameters in RGUI.

    You can stop screen curvature by setting the two curvature values to 0.0 but, as before, commenting out the [b]#define CURVATURE[/b] line is better as it runs faster. (It runs less code rather than runs code which has no effect.)

    Multi-sampling is still controlled by editing the shader file to disable code as well for similar reasons.

    I tried it with my early 256Mb Pi1 model B and it works pretty well on that (admittedly overclocked a 900Mhz) so it should be OK on a model A too.

    davej

    #110787
    patl
    Participant

    I recently tested your amazing filters.
    As you have already written, it is a bit too slow in 1080p.
    Only at a resolution of 1360×768 (most HD Ready devices) it’s really smooth, especially for SNES.
    But there is the problem with the colors of the scanlines if the display is curved.
    It is somewhat difficult to describe, so I made a screenshot.
    I’ve Played around with the filter something, to amplifies the effect.
    (but I can not really modify it)
    The effect occurs even at 1080p, due to the higher resolution, you can see it but barely.
    If the screen is not curved, the effect does not occur.
    Maybe you can calculate the scanlines in a different way.
    And it would be good if you could adjust the brightness of the scan lines.

    [attachment file=”RetroArch-1127-112659.png”]

    #110828
    davej
    Participant

    [quote=110787]I recently tested your amazing filters.
    As you have already written, it is a bit too slow in 1080p.
    Only at a resolution of 1360×768 (most HD Ready devices) it’s really smooth, especially for SNES.
    But there is the problem with the colors of the scanlines if the display is curved.
    It is somewhat difficult to describe, so I made a screenshot.
    I’ve Played around with the filter something, to amplifies the effect.
    (but I can not really modify it)
    The effect occurs even at 1080p, due to the higher resolution, you can see it but barely.
    If the screen is not curved, the effect does not occur.
    Maybe you can calculate the scanlines in a different way.
    And it would be good if you could adjust the brightness of the scan lines.[/quote]

    That’s the moire effect that comes from trying to display curved lines on a display with pixels in a straight line. Some displays show it more than others – one of my monitors barely shows it at all, another shows it a bit and on my TV it’s quite noticeable. Unfortunately the best you can do is try to minimize it if you can.

    Some things I did find helped with my TV that you might like to try:

    Don’t let the display do any scaling. i.e. Don’t set the Pi to a 720 screen mode and let the TV upscale to 1080. Run the Pi at the screen’s native resolution and set a viewport in Retroarch for the resolution you want. This will result in borders round screen but will produce a better picture.

    Setting the screen height to be either 3 times (for a 720 screen) or 4.5 times (for 1080) significantly reduced the moire effect. The easiest way for 3 times is to use integer scaling but you lose the 4:3 aspect ratio if you do that. The best way is to set a custom aspect ratio (Options->Video Options->Custom Ratio). 224×3 = 672 so you only lose 1/16th of the screen height on a 720 display (1/8th for 768). 4.5×224 = 1008 and you again lose 1/16th of the screen height on a 1080 display. To maintain a 4:3 aspect ratio you’d want to set custom ratios of 896×672 or 1344×1008.

    Stronger scan lines produce worse moire effects and the value chosen is designed to balance being visible whilst minimizing moire effects. The scan lines are based on those in the crt-geom shader (which seemed to have the best/least moire) and one of the optimizations I did to get my shader going as fast as it does was to simplify the maths around how they are calculated. Doing this lost the bits that allow them to be easily changed in crt-geom.

    #118382
    jamesthomas510
    Participant

    I am new to raspberry pi. I downloaded the file, but I don’t know what to do from there. What file do I put them in and how do I apply those files in retropie?

    #120800
    mydriaze
    Participant

    Hello,

    First, you have to put this file in the shader directory. You can upload it using FTP as described here: https://github.com/retropie/retropie-setup/wiki/Transferring-Roms

    Then, you simply have to edit the retroarch.cfg file in the \\RETROPIE\configs\all folder by modifying 2 lines. first, tell me if you succeed transferring your roms, then we will do the 2nd part. :)

    #120840
    jamesthomas510
    Participant

    Yes, I have my roms transferred, I just need to learn how to have the crt shader to add the curvature to the screen.

    #120978
    mydriaze
    Participant

    ok, go to your config folder and open retroarch.cfg:

    Look for this and modify false/true:

    # video_shader_enable = true

    # Smoothens picture with bilinear filtering. Should be disabled if using pixel shaders.
    video_smooth = false

      and:

    If you know exactly the shader you want to use for all your system, simply enter the right path :

    # Path to shader. Shader can be either Cg, CGP (Cg preset) or GLSL, GLSLP (GLSL preset)
    # video_shader = “/path/to/shader.{cg,cgp,glsl,glslp}”

    So, it will become:

    # Path to shader. Shader can be either Cg, CGP (Cg preset) or GLSL, GLSLP (GLSL preset)
    # video_shader = “/opt/retropie/emulators/retroarch/shader/crt-pi.glslp”

    If you want a specific shader for an emulator: first open the retroarch.cfg file in the system you want to launch:

    Example, for nes: \\RETROPIE\configs\nes\retroarch.cfg
    add simply this line:

    # Path to shader. Shader can be either Cg, CGP (Cg preset) or GLSL, GLSLP (GLSL preset)
    # video_shader = “/opt/retropie/emulators/retroarch/shader/crt-pi.glslp”

    #122352
    nitrogenwidget
    Participant

    So i think i’ve done all this.
    but still no shader on lr-mame2003.
    should the # be removed from the begining of the line?
    And should true or false be inside quotes?
    also which config file?
    there are like 3 or 4 config files in multiple folders called retroarch.cfg which one am i editing?

    thanks.

Viewing 14 posts - 1 through 14 (of 14 total)
  • The forum ‘Video Output on RetroPie’ is closed to new topics and replies.