Skip to content

Instantly share code, notes, and snippets.

@spite
Created November 22, 2021 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spite/055a20748ef8a86bc23933d5550b2087 to your computer and use it in GitHub Desktop.
Save spite/055a20748ef8a86bc23933d5550b2087 to your computer and use it in GitHub Desktop.
#if GL_FRAGMENT_PRECISION_HIGH == 1
precision highp int;
precision highp float;
#endif
uniform sampler2D uSampler;
uniform float time;
uniform float baseRotation1;
uniform float rotationSpeed1;
uniform float baseRotation2;
uniform float rotationSpeed2;
uniform float sliceAngle;
uniform float mirrorSlices;
uniform vec2 zoom;
uniform vec2 resolution;
uniform vec2 aspect;
uniform vec2 center;
uniform vec2 mouseOffset;
uniform bool pinch;
void main( void ) {
vec2 position = -aspect.xy + 2.0 * gl_FragCoord.xy / resolution.xy * aspect.xy;
float radius = length(position);
float angle = atan(position.y,position.x)+baseRotation1;
float slice = mod((angle+time*rotationSpeed1), (sliceAngle*2.0));
if (mirrorSlices * slice>sliceAngle)
{
slice = (2.0*sliceAngle-slice);
}
if(pinch)
{
float rot2 = baseRotation2 + time*rotationSpeed2;
rot2 = atan(position.y,position.x)+baseRotation2 + time*rotationSpeed2;
gl_FragColor = texture2D(uSampler, ( center + length( center ) * vec2( cos(rot2), sin(rot2)) + mouseOffset + vec2( cos(slice), sin(slice)) * radius) * zoom );
} else {
float rot2 = baseRotation2 + time*rotationSpeed2;
vec2 rot = vec2(sin(rot2),cos(rot2));
vec2 pos = vec2( cos(slice), sin(slice)) * radius + center ;
gl_FragColor = texture2D(uSampler, (vec2(pos.x * rot.y + pos.y * rot.x,pos.y * rot.y - pos.x * rot.x)) * zoom + mouseOffset, -1.0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment