Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
MobiusTransformsVisualizer/js/fragshader.glsl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (28 sloc)
843 Bytes
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
vec2 invMobius(vec2 a, vec2 b, vec2 c, vec2 d, vec2 z){ | |
vec2 num = vec2(0,0); | |
num.x = (d.x*z.x - d.y*z.y)-b.x; | |
num.y = (d.x*z.y - d.y*z.x)-b.y; | |
vec2 den; | |
den.x = (c.x*z.x - c.y*z.y) + a.x; | |
den.y = -(c.x*z.y + c.y*z.x) + a.y; | |
den= den/(den.x*den.x + den.y*den.y); | |
vec2 result; | |
result.x = num.x*den.x - num.y*den.y; | |
result.y = num.x*den.y + num.y*den.x; | |
return result; | |
} | |
vec4 mainImage( vec2 fragCoord ) | |
{ | |
vec2 uv = fragCoord.xy / iResolution.xy; | |
uv = uv- vec2(0.5,0.5); | |
uv = uv*3.0; | |
vec2 a = vec2(1,1); | |
vec2 b = vec2(0,1); | |
vec2 c = vec2(0,1); | |
vec2 d = vec2(1,0); | |
vec2 transCoord = invMobius(a,b,c,d,uv); | |
fragColor = length(transCoord)>1.0?vec4(1,1,1,1):texture(iChannel0,transCoord); | |
} | |
void main(){ | |
gl_FragColor = mainImage(gl_FragCoord); | |
} |