├── Amiga ├── README.md ├── amiga_example_crt-kurg_v2.png ├── crt-kurg.shader └── crt-kurg_v2.shader ├── Images ├── outrun_scanlines.jpg ├── outrun_withoutscanlines.jpg ├── scan_broken.jpg └── scan_ok.jpg ├── README.md ├── kurg-ROPi-scanlines-3x.glsl ├── kurg-ROPi-scanlines-3x.glslp ├── kurg-ROPi-scanlines-3x_v2.glsl ├── kurg-ROPi-scanlines-3x_v2.glslp ├── stuff.txt ├── test1080.glsl ├── test1080.glslp ├── test720.glsl ├── test720.glslp └── test720_0.2.glsl /Amiga/README.md: -------------------------------------------------------------------------------- 1 | FS-UAE 2 | 3 | ![crt-kurg_v2.shader](https://raw.githubusercontent.com/mcgurk/RetrOrangePi_shaders/master/Amiga/amiga_example_crt-kurg_v2.png) 4 | -------------------------------------------------------------------------------- /Amiga/amiga_example_crt-kurg_v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcgurk/RetrOrangePi_shaders/b511b855d25f69d8d80e02d38c9924c946de4ea9/Amiga/amiga_example_crt-kurg_v2.png -------------------------------------------------------------------------------- /Amiga/crt-kurg.shader: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 22 | 23 | 65 | -------------------------------------------------------------------------------- /Amiga/crt-kurg_v2.shader: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 22 | 23 | 103 | -------------------------------------------------------------------------------- /Images/outrun_scanlines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcgurk/RetrOrangePi_shaders/b511b855d25f69d8d80e02d38c9924c946de4ea9/Images/outrun_scanlines.jpg -------------------------------------------------------------------------------- /Images/outrun_withoutscanlines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcgurk/RetrOrangePi_shaders/b511b855d25f69d8d80e02d38c9924c946de4ea9/Images/outrun_withoutscanlines.jpg -------------------------------------------------------------------------------- /Images/scan_broken.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcgurk/RetrOrangePi_shaders/b511b855d25f69d8d80e02d38c9924c946de4ea9/Images/scan_broken.jpg -------------------------------------------------------------------------------- /Images/scan_ok.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcgurk/RetrOrangePi_shaders/b511b855d25f69d8d80e02d38c9924c946de4ea9/Images/scan_ok.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RetrOrangePi_shaders 2 | Shaders for mimic CRT scanlines. 3 | 4 | If you prefer this 5 | 6 | 7 | 8 | over this 9 | 10 | 11 | 12 | you are in right place. 13 | 14 | Works/tested with: 15 | - neogeo 16 | - nes 17 | - pcengine 18 | - n64 19 | - msx 20 | - playstation * 21 | - megadrive * 22 | - many mame/fba games 23 | - many others 24 | 25 | \* Some games with some consoles have interlaced (double vertical resolution) display modes (e.g. Playstation Gran Turismo menus, Megadrive Sonic The Hedgehog 2 2-player mode). Interlaced modes are better without shader. 26 | 27 | ## Install 28 | 29 | - Create `shader` directory to `/home/pi/RetroPie/roms` (or \\\\RetrOrangePi\roms). 30 | - Copy `kurg-ROPi-scanlines-3x.glsl` and `kurg-ROPi-scanlines-3x.glslp` to `/home/pi/RetroPie/roms/shader` (or \\\\RetrOrangePi\roms\shader) 31 | - Edit emulator settings file `/opt/retropie/configs/neogeo/retroarch.cfg` (this example is for neogeo) (add lines before #include... -line): 32 | ``` 33 | video_scale_integer = true 34 | video_shader = "/home/pi/RetroPie/roms/shader/kurg-ROPi-scanlines-3x.glslp" 35 | video_shader_enable = true 36 | ``` 37 | 38 | Vertical size is fixed (3 times emulator image vertical resolution). 39 | 40 | Works best with 720p display mode and with emulators with vertical resolution 240 or less. If vertical resolution of image is less than 240, image is not fullscreen. 41 | 42 | ### kurg-ROPi-scanlines-3x_v2.glslp / .glsl 43 | Totally rewritten shader, which activates only when vertical resolution is between 221-241. 44 | 45 | Better than old one because now screen is centered and e.g. in PSX-emulator shader doesn't activate in interlacer "hires" modes. 46 | 47 | If you use overlay, 4:3 screen area with 224-lines is 896x672. 48 | 49 | Most common 8-bit and 16-bit emulators uses 224-line mode (with NTSC-games): NES, SNES, Megadrive 50 | 51 | 240-linemode: PSX, PC-engine 52 | 53 | Remember activate Integer Scaling from Video-settings! 54 | 55 | ### 2.5.2! 56 | RetrOrangePi 2.5.2 default is to overwrite retroarch.cfg. If you want edit retroarch.cfg by hand, turn override off: 57 | 58 | RetroPie -> Retroarch -> Settings -> Configuration -> Load override files automatically = off 59 | 60 | or 61 | 62 | `sed -i 's/auto_overrides_enable = "true"/auto_overrides_enable = "false"/g' /opt/retropie/configs/all/retroarch.cfg` 63 | 64 | 65 | ## Theory 66 | 67 | Modern televisions have panels which have fixed resolutions. If that resolution would be very large compared to emulated device, we wouldn't have any problems. But because most displays have only 2 to 4 times of emulated device vertical resolution, scanlines have to be in "sync", or otherwise we get uneven scanlines and artifacts. 68 | 69 | Because ROPi can't change refresh rate between emulators and because it works best with 60hz, I assume that 60hz is used. This is important because then it is assumed/recommended that roms are NTSC (USA/JAPAN). And then we can assume that in most emulators vertical resolution is 240 (or 224). This is good, because most common vertical resolutions in modern televisions are 720 and 1080 (not coincidence, 720 and 1080 comes from NTSC vertical resolution). 70 | 71 | If we get image with vertical resolution 224 from emulator, we cannot fill whole screen. If our screenmode is 720p, 3 times 224 are only 672, so there inevitably 48 lines are unused (black area under and/or top of image). Other option is to use 4 times 224 (=896), but then big areas are clipped from top and/or bottom. In 1080p display we could use 4 times 224 (=896), but then there is even more black area. If we use 5 times 224 (=1120), we have to chop only 40 pixels (8 scanlines from original image). 72 | 73 | If we want some simulated separation for pixels in horizontal direction, we have to lock also horizontal scaling to integer multiplication. That leads to situation, where we cannot keep aspect ratio correct, if pixels are originally something else than square. 74 | 75 | It is possible to make good quality scanline shader with scaling (normal 1080p display scales 720p image without big artifacts), but if I try more complicated shaders with OPi, it slows down too much. 76 | 77 | 78 | Example of "broken" scanlines, where image is not scaled with integer factor: 79 | 80 | 81 | 82 | 83 | Example of working scanlines, where image is scaled with integer factor (3x): 84 | 85 | 86 | 87 | ### Why scanline exists? 88 | 89 | CRT-televisions updated screen 50 or 60 times per second. In normal television broadcast every other frame only odd or even lines was drawn (this saved bandwith to half). These are called fields. Many old consoles and computers had half of television resolution. Television standard allowed to draw same lines in consecutive draw, so with many computers and consoles odd (or even) lines are newer drawn -> every other line are permanently black. This arrangement can be called 240p (normal television broadcast was 480i) (NTSC). 90 | 91 | ## experimenting 92 | 93 | test-shader tries to mimic gap between pixels in one scanline. Downside is that you cannot scale image at all and aspect ratio can be very distorted (depends aspect ratio of pixel). 94 | 95 | make "shader" directory to /home/pi/RetroPie/roms (or \\\\RetrOrangePi\roms). 96 | copy test720.glsl and test720.glslp to /home/pi/RetroPie/roms/shader (or \\\\RetrOrangePi\roms\shader) 97 | 98 | Edit emulator settings file /opt/retropie/configs/neogeo/retroarch.cfg (this example is for neogeo): 99 | ``` 100 | video_shader = "/home/pi/RetroPie/roms/shader/test720.glslp" 101 | video_shader_enable = true 102 | ``` 103 | test720 doesn't obey any aspect ratio settings! All pixels are assumed to be square. Every pixel are scaled by 3, so size of image are fixed (you can't scale it). 104 | -------------------------------------------------------------------------------- /kurg-ROPi-scanlines-3x.glsl: -------------------------------------------------------------------------------- 1 | #if defined(VERTEX) 2 | 3 | 4 | attribute vec4 VertexCoord; 5 | attribute vec4 TexCoord; 6 | varying vec4 TEX0; 7 | uniform mat4 MVPMatrix; 8 | 9 | void main() { 10 | gl_Position = VertexCoord.x*MVPMatrix[0] + VertexCoord.y*MVPMatrix[1] + VertexCoord.z*MVPMatrix[2] + VertexCoord.w*MVPMatrix[3]; 11 | TEX0.xy = TexCoord.xy; 12 | } 13 | 14 | 15 | #elif defined(FRAGMENT) 16 | 17 | 18 | precision mediump float; 19 | 20 | uniform sampler2D Texture; 21 | varying vec4 TEX0; 22 | uniform vec2 TextureSize; 23 | 24 | void main() { 25 | 26 | vec3 col; 27 | float x = TEX0.x * TextureSize.x; 28 | float y = floor(gl_FragCoord.y / 3.0) + 0.5; 29 | float ymod = mod(gl_FragCoord.y, 3.0); 30 | vec2 f0 = vec2(x, y); 31 | vec2 uv0 = f0 / TextureSize.xy; 32 | vec3 t0 = texture2D(Texture, uv0).xyz; 33 | if (ymod > 2.0) { 34 | vec2 f1 = vec2(x, y + 1.0); 35 | vec2 uv1 = f1 / TextureSize.xy; 36 | vec3 t1 = texture2D(Texture, uv1).xyz; 37 | col = (t0 + t1) / 2.0 * 0.6; 38 | } else { 39 | col = t0; 40 | } 41 | 42 | gl_FragColor = vec4( col, 1.0 ); 43 | 44 | } 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /kurg-ROPi-scanlines-3x.glslp: -------------------------------------------------------------------------------- 1 | shaders = 1 2 | shader0 = kurg-ROPi-scanlines-3x.glsl 3 | 4 | filter_linear0 = true 5 | 6 | scale_type_x0 = "viewport" 7 | scale_x0 = "1.000000" 8 | scale_type_y0 = "viewport" 9 | scale_y0 = "1.000000" 10 | -------------------------------------------------------------------------------- /kurg-ROPi-scanlines-3x_v2.glsl: -------------------------------------------------------------------------------- 1 | #if defined(VERTEX) 2 | 3 | 4 | attribute vec4 VertexCoord; 5 | attribute vec4 TexCoord; 6 | varying vec4 TEX0; 7 | uniform mat4 MVPMatrix; 8 | 9 | void main() { 10 | gl_Position = MVPMatrix * VertexCoord; 11 | TEX0.xy = TexCoord.xy; 12 | } 13 | 14 | 15 | #elif defined(FRAGMENT) 16 | 17 | 18 | precision mediump float; 19 | 20 | uniform sampler2D Texture; 21 | varying vec4 TEX0; 22 | uniform vec2 TextureSize; 23 | uniform vec2 InputSize; 24 | 25 | void main() { 26 | vec3 col; 27 | if (InputSize.y > 220.0 && InputSize.y < 242.0) { 28 | float x = TEX0.x; 29 | float y = TEX0.y + (0.25 / TextureSize.y); 30 | col = texture2D(Texture, vec2(x, y)).xyz; 31 | float texel_y = TEX0.y * TextureSize.y * 3.0; 32 | float ymod = mod(texel_y, 3.0); 33 | if (ymod >= 1.5) { 34 | col = col * 0.6; 35 | } 36 | } else { 37 | col = texture2D(Texture, TEX0.xy).xyz; 38 | } 39 | 40 | gl_FragColor = vec4( col, 1.0 ); 41 | 42 | } 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /kurg-ROPi-scanlines-3x_v2.glslp: -------------------------------------------------------------------------------- 1 | shaders = 1 2 | shader0 = kurg-ROPi-scanlines-3x_v2.glsl 3 | 4 | filter_linear0 = true 5 | 6 | scale_type_x0 = "viewport" 7 | scale_x0 = "1.000000" 8 | scale_type_y0 = "viewport" 9 | scale_y0 = "1.000000" 10 | -------------------------------------------------------------------------------- /stuff.txt: -------------------------------------------------------------------------------- 1 | Shaders: 2 | https://www.dropbox.com/s/ol6yutuy4anens4/glsl.zip?dl=0 3 | Roy Corser Sure...a link for a complete pack. Use only glsl....cg are not supported. I have a good result using "2xsal, x2, nearest" but first disable hw bilinear filtering. Have fun! 4 | (~/.config/retroarch/shaders ?) 5 | /opt/retropie/emulators/retroarch/shader 6 | Jälkimmäinen näyttäs olevan ainakin retroarchin oletushakemisto. 7 | interlaced.glsl ei näyttäny hyvältä. 8 | Ei toiminu suoraan RetroPiestä otettu crt-pi.glsl/crt-pi.glslp. 9 | https://mega.nz/#!ON501ZwT!MSxPmeSCn55G-GmYxiay0zL6NGyU6HTrUbApanJ16nY 10 | /opt/retropie/emulators/retroarch/shader 11 | RetroArch-menu: Settings->Video->Integer scale 12 | https://www.facebook.com/groups/1131759626884432/permalink/1157090121018049/ 13 | 14 | UTF-8, UNIX 15 | 16 | http://www.shaderific.com/glsl-functions/ 17 | 18 | http://www.khronos.org/files/opengl-quick-reference-card.pdf 19 | 20 | https://github.com/libretro/RetroArch/wiki/GLSL-shaders 21 | 22 | https://github.com/libretro/common-shaders/tree/master/docs 23 | - scale_typeN (string): This can be set to one of these values: 24 | "source": Output size of shader pass N is relative to the input size 25 | as found in IN.video_size. Value is float. 26 | "viewport": Output size of shader pass N is relative to the size of the 27 | window viewport. Value is float. 28 | This value can change over time if the user 29 | resizes his/her window! 30 | "absolute": Output size is statically defined to a certain size. 31 | Useful for hi-res blenders or similiar. 32 | 33 | If no scale type is assumed, it is assumed that it is set to "source" 34 | with scaleN set to 1.0. 35 | 36 | It is possible to set scale_type_xN and scale_type_yN to specialize 37 | the scaling type in either direction. scale_typeN however 38 | overrides both of these. 39 | 40 | IN.video_size: The size of the actual video data in the texture, 41 | e.g for a SNES this will be generally 42 | (256, 224) for normal resolution frames. 43 | 44 | IN.texture_size: This is the size of the texture itself. 45 | Optimally power-of-two sized. 46 | 47 | IN.output_size: The size of the video output. 48 | This is the size of the viewport shown on screen. 49 | 50 | 51 | uniform COMPAT_PRECISION vec2 OutputSize; 52 | uniform COMPAT_PRECISION vec2 TextureSize; 53 | uniform COMPAT_PRECISION vec2 InputSize; 54 | 55 | scale_type_x0 = "viewport" 56 | scale_x0 = "1.000000" 57 | scale_type_y0 = "viewport" 58 | scale_y0 = "1.000000" 59 | 60 | scale_type_x0 = "source" 61 | scale_x0 = "1.000000" 62 | scale_type_y0 = "source" 63 | scale_y0 = "3.000000" 64 | 65 | //viewport 66 | vec4 _res; 67 | _res = COMPAT_TEXTURE(Texture, TEX0.xy); 68 | _TMP1 = TEX0.y*TextureSize.y; 69 | _TMP1 = gl_FragCoord.y; 70 | _TMP1 = mod(_TMP1-1.5, 3.0) / 3.0; 71 | FragColor = _res - (_TMP1*0.5); 72 | 73 | //source 74 | vec4 _res; 75 | _res = COMPAT_TEXTURE(Texture, TEX0.xy); 76 | _TMP1 = TEX0.y*TextureSize.y; 77 | _TMP2 = fract(_TMP1); 78 | if (_TMP2 < 0.5) { 79 | FragColor = _res; 80 | } else { 81 | FragColor = _res * 0.5; 82 | } 83 | -------------------------------------------------------------------------------- /test1080.glsl: -------------------------------------------------------------------------------- 1 | #if defined(VERTEX) 2 | 3 | #if __VERSION__ >= 130 4 | #define COMPAT_VARYING out 5 | #define COMPAT_ATTRIBUTE in 6 | #define COMPAT_TEXTURE texture 7 | #else 8 | #define COMPAT_VARYING varying 9 | #define COMPAT_ATTRIBUTE attribute 10 | #define COMPAT_TEXTURE texture2D 11 | #endif 12 | 13 | #ifdef GL_ES 14 | #define COMPAT_PRECISION mediump 15 | #else 16 | #define COMPAT_PRECISION 17 | #endif 18 | COMPAT_VARYING float _frame_rotation; 19 | 20 | struct input_dummy { 21 | vec2 _video_size; 22 | vec2 _texture_size; 23 | vec2 _output_dummy_size; 24 | float _frame_count; 25 | float _frame_direction; 26 | float _frame_rotation; 27 | }; 28 | 29 | COMPAT_ATTRIBUTE vec4 VertexCoord; 30 | COMPAT_ATTRIBUTE vec4 COLOR; 31 | COMPAT_VARYING vec4 COL0; 32 | COMPAT_ATTRIBUTE vec4 TexCoord; 33 | COMPAT_VARYING vec4 TEX0; 34 | 35 | uniform mat4 MVPMatrix; 36 | uniform int FrameDirection; 37 | uniform int FrameCount; 38 | uniform COMPAT_PRECISION vec2 OutputSize; 39 | uniform COMPAT_PRECISION vec2 TextureSize; 40 | uniform COMPAT_PRECISION vec2 InputSize; 41 | 42 | void main() { 43 | gl_Position = VertexCoord.x*MVPMatrix[0] + VertexCoord.y*MVPMatrix[1] + VertexCoord.z*MVPMatrix[2] + VertexCoord.w*MVPMatrix[3]; 44 | TEX0.xy = TexCoord.xy; 45 | } 46 | 47 | #elif defined(FRAGMENT) 48 | 49 | #if __VERSION__ >= 130 50 | #define COMPAT_VARYING in 51 | #define COMPAT_TEXTURE texture 52 | out vec4 FragColor; 53 | #else 54 | #define COMPAT_VARYING varying 55 | #define FragColor gl_FragColor 56 | #define COMPAT_TEXTURE texture2D 57 | #endif 58 | 59 | #ifdef GL_ES 60 | #ifdef GL_FRAGMENT_PRECISION_HIGH 61 | precision highp float; 62 | #else 63 | precision mediump float; 64 | #endif 65 | #define COMPAT_PRECISION mediump 66 | #else 67 | #define COMPAT_PRECISION 68 | #endif 69 | COMPAT_VARYING float _frame_rotation; 70 | 71 | struct input_dummy { 72 | vec2 _video_size; 73 | vec2 _texture_size; 74 | vec2 _output_dummy_size; 75 | float _frame_count; 76 | float _frame_direction; 77 | float _frame_rotation; 78 | }; 79 | 80 | float _TMP2; 81 | float _TMP1; 82 | uniform sampler2D Texture; 83 | input_dummy _IN1; 84 | COMPAT_VARYING vec4 TEX0; 85 | 86 | uniform int FrameDirection; 87 | uniform int FrameCount; 88 | uniform COMPAT_PRECISION vec2 OutputSize; 89 | uniform COMPAT_PRECISION vec2 TextureSize; 90 | uniform COMPAT_PRECISION vec2 InputSize; 91 | 92 | 93 | void main() { 94 | 95 | vec3 col; 96 | float x = floor(gl_FragCoord.x / 4.0) - 0.5; 97 | float y = floor(gl_FragCoord.y / 4.0) - 0.5; 98 | float xmod = mod(gl_FragCoord.x, 4.0); 99 | float ymod = mod(gl_FragCoord.y, 4.0); 100 | vec2 f0 = vec2(x, y); 101 | vec2 f1 = vec2(x, y + 1.0); 102 | vec2 uv0 = f0 / TextureSize.xy; 103 | vec2 uv1 = f1 / TextureSize.xy; 104 | vec3 t0 = COMPAT_TEXTURE(Texture, uv0).xyz; 105 | vec3 t1 = COMPAT_TEXTURE(Texture, uv1).xyz; 106 | //vec3 t2 = COMPAT_TEXTURE(Texture, vec2(x+1.0,y)/TextureSize.xy).xyz; 107 | float p = 1.0; 108 | if (xmod < 1.0) p = 0.9; 109 | if (ymod < 1.0) col = t0 * 0.8; else 110 | if (ymod < 2.0) col = t0; else 111 | if (ymod < 3.0) col = t0 * 0.8; else 112 | col = (t0 + t1) / 2.0 * 0.6; 113 | FragColor = vec4( col * p, 1.0 ); 114 | //FragColor = vec4( col * t2, 1.0 ); 115 | 116 | } 117 | 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /test1080.glslp: -------------------------------------------------------------------------------- 1 | shaders = 1 2 | shader0 = test1080.glsl 3 | 4 | filter_linear0 = false 5 | #filter_linear0 = true 6 | 7 | scale_type_x0 = "viewport" 8 | scale_x0 = "1.000000" 9 | scale_type_y0 = "viewport" 10 | scale_y0 = "1.000000" 11 | -------------------------------------------------------------------------------- /test720.glsl: -------------------------------------------------------------------------------- 1 | #if defined(VERTEX) 2 | 3 | #if __VERSION__ >= 130 4 | #define COMPAT_VARYING out 5 | #define COMPAT_ATTRIBUTE in 6 | #define COMPAT_TEXTURE texture 7 | #else 8 | #define COMPAT_VARYING varying 9 | #define COMPAT_ATTRIBUTE attribute 10 | #define COMPAT_TEXTURE texture2D 11 | #endif 12 | 13 | #ifdef GL_ES 14 | #define COMPAT_PRECISION mediump 15 | #else 16 | #define COMPAT_PRECISION 17 | #endif 18 | COMPAT_VARYING float _frame_rotation; 19 | 20 | struct input_dummy { 21 | vec2 _video_size; 22 | vec2 _texture_size; 23 | vec2 _output_dummy_size; 24 | float _frame_count; 25 | float _frame_direction; 26 | float _frame_rotation; 27 | }; 28 | 29 | COMPAT_ATTRIBUTE vec4 VertexCoord; 30 | COMPAT_ATTRIBUTE vec4 COLOR; 31 | COMPAT_VARYING vec4 COL0; 32 | COMPAT_ATTRIBUTE vec4 TexCoord; 33 | COMPAT_VARYING vec4 TEX0; 34 | 35 | uniform mat4 MVPMatrix; 36 | uniform int FrameDirection; 37 | uniform int FrameCount; 38 | uniform COMPAT_PRECISION vec2 OutputSize; 39 | uniform COMPAT_PRECISION vec2 TextureSize; 40 | uniform COMPAT_PRECISION vec2 InputSize; 41 | 42 | void main() { 43 | gl_Position = VertexCoord.x*MVPMatrix[0] + VertexCoord.y*MVPMatrix[1] + VertexCoord.z*MVPMatrix[2] + VertexCoord.w*MVPMatrix[3]; 44 | TEX0.xy = TexCoord.xy; 45 | } 46 | 47 | #elif defined(FRAGMENT) 48 | 49 | #if __VERSION__ >= 130 50 | #define COMPAT_VARYING in 51 | #define COMPAT_TEXTURE texture 52 | out vec4 FragColor; 53 | #else 54 | #define COMPAT_VARYING varying 55 | #define FragColor gl_FragColor 56 | #define COMPAT_TEXTURE texture2D 57 | #endif 58 | 59 | #ifdef GL_ES 60 | #ifdef GL_FRAGMENT_PRECISION_HIGH 61 | precision highp float; 62 | #else 63 | precision mediump float; 64 | #endif 65 | #define COMPAT_PRECISION mediump 66 | #else 67 | #define COMPAT_PRECISION 68 | #endif 69 | COMPAT_VARYING float _frame_rotation; 70 | 71 | struct input_dummy { 72 | vec2 _video_size; 73 | vec2 _texture_size; 74 | vec2 _output_dummy_size; 75 | float _frame_count; 76 | float _frame_direction; 77 | float _frame_rotation; 78 | }; 79 | 80 | float _TMP2; 81 | float _TMP1; 82 | uniform sampler2D Texture; 83 | input_dummy _IN1; 84 | COMPAT_VARYING vec4 TEX0; 85 | 86 | uniform int FrameDirection; 87 | uniform int FrameCount; 88 | uniform COMPAT_PRECISION vec2 OutputSize; 89 | uniform COMPAT_PRECISION vec2 TextureSize; 90 | uniform COMPAT_PRECISION vec2 InputSize; 91 | 92 | 93 | void main() { 94 | 95 | vec3 col; 96 | float x = floor(gl_FragCoord.x / 3.0) + 0.5; 97 | float y = floor(gl_FragCoord.y / 3.0) + 0.5; 98 | float xmod = mod(gl_FragCoord.x, 3.0); 99 | float ymod = mod(gl_FragCoord.y, 3.0); 100 | vec2 f0 = vec2(x, y); 101 | vec2 uv0 = f0 / TextureSize.xy; 102 | float p = 1.0; 103 | vec3 t0 = COMPAT_TEXTURE(Texture, uv0).xyz; 104 | if (ymod > 2.0) { 105 | vec2 f1 = vec2(x, y + 1.0); 106 | vec2 uv1 = f1 / TextureSize.xy; 107 | vec3 t1 = COMPAT_TEXTURE(Texture, uv1).xyz; 108 | if (xmod > 2.0) p = 0.8; 109 | col = (t0 + t1) / 2.0 * 0.6 * p; 110 | } else { 111 | if (xmod > 2.0) { 112 | vec2 f1 = vec2(x + 1.0, y); 113 | vec2 uv1 = f1 / TextureSize.xy; 114 | vec3 t1 = COMPAT_TEXTURE(Texture, uv1).xyz; 115 | col = (t0 + t1) / 2.0 * 1.0;//0.95; 116 | } else col = t0; 117 | } 118 | FragColor = vec4( col, 1.0 ); 119 | 120 | } 121 | 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /test720.glslp: -------------------------------------------------------------------------------- 1 | shaders = 1 2 | #shader0 = /home/pi/RetroPie/roms/kurg_scanlines_source.glsl 3 | shader0 = test720.glsl 4 | 5 | filter_linear0 = false 6 | #filter_linear0 = true 7 | 8 | scale_type_x0 = "viewport" 9 | scale_x0 = "1.000000" 10 | scale_type_y0 = "viewport" 11 | scale_y0 = "1.000000" 12 | -------------------------------------------------------------------------------- /test720_0.2.glsl: -------------------------------------------------------------------------------- 1 | #if defined(VERTEX) 2 | 3 | #if __VERSION__ >= 130 4 | #define COMPAT_VARYING out 5 | #define COMPAT_ATTRIBUTE in 6 | #define COMPAT_TEXTURE texture 7 | #else 8 | #define COMPAT_VARYING varying 9 | #define COMPAT_ATTRIBUTE attribute 10 | #define COMPAT_TEXTURE texture2D 11 | #endif 12 | 13 | #ifdef GL_ES 14 | #define COMPAT_PRECISION mediump 15 | #else 16 | #define COMPAT_PRECISION 17 | #endif 18 | COMPAT_VARYING float _frame_rotation; 19 | 20 | struct input_dummy { 21 | vec2 _video_size; 22 | vec2 _texture_size; 23 | vec2 _output_dummy_size; 24 | float _frame_count; 25 | float _frame_direction; 26 | float _frame_rotation; 27 | }; 28 | 29 | COMPAT_ATTRIBUTE vec4 VertexCoord; 30 | COMPAT_ATTRIBUTE vec4 COLOR; 31 | COMPAT_VARYING vec4 COL0; 32 | COMPAT_ATTRIBUTE vec4 TexCoord; 33 | COMPAT_VARYING vec4 TEX0; 34 | 35 | uniform mat4 MVPMatrix; 36 | uniform int FrameDirection; 37 | uniform int FrameCount; 38 | uniform COMPAT_PRECISION vec2 OutputSize; 39 | uniform COMPAT_PRECISION vec2 TextureSize; 40 | uniform COMPAT_PRECISION vec2 InputSize; 41 | 42 | void main() { 43 | gl_Position = VertexCoord.x*MVPMatrix[0] + VertexCoord.y*MVPMatrix[1] + VertexCoord.z*MVPMatrix[2] + VertexCoord.w*MVPMatrix[3]; 44 | TEX0.xy = TexCoord.xy; 45 | } 46 | 47 | #elif defined(FRAGMENT) 48 | 49 | #if __VERSION__ >= 130 50 | #define COMPAT_VARYING in 51 | #define COMPAT_TEXTURE texture 52 | out vec4 FragColor; 53 | #else 54 | #define COMPAT_VARYING varying 55 | #define FragColor gl_FragColor 56 | #define COMPAT_TEXTURE texture2D 57 | #endif 58 | 59 | #ifdef GL_ES 60 | #ifdef GL_FRAGMENT_PRECISION_HIGH 61 | precision highp float; 62 | #else 63 | precision mediump float; 64 | #endif 65 | #define COMPAT_PRECISION mediump 66 | #else 67 | #define COMPAT_PRECISION 68 | #endif 69 | COMPAT_VARYING float _frame_rotation; 70 | 71 | struct input_dummy { 72 | vec2 _video_size; 73 | vec2 _texture_size; 74 | vec2 _output_dummy_size; 75 | float _frame_count; 76 | float _frame_direction; 77 | float _frame_rotation; 78 | }; 79 | 80 | float _TMP2; 81 | float _TMP1; 82 | uniform sampler2D Texture; 83 | input_dummy _IN1; 84 | COMPAT_VARYING vec4 TEX0; 85 | 86 | uniform int FrameDirection; 87 | uniform int FrameCount; 88 | uniform COMPAT_PRECISION vec2 OutputSize; 89 | uniform COMPAT_PRECISION vec2 TextureSize; 90 | uniform COMPAT_PRECISION vec2 InputSize; 91 | 92 | 93 | void main() { 94 | 95 | vec3 col; 96 | float x = TEX0.x * TextureSize.x; 97 | //float x = floor(gl_FragCoord.x / 3.0) + 0.5; 98 | float y = floor(gl_FragCoord.y / 3.0) + 0.5; 99 | //float xmod = mod(gl_FragCoord.x, 3.0); 100 | float ymod = mod(gl_FragCoord.y, 3.0); 101 | vec2 f0 = vec2(x, y); 102 | vec2 uv0 = f0 / TextureSize.xy; 103 | //vec2 uv0 = vec2(TEX0.x, f0.y / TextureSize.y); 104 | float p = 1.0; 105 | vec3 t0 = COMPAT_TEXTURE(Texture, uv0).xyz; 106 | if (ymod > 2.0) { 107 | vec2 f1 = vec2(x, y + 1.0); 108 | vec2 uv1 = f1 / TextureSize.xy; 109 | vec3 t1 = COMPAT_TEXTURE(Texture, uv1).xyz; 110 | //if (xmod > 2.0) p = 0.8; 111 | col = (t0 + t1) / 2.0 * 0.6 * p; 112 | } else { 113 | /*if (xmod > 2.0) { 114 | vec2 f1 = vec2(x + 1.0, y); 115 | vec2 uv1 = f1 / TextureSize.xy; 116 | vec3 t1 = COMPAT_TEXTURE(Texture, uv1).xyz; 117 | col = (t0 + t1) / 2.0 * 1.0;//0.95; 118 | } else*/ col = t0; 119 | } 120 | FragColor = vec4( col, 1.0 ); 121 | 122 | } 123 | 124 | 125 | #endif 126 | --------------------------------------------------------------------------------