This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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