Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define SCALE 3.0
- #if defined(VERTEX)
- #if __VERSION__ >= 130
- #define COMPAT_VARYING out
- #define COMPAT_ATTRIBUTE in
- #define COMPAT_TEXTURE texture
- #else
- #define COMPAT_VARYING varying
- #define COMPAT_ATTRIBUTE attribute
- #define COMPAT_TEXTURE texture2D
- #endif
- #ifdef GL_ES
- #define COMPAT_PRECISION mediump
- #else
- #define COMPAT_PRECISION
- #endif
- COMPAT_ATTRIBUTE vec4 VertexCoord;
- COMPAT_ATTRIBUTE vec4 COLOR;
- COMPAT_ATTRIBUTE vec4 TexCoord;
- COMPAT_VARYING vec4 COL0;
- COMPAT_VARYING vec4 TEX0;
- uniform mat4 MVPMatrix;
- uniform COMPAT_PRECISION int FrameDirection;
- uniform COMPAT_PRECISION int FrameCount;
- uniform COMPAT_PRECISION vec2 OutputSize;
- uniform COMPAT_PRECISION vec2 TextureSize;
- uniform COMPAT_PRECISION vec2 InputSize;
- // vertex compatibility #defines
- #define vTexCoord TEX0.xy
- #define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
- #define outsize vec4(OutputSize, 1.0 / OutputSize)
- void main()
- {
- gl_Position = MVPMatrix * VertexCoord;
- COL0 = COLOR;
- TEX0.xy = TexCoord.xy;
- }
- #elif defined(FRAGMENT)
- #if __VERSION__ >= 130
- #define COMPAT_VARYING in
- #define COMPAT_TEXTURE texture
- out vec4 FragColor;
- #else
- #define COMPAT_VARYING varying
- #define FragColor gl_FragColor
- #define COMPAT_TEXTURE texture2D
- #endif
- #ifdef GL_ES
- #ifdef GL_FRAGMENT_PRECISION_HIGH
- precision highp float;
- #else
- precision mediump float;
- #endif
- #define COMPAT_PRECISION mediump
- #else
- #define COMPAT_PRECISION
- #endif
- uniform COMPAT_PRECISION int FrameDirection;
- uniform COMPAT_PRECISION int FrameCount;
- uniform COMPAT_PRECISION vec2 OutputSize;
- uniform COMPAT_PRECISION vec2 TextureSize;
- uniform COMPAT_PRECISION vec2 InputSize;
- uniform sampler2D Texture;
- COMPAT_VARYING vec4 TEX0;
- // fragment compatibility #defines
- #define Source Texture
- #define vTexCoord TEX0.xy
- #define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
- #define outsize vec4(OutputSize, 1.0 / OutputSize)
- void main()
- {
- float isMainScreen = 1.0 - max(sign(vTexCoord.x * TextureSize.x - 256.0 * SCALE), 0.0);
- float scale = 1.0 + (isMainScreen * (SCALE - 1.0));
- vec2 fakeTextureSize = TextureSize / scale;
- vec2 texelSize = 1.0 / fakeTextureSize;
- float top = texelSize.y * 0.5;
- float bottom = 1.0 - texelSize.y * 0.5;
- float left = (texelSize.x * 0.5) * isMainScreen
- + ((256.0 * scale / TextureSize.x) + texelSize.x * 0.5) * (1.0 - isMainScreen);
- float right = ((256.0 * scale / TextureSize.x) - texelSize.x * 0.5) * isMainScreen
- + (1.0 - texelSize.x * 0.5) * (1.0 - isMainScreen);
- vec2 tl = vec2(vTexCoord - texelSize * 0.5);
- tl = clamp(tl, vec2(left, top), vec2(right, bottom));
- vec4 coltl = COMPAT_TEXTURE(Source, tl);
- vec2 tr = vTexCoord + vec2(texelSize.x * 0.5, texelSize.y * -0.5);
- tr = clamp(tr, vec2(left, top), vec2(right, bottom));
- vec4 coltr = COMPAT_TEXTURE(Source, tr);
- vec2 bl = vTexCoord + vec2(texelSize.x * -0.5, texelSize.y * 0.5);
- bl = clamp(bl, vec2(left, top), vec2(right, bottom));
- vec4 colbl = COMPAT_TEXTURE(Source, bl);
- vec2 br = vTexCoord + texelSize * 0.5;
- br = clamp(br, vec2(left, top), vec2(right, bottom));
- vec4 colbr = COMPAT_TEXTURE(Source, br);
- vec2 f = fract((vTexCoord - texelSize * 0.5) * fakeTextureSize);
- vec4 tA = mix(coltl, coltr, f.x);
- vec4 tB = mix(colbl, colbr, f.x);
- FragColor = mix(tA, tB, f.y);
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement