I've recently been toying around with Shaders and I found out that, unless I use a sf::RenderTexture, the displayed result is always Y-Inverted.
// General parameters
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform float time;
uniform vec2 resolution;
const vec2 center = vec2(0.5, 0.5);
float quadraticInOut(float t) {
float p = 2.0 * t * t;
return t < 0.5 ? p : -p + (4.0 * t) - 1.0;
}
float rand(vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
if (time == 0.0) {
gl_FragColor = texture2D(tex0, p);
} else if (time == 1.0) {
gl_FragColor = texture2D(tex1, p);
} else {
float x = time;
float dist = distance(center, p);
float r = x - min(rand(vec2(p.y, 0.0)), rand(vec2(0.0, p.x)));
float m = dist <= r ? 1.0 : 0.0;
gl_FragColor = mix(texture2D(tex0, p), texture2D(tex1, p), m);
}
}
A simple shader like this one, only a fragment shader might I add, is always upside down.
Is there something I'm missing?
I'm quite new to shaders so keep that in mind.