Back to shaders
Shader test bench
Wipe Left.fs
runnable fragment
Complete GLSL fragment shader. Stronghold runs it directly when the browser can compile it.
Code
uniform sampler2D startImage;
uniform sampler2D endImage;
uniform float progress;
precision mediump float;
/*
{
"INPUTS" : [
{
"TYPE" : "image",
"NAME" : "startImage"
},
{
"TYPE" : "image",
"NAME" : "endImage"
},
{
"TYPE" : "float",
"MAX" : 1,
"NAME" : "progress",
"MIN" : 0,
"DEFAULT" : 0
}
],
"CATEGORIES" : [
"Wipe"
],
"CREDIT": "Automatically converted from https://www.github.com/gl-transitions/gl-transitions/tree/master/wipeLeft.glsl",
"DESCRIPTION": "",
"ISFVSN" : "2"
}
*/
vec4 getFromColor(vec2 inUV) {
return texture2D(startImage, inUV);
}
vec4 getToColor(vec2 inUV) {
return texture2D(endImage, inUV);
}
// Author: Jake Nelson
// License: MIT
vec4 transition(vec2 uv) {
vec2 p=uv.xy/vec2(1.0).xy;
vec4 a=getFromColor(p);
vec4 b=getToColor(p);
return mix(a, b, step(1.0-p.x,progress));
}
void main() {
gl_FragColor = transition((gl_FragCoord.xy / u_resolution.xy).xy);
}