├── README.md ├── WorleyNoise ├── Particle.pde └── WorleyNoise.pde ├── LICENSE ├── WorleyNoisePerlinMotion └── WorleyNoisePerlinMotion.pde ├── WorleyNoise3D └── WorleyNoise3D.pde ├── CabanaViz1 └── CabanaViz1.pde └── CabanaViz2 └── CabanaViz2.pde /README.md: -------------------------------------------------------------------------------- 1 | # WorleyNoise 2 | Repo for Code from Worley Noise live stream 3 | -------------------------------------------------------------------------------- /WorleyNoise/Particle.pde: -------------------------------------------------------------------------------- 1 | class Particle { 2 | PVector position; 3 | PVector velocity; 4 | 5 | Particle() { 6 | position = new PVector( 7 | random(width), 8 | random(height), 9 | random(-width/2, width/2) 10 | ); 11 | velocity = PVector.random2D(); 12 | velocity.mult(5); 13 | } 14 | 15 | void update() { 16 | // Add the current speed to the position. 17 | position.add(velocity); 18 | if ((position.x > width) || (position.x < 0)) { 19 | velocity.x = velocity.x * -1; 20 | } 21 | if ((position.y > height) || (position.y < 0)) { 22 | velocity.y = velocity.y * -1; 23 | } 24 | } 25 | void display() { 26 | // Display circle at x position 27 | stroke(0); 28 | fill(175); 29 | ellipse(position.x, position.y, 16, 16); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Daniel Shiffman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /WorleyNoisePerlinMotion/WorleyNoisePerlinMotion.pde: -------------------------------------------------------------------------------- 1 | PVector[] seed = new PVector[7]; 2 | 3 | void setup() { 4 | size(400, 400); 5 | for (int i = 0; i < seed.length; i++) { 6 | seed[i] = new PVector(random(width), random(height), random(width)); 7 | } 8 | } 9 | 10 | void draw() { 11 | 12 | 13 | loadPixels(); 14 | for (int x = 0; x < width; x++) { 15 | for (int y = 0; y < height; y++) { 16 | int index = x + y * width; 17 | float[] distances = new float[seed.length]; 18 | for (int i = 0; i < seed.length; i++) { 19 | PVector v = seed[i]; 20 | //distances[i] = dist(x, y, width/2, v.x, v.y, v.z); 21 | distances[i] = dist(x, y, v.x, v.y); 22 | } 23 | distances = sort(distances); 24 | float d = map(distances[0],0,width/2,255,0); 25 | color c = color(d); 26 | pixels[index] = c; 27 | } 28 | } 29 | updatePixels(); 30 | 31 | 32 | int offset = 0; 33 | for (PVector v : seed) { 34 | stroke(0, 255, 0); 35 | strokeWeight(8); 36 | point(v.x, v.y); 37 | v.x = map(noise(offset + frameCount * 0.005),0,1,-100,width+100); 38 | v.y = map(noise(offset + 100000 + frameCount * 0.005),0,1,-100,height+100); 39 | offset+=1000; 40 | } 41 | 42 | saveFrame("perlin/worley####.png"); 43 | } 44 | -------------------------------------------------------------------------------- /WorleyNoise/WorleyNoise.pde: -------------------------------------------------------------------------------- 1 | Particle[] features; 2 | float angle = 0; 3 | void setup() { 4 | size(640, 360); 5 | features = new Particle[20]; 6 | for (int i = 0; i < features.length; i++) { 7 | features[i] = new Particle(); 8 | //colorMode(HSB,255); 9 | } 10 | } 11 | 12 | void draw() { 13 | background(0); 14 | loadPixels(); 15 | float z = sin(angle) * (width/2); 16 | for (int x = 0; x < width; x++) { 17 | for (int y = 0; y < height; y++) { 18 | int index = x + y * width; 19 | 20 | float[] distances = new float[features.length]; 21 | for (int i = 0; i < features.length; i++) { 22 | PVector v = features[i].position; 23 | // 3D features 24 | // float z = map(mouseX, 0, width, -width/2, width/2); 25 | distances[i] = dist(x, y, z, v.x, v.y, v.z); 26 | // 2D features 27 | // distances[i] = dist(x, y, v.x, v.y); 28 | } 29 | distances = sort(distances); 30 | //int n = 3; 31 | float d0 = distances[0]; 32 | float d1 = distances[1]; 33 | float d2 = distances[2]; 34 | float r = map(d1, 0, width/4, 255, 20) * 2; 35 | float g = map(d2, 0, width/4, 255, 20) * 2; 36 | float b = map(d0, 0, width/4, 255, 20) * 2; 37 | pixels[index] = color(r, g, b); 38 | } 39 | } 40 | updatePixels(); 41 | 42 | //for (int i = 0; i < features.length; i++) { 43 | // PVector v = features[i]; 44 | // v.x += random(-5, 5); 45 | // v.y += random(-5, 5); 46 | // v.z += random(-5, 5); 47 | //} 48 | 49 | 50 | for (int i = 0; i < features.length; i++) { 51 | Particle p = features[i]; 52 | //p.display(); 53 | p.update(); 54 | } 55 | 56 | // angle += 0.01; 57 | // saveFrame("worley/worley####.png"); 58 | } 59 | -------------------------------------------------------------------------------- /WorleyNoise3D/WorleyNoise3D.pde: -------------------------------------------------------------------------------- 1 | import peasy.PeasyCam; 2 | 3 | PVector[] features; 4 | float angle = 0; 5 | PeasyCam cam; 6 | 7 | void setup() { 8 | size(800, 800, P3D); 9 | cam = new PeasyCam(this, 1600); 10 | features = new PVector[50]; 11 | for (int i = 0; i < features.length; i++) { 12 | features[i] = new PVector( 13 | random(-width/2, width/2), 14 | random(-width/2, width/2), 15 | random(-width/2, width/2)); 16 | } 17 | } 18 | 19 | void draw() { 20 | background(0); 21 | //loadPixels(); 22 | //float z = sin(angle) * (width/2); 23 | int skip = 50; 24 | for (int x = -width/2; x < width/2; x+=skip) { 25 | for (int y = -width/2; y < width/2; y+=skip) { 26 | for (int z = -width/2; z < width/2; z+=skip) { 27 | float[] distances = new float[features.length]; 28 | for (int i = 0; i < features.length; i++) { 29 | PVector v = features[i]; 30 | distances[i] = dist(x, y, z, v.x, v.y, v.z); 31 | } 32 | distances = sort(distances); 33 | int n = 1; 34 | float d = distances[n]; 35 | float sz = map(d, 0, width/8, skip, 0); 36 | push(); 37 | translate(x, y, z); 38 | noStroke(); 39 | fill(255, 50); 40 | box(sz); 41 | pop(); 42 | } 43 | } 44 | } 45 | //updatePixels(); 46 | 47 | //for (int i = 0; i < features.length; i++) { 48 | // PVector v = features[i]; 49 | // v.x += random(-5, 5); 50 | // v.y += random(-5, 5); 51 | // v.z += random(-5, 5); 52 | //} 53 | 54 | // println(frameRate); 55 | 56 | //for (int i = 0; i < features.length; i++) { 57 | // float sw = map(features[i].z, 0, width, 4, 20); 58 | // strokeWeight(sw); 59 | // stroke(255, 0, 0); 60 | // point(features[i].x, features[i].y); 61 | //} 62 | // noLoop(); 63 | 64 | //angle += 0.01; 65 | //saveFrame("worley/worley####.png"); 66 | } 67 | -------------------------------------------------------------------------------- /CabanaViz1/CabanaViz1.pde: -------------------------------------------------------------------------------- 1 | import peasy.PeasyCam; 2 | 3 | int[] ct = { 4 | color(146, 83, 161), 5 | color(240, 99, 164), 6 | color(45, 197, 244), 7 | color(252, 238, 33), 8 | color(241, 97, 100), 9 | color(112, 50, 126), 10 | color(164, 41, 99), 11 | color(11, 106, 136), 12 | color(248, 158, 79), 13 | color(146, 83, 161), 14 | color(236, 1, 90) 15 | }; 16 | 17 | PVector[] features = new PVector[50]; 18 | float angle = 0; 19 | //PeasyCam cam; 20 | 21 | int counter = 0; 22 | boolean slice = false; 23 | float y = 400; 24 | PImage wnoise; 25 | 26 | boolean showNoise = false; 27 | 28 | int state = 0; 29 | 30 | boolean render = false; 31 | 32 | 33 | void setup() { 34 | size(800, 800, P3D); 35 | wnoise = createImage(800, 800, RGB); 36 | //cam = new PeasyCam(this, 1600); 37 | for (int i = 0; i < features.length; i++) { 38 | float x = random(-400, 400); 39 | float y = random(-400, 400); 40 | float z = random(-400, 400); 41 | features[i] = new PVector(x, y, z); 42 | } 43 | frameRate(30); 44 | } 45 | 46 | void draw() { 47 | background(ct[0]); 48 | lights(); 49 | //hint(ENABLE_DEPTH_SORT); 50 | 51 | translate(width/2, height/2, -800); 52 | rotateX(-PI/8); 53 | rotateY(-PI/6 + frameCount * 0.005); 54 | stroke(ct[2]); 55 | strokeWeight(8); 56 | noFill(); 57 | box(800); 58 | 59 | for (int i = 0; i < counter; i++) { 60 | PVector p = features[i]; 61 | push(); 62 | noStroke(); 63 | fill(ct[3]); 64 | translate(p.x, p.z, p.y); 65 | sphere(16); 66 | pop(); 67 | } 68 | 69 | if (frameCount > 60) { 70 | if (frameCount % 2 == 0) { 71 | if (counter < features.length) { 72 | counter+=2; 73 | } else { 74 | slice = true; 75 | } 76 | } 77 | } 78 | 79 | if (showNoise) { 80 | wnoise.loadPixels(); 81 | float z = y; 82 | for (int x = 0; x < width; x++) { 83 | for (int y = 0; y < height; y++) { 84 | int index = x + y * width; 85 | 86 | float[] distances = new float[features.length]; 87 | for (int i = 0; i < features.length; i++) { 88 | PVector v = features[i]; 89 | // 3D features 90 | // float z = map(mouseX, 0, width, -width/2, width/2); 91 | distances[i] = dist(x-400, y-400, z, v.x, v.y, v.z); 92 | // 2D features 93 | // distances[i] = dist(x, y, v.x, v.y); 94 | } 95 | distances = sort(distances); 96 | float d0 = distances[0]; 97 | float r = map(d0, 0, width/2, 255, 0); 98 | wnoise.pixels[index] = color(r); 99 | } 100 | } 101 | wnoise.mask(wnoise); 102 | wnoise.updatePixels(); 103 | } 104 | 105 | 106 | 107 | 108 | if (slice) { 109 | float extent = 450; 110 | 111 | float w = wnoise.width; 112 | strokeWeight(4); 113 | stroke(ct[1]); 114 | fill(ct[1], 175); 115 | translate(0, y, 0); 116 | beginShape(QUAD); 117 | vertex(-extent, 0, -extent, -w, -w); 118 | vertex(extent, 0, -extent, w, -w); 119 | vertex(extent, 0, extent, w, w); 120 | vertex(-extent, 0, extent, -w, w); 121 | endShape(); 122 | y-=10; 123 | 124 | if (showNoise) { 125 | imageMode(CENTER); 126 | rotateX(PI/2); 127 | image(wnoise, 0, 0); 128 | } 129 | y = constrain(y, -400, 400); 130 | } 131 | 132 | if (render) { 133 | saveFrame("cube1/cube1####.png"); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /CabanaViz2/CabanaViz2.pde: -------------------------------------------------------------------------------- 1 | import peasy.PeasyCam; 2 | 3 | int[] ct = { 4 | color(146, 83, 161), 5 | color(240, 99, 164), 6 | color(45, 197, 244), 7 | color(252, 238, 33), 8 | color(241, 97, 100), 9 | color(112, 50, 126), 10 | color(164, 41, 99), 11 | color(11, 106, 136), 12 | color(248, 158, 79), 13 | color(146, 83, 161), 14 | color(236, 1, 90) 15 | }; 16 | 17 | PVector[] features = new PVector[20]; 18 | float angle = 0; 19 | //PeasyCam cam; 20 | 21 | int counter = 0; 22 | boolean slice = false; 23 | float y = 400; 24 | PImage wnoise; 25 | 26 | boolean showNoise = true; 27 | 28 | int state = 0; 29 | 30 | boolean render = false; 31 | 32 | 33 | void setup() { 34 | size(800, 800, P3D); 35 | wnoise = createImage(800, 800, RGB); 36 | //cam = new PeasyCam(this, 1600); 37 | for (int i = 0; i < features.length; i++) { 38 | float x = random(-400, 400); 39 | float y = random(-400, 400); 40 | float z = random(-400, 400); 41 | features[i] = new PVector(x, y, z); 42 | } 43 | frameRate(30); 44 | } 45 | 46 | void draw() { 47 | background(ct[0]); 48 | //lights(); 49 | hint(ENABLE_DEPTH_SORT); 50 | 51 | translate(width/2, height/2, -800); 52 | rotateX(-PI/8); 53 | rotateY(-PI/6 + frameCount * 0.005); 54 | stroke(ct[2]); 55 | strokeWeight(8); 56 | noFill(); 57 | box(800); 58 | 59 | if (showNoise) { 60 | counter = features.length; 61 | slice = true; 62 | } 63 | for (int i = 0; i < counter; i++) { 64 | PVector p = features[i]; 65 | push(); 66 | noStroke(); 67 | fill(ct[3]); 68 | translate(p.x, p.z, p.y); 69 | sphere(16); 70 | pop(); 71 | } 72 | 73 | if (frameCount > 60) { 74 | if (frameCount % 2 == 0) { 75 | if (counter < features.length) { 76 | counter+=2; 77 | } else { 78 | slice = true; 79 | } 80 | } 81 | } 82 | 83 | if (showNoise) { 84 | wnoise.loadPixels(); 85 | float z = y; 86 | for (int x = 0; x < width; x++) { 87 | for (int y = 0; y < height; y++) { 88 | int index = x + y * width; 89 | 90 | float[] distances = new float[features.length]; 91 | for (int i = 0; i < features.length; i++) { 92 | PVector v = features[i]; 93 | // 3D features 94 | // float z = map(mouseX, 0, width, -width/2, width/2); 95 | distances[i] = dist(x-400, y-400, z, v.x, v.y, v.z); 96 | // 2D features 97 | // distances[i] = dist(x, y, v.x, v.y); 98 | } 99 | distances = sort(distances); 100 | float d0 = distances[0]; 101 | float r = map(d0, 0, width/2, 300, 0); 102 | wnoise.pixels[index] = color(r); 103 | } 104 | } 105 | wnoise.mask(wnoise); 106 | wnoise.updatePixels(); 107 | } 108 | 109 | 110 | 111 | 112 | if (slice) { 113 | float extent = 450; 114 | 115 | float w = wnoise.width; 116 | strokeWeight(4); 117 | stroke(ct[1]); 118 | if (showNoise) { 119 | noFill(); 120 | } else { 121 | fill(ct[1], 175); 122 | } 123 | translate(0, y, 0); 124 | beginShape(QUAD); 125 | vertex(-extent, 0, -extent, -w, -w); 126 | vertex(extent, 0, -extent, w, -w); 127 | vertex(extent, 0, extent, w, w); 128 | vertex(-extent, 0, extent, -w, w); 129 | endShape(); 130 | y-=10; 131 | 132 | if (showNoise) { 133 | imageMode(CENTER); 134 | rotateX(PI/2); 135 | image(wnoise, 0, 0); 136 | } 137 | y = constrain(y, -400, 400); 138 | } 139 | 140 | if (render) { 141 | saveFrame("cube2/cube2####.png"); 142 | } 143 | } 144 | --------------------------------------------------------------------------------