Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbh12001 committed Nov 28, 2017
1 parent 4011ffe commit 08da6f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion js/mobius.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function add_2d_ctrl(parent,variable,label,min_x,max_x,min_y,max_y) {
//update value based on location, rounded to thrid decimal
drag: function(event, ui){//When it's dragged, call this function

variable.setVals(remap(ui.position.left,0,80,min_x,max_x),remap(ui.position.top,0,80,min_y,max_y));
variable.setVals(remap(ui.position.left,0,80,min_x,max_x),remap(ui.position.top,80,0,min_y,max_y));

$(container).data('complex',variable)
imNum.nodeValue = 'im: ' +variable['im'].toFixed(3)
Expand Down
46 changes: 36 additions & 10 deletions mobius.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


vec2 invMobius(vec2 _a, vec2 _b, vec2 _c, vec2 _d, vec2 z){
vec2 num = vec2(0,0);
vec2 num;
num.x = (_d.x*z.x - _d.y*z.y)-_b.x;
num.y = (_d.x*z.y - _d.y*z.x)-_b.y;

Expand All @@ -56,34 +56,60 @@
return result;
}

vec2 fwdMobius(vec2 _a, vec2 _b, vec2 _c, vec2 _d, vec2 z){
vec2 num;
num.x = (_a.x*z.x - _a.y*z.y)+_b.x;
num.y = (_a.x*z.y - _a.y*z.x)+_b.y;

vec2 den;
den.x = (z.x*z.x - _c.y*z.y) + _d.x;
den.y = (_c.x*z.y + _c.y*z.x) + _d.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;

}

vec3 hsb2rgb( in vec3 c ){
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),
6.0)-3.0)-1.0,
0.0,
1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb);
return c.z * mix( vec3(1.0), rgb, c.y);
}

vec4 mainImage( vec2 fragCoord )
{
vec2 uv = fragCoord.xy / vec2(500,500);
uv = uv- vec2(0.5,0.5);
uv = uv*3.0;
uv = uv*vec2(3.0,-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);

return max(abs(transCoord.x),abs(transCoord.y))>1.0?vec4(1,1,1,1):texture2D(sampler,transCoord);
// return (abs(mod(transCoord.x*10.0,1.0))>0.9 ||
// abs(mod(transCoord.y*10.0,1.0))>0.9) && max(abs(transCoord.x),abs(transCoord.y))<5.0
// ?vec4(0,0,0,1):vec4(1,1,1,1);
return max(abs(transCoord.x),abs(transCoord.y))>1.0?vec4(1,1,1,1):texture2D(sampler,transCoord.yx);
/*return (abs(mod(transCoord.x*10.0,1.0))>0.93 ||
abs(mod(transCoord.y*10.0,1.0))>0.93) && max(abs(transCoord.x),abs(transCoord.y))<5.0
?vec4(0,0,0,1):vec4(hsb2rgb(vec3(transCoord.x+transCoord.y,1,1)),1);*/
// return vec4(transCoord.x,transCoord.y,c.x,1);
}



void main(){
vec4 outcolor = vec4(0.0);
for (float i = -2.0; i < 3.0; i++) {
for (float j = -2.0; j < 3.0; j++) {
outcolor += mainImage(gl_FragCoord.xy+vec2(i/3.0,j/3.0));
for (float i = 0.0; i < 4.0; i++) {
for (float j = 0.0; j < 4.0; j++) {
outcolor += mainImage(gl_FragCoord.yx+vec2(i/4.0,j/4.0));
}
}

gl_FragColor = outcolor/25.0;
gl_FragColor = outcolor/16.0;
}
// ]]> </script>
</body>
Expand Down

0 comments on commit 08da6f0

Please sign in to comment.