1// Parameter lines go here: 2#pragma parameter SCANTHICK "Scanline Thickness" 2.0 2.0 4.0 2.0 3#pragma parameter INTENSITY "Scanline Intensity" 0.15 0.0 1.0 0.01 4#pragma parameter BRIGHTBOOST "Luminance Boost" 0.15 0.0 1.0 0.01 5 6#if defined(VERTEX) 7 8#if __VERSION__ >= 130 9#define COMPAT_VARYING out 10#define COMPAT_ATTRIBUTE in 11#define COMPAT_TEXTURE texture 12#else 13#define COMPAT_VARYING varying 14#define COMPAT_ATTRIBUTE attribute 15#define COMPAT_TEXTURE texture2D 16#endif 17 18#ifdef GL_ES 19#define COMPAT_PRECISION mediump 20#else 21#define COMPAT_PRECISION 22#endif 23 24COMPAT_ATTRIBUTE vec4 VertexCoord; 25COMPAT_ATTRIBUTE vec4 COLOR; 26COMPAT_ATTRIBUTE vec4 TexCoord; 27COMPAT_VARYING vec4 COL0; 28COMPAT_VARYING vec4 TEX0; 29 30vec4 _oPosition1; 31uniform mat4 MVPMatrix; 32uniform COMPAT_PRECISION int FrameDirection; 33uniform COMPAT_PRECISION int FrameCount; 34uniform COMPAT_PRECISION vec2 OutputSize; 35uniform COMPAT_PRECISION vec2 TextureSize; 36uniform COMPAT_PRECISION vec2 InputSize; 37 38void main() 39{ 40 gl_Position = MVPMatrix * VertexCoord; 41 COL0 = COLOR; 42 TEX0.xy = TexCoord.xy * 1.00001; 43} 44 45#elif defined(FRAGMENT) 46 47#if __VERSION__ >= 130 48#define COMPAT_VARYING in 49#define COMPAT_TEXTURE texture 50out vec4 FragColor; 51#else 52#define COMPAT_VARYING varying 53#define FragColor gl_FragColor 54#define COMPAT_TEXTURE texture2D 55#endif 56 57#ifdef GL_ES 58#ifdef GL_FRAGMENT_PRECISION_HIGH 59precision highp float; 60#else 61precision mediump float; 62#endif 63#define COMPAT_PRECISION mediump 64#else 65#define COMPAT_PRECISION 66#endif 67 68uniform COMPAT_PRECISION int FrameDirection; 69uniform COMPAT_PRECISION int FrameCount; 70uniform COMPAT_PRECISION vec2 OutputSize; 71uniform COMPAT_PRECISION vec2 TextureSize; 72uniform COMPAT_PRECISION vec2 InputSize; 73uniform sampler2D Texture; 74COMPAT_VARYING vec4 TEX0; 75 76// compatibility #defines 77#define Source Texture 78#define vTexCoord TEX0.xy 79 80#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize 81#define OutputSize vec4(OutputSize, 1.0 / OutputSize) 82 83#ifdef PARAMETER_UNIFORM 84// All parameter floats need to have COMPAT_PRECISION in front of them 85uniform COMPAT_PRECISION float SCANTHICK; 86uniform COMPAT_PRECISION float INTENSITY; 87uniform COMPAT_PRECISION float BRIGHTBOOST; 88#else 89#define SCANTHICK 2.0 90#define INTENSITY 0.15 91#define BRIGHTBOOST 0.15 92#endif 93 94void main() 95{ 96 vec3 texel = COMPAT_TEXTURE(Texture, TEX0.xy).rgb; 97 vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * texel)) * texel; 98 vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * texel)) * texel; 99 float selectY = mod(TEX0.y * SCANTHICK * TextureSize.y, 2.0); 100 float selectHigh = step(1.0, selectY); 101 float selectLow = 1.0 - selectHigh; 102 vec3 pixelColor = (selectLow * pixelLow) + (selectHigh * pixelHigh); 103 104 FragColor = vec4(pixelColor, 1.0); 105} 106#endif 107