├── README.md └── rgb_split_shader.rpy /README.md: -------------------------------------------------------------------------------- 1 | # RGB-Split 2 | ![screenshot0001](https://user-images.githubusercontent.com/23055740/128658333-8ad6c0a4-50ed-49fe-a05c-af4c43ccce4a.png) 3 | 4 | Custom Ren'Py RGB Split shader that has the same effect as chromatic aberration or anaglyph images. 5 | It shifts the red and blue channels each one in different directions and rotates them around the green channel. 6 | 7 | Video: https://vk.com/video-201215195_456239021 8 | 9 | # Instruction: 10 | Minimum Ren'Py version - 7.4.0 11 | 12 | * Drop rgb_split_shader.rpy inside your project. 13 | * Add "config.gl2 = True" line to enable shaders in your game. 14 | * Create transform with "rgb_split" shader and set values to u_intensity and u_angle. 15 | * Apply created transform to your image. 16 | 17 | # Usage Example: 18 | 19 | ![2021-08-09_085415](https://user-images.githubusercontent.com/23055740/128658974-97f348dd-5560-4b49-89eb-70e6a7d6a519.png) 20 | 21 | u_intensity - distance between channels, in pixels 22 | 23 | u_angle - rotation degrees. 24 | -------------------------------------------------------------------------------- /rgb_split_shader.rpy: -------------------------------------------------------------------------------- 1 | python early hide: 2 | 3 | ############################################################################ 4 | ## RGB Split 5 | 6 | """ 7 | 'rgb_split' - shader name. 8 | 'u_intensity' - channels separation length. 9 | 'u_angle' - angle degrees. 10 | """ 11 | 12 | renpy.register_shader( 13 | "rgb_split", 14 | variables=""" 15 | uniform float u_intensity; 16 | uniform float u_angle; 17 | uniform vec2 u_model_size; 18 | uniform sampler2D tex0; 19 | attribute vec2 a_tex_coord; 20 | varying vec2 v_tex_coord; 21 | varying vec2 v_pix_size; 22 | """, 23 | vertex_300=""" 24 | v_tex_coord = a_tex_coord; 25 | v_pix_size = 1.0 / u_model_size; 26 | """, 27 | fragment_300=""" 28 | #define PI 3.14159265359 29 | 30 | float rad = u_intensity / 2.0; 31 | float fi = u_angle * PI / 180.0; 32 | 33 | vec2 angle = vec2(cos(fi), sin(fi)); 34 | 35 | vec2 pos_r = v_tex_coord + rad * v_pix_size * angle; 36 | vec2 pos_g = v_tex_coord; 37 | vec2 pos_b = v_tex_coord - rad * v_pix_size * angle; 38 | 39 | vec4 res; 40 | res.r = texture2D(tex0, pos_r).r; 41 | res.g = texture2D(tex0, pos_g).g; 42 | res.b = texture2D(tex0, pos_b).b; 43 | res.a = (texture2D(tex0, pos_r).a + texture2D(tex0, pos_g).a + texture2D(tex0, pos_b).a) / 3.0; 44 | 45 | gl_FragColor = res; 46 | """ 47 | ) 48 | 49 | init -1000: 50 | 51 | transform tr_rgb_split(time=30.0, intensity=5.0): 52 | animation 53 | shader 'rgb_split' 54 | u_intensity intensity 55 | block: 56 | linear time u_angle 360.0 57 | u_angle 0.0 58 | repeat 59 | --------------------------------------------------------------------------------