Back to shaders

Shader test bench

Directionalwarp

gl-transitions transition glsl runnable transition MIT
Source
runnable transition

GLSL transition function. Stronghold supplies two demo textures and progress/time uniforms.

Code

// Author: pschroen
// License: MIT

uniform float smoothness; // = 0.1
uniform vec2 direction; // = vec2(-1.0, 1.0)

const vec2 center = vec2(0.5, 0.5);

vec4 transition (vec2 uv) {
  vec2 v = normalize(direction);
  v /= abs(v.x) + abs(v.y);
  float d = v.x * center.x + v.y * center.y;
  float m = 1.0 - smoothstep(-smoothness, 0.0, v.x * uv.x + v.y * uv.y - (d - 0.5 + progress * (1.0 + smoothness)));
  return mix(getFromColor((uv - 0.5) * (1.0 - m) + 0.5), getToColor((uv - 0.5) * m + 0.5), m);
}