/* caligari's scanlines Copyright (C) 2011 caligari This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. (caligari gave their consent to have this shader distributed under the GPL in this message: http://board.byuu.org/viewtopic.php?p=36219#p36219 "As I said to Hyllian by PM, I'm fine with the GPL (not really a bi deal...)" ) */ // 0.5 = the spot stays inside the original pixel // 1.0 = the spot bleeds up to the center of next pixel #define PHOSPHOR_WIDTH 0.9 #define PHOSPHOR_HEIGHT 0.65 // Used to counteract the desaturation effect of weighting. #define COLOR_BOOST 1.9 // Constants used with gamma correction. #define InputGamma 2.4 #define OutputGamma 2.2 // Uncomment to only draw every third pixel, which highlights the shape // of individual (remaining) spots. //#define DEBUG // Uncomment one of these to choose a gamma correction method. // If none are uncommented, no gamma correction is done. // #define REAL_GAMMA #define FAKE_GAMMA // #define FAKER_GAMMA #ifdef REAL_GAMMA #define GAMMA_IN(color) pow(color, vec4(InputGamma)) #define GAMMA_OUT(color) pow(color, vec4(1.0 / OutputGamma)) #elif defined FAKE_GAMMA /* * Approximations: * for 1 PHOSPHOR_WIDTH, * this pixel doesn't contribute * otherwise, smoothstep gives the * weight of the contribution */ hweight = smoothstep( 1.0, 0.0, abs((posx + centers - vec3(i)) / vec3(PHOSPHOR_WIDTH)) ); color.rgb += pixel.rgb * hweight * vec3(vweight); } } } color *= vec4(COLOR_BOOST); color.a = 1.0; return clamp(GAMMA_OUT(color), 0.0, 1.0); }