//################################################################# class Displace extends TextureFilter{ public Displace(){ super("Displace",2,1); sourceDescriptions("Image","Distorsion map"); replaceSource(0, new Grid() ); replaceSource(1, new Noise() ); setAttribute(0,"Power",EXPONENTIAL, 0.01, 1.2); } //---------------------- Color output( float x, float y , float z){ float distort = getAttribute(0)*( sources[1].output(x,y,z).getMax() - 0.5 ); return sources[0].output(x+distort,y+distort,z+distort); } }//################################################################# class Swirl extends TextureFilter{ public Swirl(){ super("Swirl",1,2); replaceSource(0, new Grid() ); setAttribute(0,"Rotation", LINEAR, 1, 0.1); setAttribute(1,"Extent", EXPONENTIAL, 20, 1.1); } //---------------------- Color output( float x, float y , float z){ x -= 0.5; y -= 0.5; float d = getAttribute(1)*mag(x,y); float r = getAttribute(0)*((1+d)/exp(d)); float ix = 0.5 + x*cos(r) + y*sin(r); float iy = 0.5 + x*sin(r) - y*cos(r); return sources[0].output(ix,iy,z); } } //################################################################# class Rotate extends TextureFilter{ public Rotate(){ super("Rotate",1,1); replaceSource(0, new Grid() ); setAttribute(0,"Rotation", LINEAR, PI/8, PI/32); } //---------------------- Color output( float x, float y , float z){ x -= 0.5; y -= 0.5; float rot = getAttribute(0); float ix = 0.5 + x*cos(rot) + y*sin(rot); float iy = 0.5 + x*sin(rot) - y*cos(rot); return sources[0].output(ix,iy,z); } } //################################################################# class Translate extends TextureFilter{ public Translate(){ super("Translate",1,2); replaceSource(0, new Grid() ); setAttribute(0,"X offset", LINEAR, 0, 0.025); setAttribute(1,"Y offset", LINEAR, 0, 0.025); } //---------------------- Color output( float x, float y , float z){ return sources[0].output( x+getAttribute(0), y+getAttribute(1), z); } } //################################################################# class Scale extends TextureFilter{ public Scale(){ super("Scale",1,2); replaceSource(0, new Grid() ); setAttribute(0,"Master scale", EXPONENTIAL, 1, 1.1); setAttribute(1,"X scale", EXPONENTIAL, 1, 1.1); setAttribute(2,"Y scale", EXPONENTIAL, 1, 1.1); } //---------------------- Color output( float x, float y , float z){ float s = getAttribute(0); return sources[0].output( x*s*getAttribute(1), y*s*getAttribute(2), z); } } //################################################################# class Bulge extends TextureFilter{ public Bulge(){ super("Bulge",1,2); replaceSource(0, new Grid() ); setAttribute(0,"Power",LINEAR, -0.5, 0.0125); setAttribute(1,"Extent", EXPONENTIAL, 5, 1.2); } //---------------------- Color output( float x, float y , float z){ float bulge = getAttribute(0); float extent = getAttribute(1); x -= 0.5; y -= 0.5; float d = 1 + bulge*exp(-sq( extent*mag(x,y) )); float ix = 0.5 + x*d; float iy = 0.5 + y*d; return sources[0].output(ix,iy,z); } } //################################################################# class Warp extends TextureFilter{ public Warp(){ super("Warp",1,1); replaceSource(0, new Grid() ); setAttribute(0,"Power",LINEAR, -1.5, 0.1); } //---------------------- Color output( float x, float y , float z){ float scaling = getAttribute(0); x -= 0.5; y -= 0.5; float d = 1 + scaling*mag(x,y); float ix = 0.5 + x*d; float iy = 0.5 + y*d; return sources[0].output(ix,iy,z); } } //################################################################# class CoordinateMapping extends TextureFilter{ //---------------------- CoordinateMapping(){ super("Coords",3,0,"Define x,y according to source brightnesses"); sourceDescriptions("y coordinate","Source","x coordinate"); replaceSource(0, new GradientY() ); replaceSource(1, new Grid() ); replaceSource(2, new GradientX() ); } //---------------------- Color output( float x, float y , float z){ float u = sources[2].output(x,y,z).getMax(); float v = sources[0].output(x,y,z).getMax(); return sources[1].output( u, v, z); } } //#################################################################