Created
June 13, 2019 12:31
-
-
Save KrabCode/9a33e30e01acbb7ab33f6cee827b598d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| float t; | |
| void setup() { | |
| fullScreen(P3D); | |
| } | |
| void draw() { | |
| t = radians(frameCount); | |
| background(0); | |
| pushMatrix(); | |
| translate(width*.5, height*.5); | |
| rotateX(PI*.45); | |
| translate(0, 300); | |
| fill(0); | |
| stroke(255, 150); | |
| strokeWeight(1); | |
| int xres = 19*4; | |
| int yres = 11*4; | |
| float planeWidth = width*2; | |
| float planeHeight = height*2; | |
| for (float xi = 0; xi <= xres; xi++) { | |
| beginShape(TRIANGLE_STRIP); | |
| for (float yi = 0; yi <= yres; yi++) { | |
| float x0 = map(xi, 0, xres, -planeWidth*.5, planeWidth*.5); | |
| float x1 = map(xi+1, 0, xres, -planeWidth*.5, planeWidth*.5); | |
| float y = map(yi, 0, yres, -planeHeight*.5, planeHeight*.5); | |
| float z0 = 50*getZ(x0, y); | |
| float z1 = 50*getZ(x1, y); | |
| vertex(x0, y, z0); | |
| vertex(x1, y, z1); | |
| } | |
| endShape(); | |
| } | |
| popMatrix(); | |
| //fill(255); | |
| //text(floor(frameRate),20, 20); | |
| } | |
| float getZ(float x, float y) { | |
| float d = dist(x, y, 0, -height*5); | |
| float dN = map(d, 0, height*2.5, 0, 1); | |
| return -fbm(dN); | |
| } | |
| float fbm(float iN) { | |
| float sum = 0; | |
| float frq = 6; | |
| float amp = 1; | |
| float ampCorrection = 0; | |
| for (int i = 0; i < 4; i++) { | |
| sum += amp*(abs(sin(iN*frq-t))); | |
| frq *= 3; | |
| amp *= .3; | |
| ampCorrection += amp*2; | |
| } | |
| return sum-ampCorrection; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment