Skip to content

Instantly share code, notes, and snippets.

@esnho
Last active September 19, 2021 20:45
Show Gist options
  • Save esnho/cda2c8cad4338b8450277a54f78bacd1 to your computer and use it in GitHub Desktop.
Save esnho/cda2c8cad4338b8450277a54f78bacd1 to your computer and use it in GitHub Desktop.
skew-in for erogenous tone structure, doesn't work!
precision mediump float;
// template : glsl.ergonenous-tones.com
varying vec2 tcoord; // location
uniform sampler2D tex; // texture one
uniform sampler2D tex2; // texture two
uniform vec2 tres; // size of texture (screen)
uniform vec4 fparams; // 4 floats coming in
uniform ivec4 iparams; // 4 ints coming in
uniform float ftime; // 0.0 to 1.0
uniform int itime; // increases when ftime hits 1.0
//f0:skew x:
//f1:skew y:
//f2:scale:
//f3:transOrigX:
//f4:transOrigY:
float skewLimit = 1.;
float transformLimit = 1.;
float scaleLimit = 5.;
float f0 = mix(-skewLimit, skewLimit, fparams[0]);
float f1 = mix(-skewLimit, skewLimit, fparams[1]);
float magicLerp = 2.34; // raise the input param at this power to start from ~1.0 when param = 0.5
float f2 = mix(.0, scaleLimit, pow(fparams[2], magicLerp));
// float f3 = mix(-transformLimit, transformLimit, fparams[3]);
// float f4 = mix(-transformLimit, transformLimit, fparams[3]);
float time = float(itime) + ftime;
vec2 resolution = tres;
// How much we want to skew each axis by
float xSkew = f0;
float ySkew = f1;
// Create a transform that will skew our texture coords
mat3 trans = mat3(
1.0, tan(xSkew), 0.0,
tan(ySkew), 1.0, 0.0,
0.0, 0.0, 1.0
);
void main(void) {
// the two vec2 can be parametrised to adjust transform origin
vec2 texCoord = (trans * (vec3((tcoord.xy - vec2(.5, .5)) * f2, 0.0))).xy + vec2(.5, .5);
// How much we want to skew each axis by
float xSkew = f0;
float ySkew = f1;
// Create a transform that will skew our texture coords
mat3 trans = mat3(
1.0, tan(xSkew), 0.0,
tan(ySkew), 1.0, 0.0,
0.0, 0.0, 1.0
);
vec4 textOut = texture2D(tex, texCoord);
gl_FragColor = vec4(textOut);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment