Coding Challenge #24: Perlin Noise Flow Field

Поділитися
Вставка
  • Опубліковано 12 чер 2024
  • In this coding challenge, I use Perlin noise to create a two-dimensional flow field with the p5.js library. Code: thecodingtrain.com/challenges...
    🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
    🎥 Previous video: • Coding Challenge #23: ...
    🎥 Next video: • Coding Challenge #25: ...
    🎥 All videos: • Coding Challenges
    References:
    🗄 p5.js noise() reference: p5js.org/reference/#/p5/noise
    Videos:
    🔴 Livestream Archive: • Live Stream #46: Perli...
    🎥 My videos about Perlin Noise: • 13: What is Perlin Noise?
    Related Coding Challenges:
    🚂 #11 3D Terrain Generation with Perlin Noise in Processing: • Coding Challenge 11: 3...
    🚂 #132 Fluid Simulation: • Coding Challenge #132:...
    🚂 #C4 - Coding in the Cabana Worley Noise: • Coding Worley Noise
    Timestamps:
    0:00 Introduction
    0:35 Two dimensional Perlin noise
    2:02 Scale
    5:08 Create a vector
    5:45 Draw vector as a line
    7:09 Random angle
    8:10 Flow field
    9:24 N-dimensional Perlin noise
    9:53 Add zoff
    11:56 Add Particle class
    15:26 Add particles
    16:26 Add edges()
    17:34 Have particles be affected by vectors
    18:34 Flowfield array
    21:00 Follow()
    22:56 Set magnitude of vectors
    26:42 Add alpha
    27:36 Store particle's previous position
    27:56 Draw line between current and previous position
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: / discord
    💖 Membership: ua-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #perlinnoise #arrays #p5js

КОМЕНТАРІ • 292

  • @nikhobo
    @nikhobo 21 день тому

    Я не знаю английский, но преподаватель настолько экспрессивно рассказывает, что становится понятно. Спасибо! Это очень круто!

  • @ilustrado7291
    @ilustrado7291 7 років тому +203

    I can't stop watching your videos man!

    • @ilustrado7291
      @ilustrado7291 7 років тому +2

      ProCactus Hahaha! Exactly, my man. These concepts and ideas are really interesting - and his energy and enthusiasm reminds me of the "perfect" college professor. Hehe. He's really fun.
      I remember 2 quotes: "The secret to creativity is knowing how to hide your sources" and "Steal like an artist". We'll stand on the shoulders of giants! ;)

    • @ilustrado7291
      @ilustrado7291 7 років тому

      ***** ProCactus Hahaha! Nice! If you guys are on github (which is a must), you can upload your codes there so that we can all learn together. ;) Have fun guys!

    • @abara5678
      @abara5678 7 років тому +2

      Me neither and i have never even written one bit in any Coding Language =)

    • @HenriqueMRocamora
      @HenriqueMRocamora 7 років тому

      I KNOW THAT FEEL

    • @hiperesp
      @hiperesp 5 років тому

      Me2 haha

  • @emilybjoerk
    @emilybjoerk 7 років тому +253

    You are computing the whole vector field every frame even though you only use a fraction of the vectors. Give the perlin noise function as an argument to the vector follow function and compute the flow vector once per particle instead. It should improve your performance significantly and make it independent of the resolution and only depend on the number of particles.

    • @TheCodingTrain
      @TheCodingTrain  7 років тому +91

      Really great point, thank you.

    • @PhilBoswell
      @PhilBoswell 7 років тому +17

      A minor extra optimisation could be to save the calculated vector in the flowfield array so that particles in the same square can share it, assuming that wiping the array on each cycle doesn't slow things down again.

    • @drewjamesandre
      @drewjamesandre 6 років тому +6

      Hey Emily, I see what you mean here! Nice tip.
      There is a lot of empty space that isn't actually touched by any particle, and it would make sense for each particle to calculate the vector of the "cell" it is currently occupying.
      I'm confused about one thing though. If the flow vector is only calculated once per particle, it seems like it would become less of a "flow field" and more of individual particles moving along a perlin noise defined 2d path, totally separate from other particles. Is that how you see it? So if two particles are close to each other, it may loose that appearence of a flow field?

    • @Moll-ayyy
      @Moll-ayyy 6 років тому +4

      Drew André I'm not totally sure, but I'd imagine that all the particles would still behave like they all exist in the same flow field because they all access the same noise space, and the zoff variable would be changed globally. I think.

    • @3i33i
      @3i33i 5 років тому

      ill do it soon

  • @vaguebrownfox
    @vaguebrownfox 2 роки тому +3

    "Ugh you're back, great!" gotta love Shiffman

  • @J_Abad
    @J_Abad 7 років тому +79

    Instead of setting a max speed you could create a viscous friction force so that it's proportional to the particle's speed, that way everything will behave more like a fluid

  • @abara5678
    @abara5678 7 років тому +18

    Man i love this guy´s attitude and character =). So excited about what he is doing and a real sense of humor!

  • @mctuble
    @mctuble 7 років тому +1

    These are by far my favorite coding videos and are getting me interested again in coding. Thank you for that.

  • @RicoGalassi
    @RicoGalassi 4 роки тому +30

    Just watching some of your older videos Dan. Makes me wish I had you as a comp sci professor in college. I would've loved it so much more

    • @IARRCSim
      @IARRCSim 10 місяців тому

      Definitely. It is great he's sharing on youtube too, though. youtube reaches a lot more people and mostly people who are actually looking for content like his. Computer science students often need to take whatever class they're in if they want to graduate so the level of enthusiasm for what is taught tends to be lower.

  • @Algebrodadio
    @Algebrodadio 7 років тому +82

    When your particles 'wrap around', you're giving their position space a toric symmetry. But the perlin noise doesn't have the same symmetry so it will be discontinuous at the boundary of the canvas.

    • @TheCodingTrain
      @TheCodingTrain  7 років тому +39

      Oh, this is a very good and important point, thank you!!

    • @Algebrodadio
      @Algebrodadio 7 років тому +2

      I love these videos - don't change a thing!

    • @erispe
      @erispe 3 роки тому +2

      Is this why the particles are getting stuck at the canvas border?

  • @ya64
    @ya64 7 років тому +1

    I just found this channel and learned so much already. I think Perlin Noise is my new favorite thing and can't wait to start playing with it!

  • @frmcf
    @frmcf Рік тому +3

    I'm feeling so pleased with myself right now, because I followed through the first two thirds of the tutorial and then took it from there and came up with a lot of Dan's solutions by myself. I feel like a big boy who just used the toilet without any help for the first time.

  • @EricDiazMD
    @EricDiazMD 7 років тому +1

    Awesome! First video of yours that I've seen. I learned a lot. I hope you keep doing these. Thanks for what you've done so far.

  • @70TakeAway1
    @70TakeAway1 7 років тому +3

    I'm an accounting major but can't seem to stop watching your videos even though I understand absolutely nothing. Great work.

  • @adilrabbani3562
    @adilrabbani3562 6 років тому +11

    Hey Dan! I like watching all your videos and wish I had a teacher like you at my University. You explain the most convoluted of things in a very fun and easy way. Taking them part by part. I am really thinking of applying for the Masters program at NYU after watching your videos.

  • @theetherbelow
    @theetherbelow Рік тому

    Was looking for inspiration for generative art for pen plotting and this video is still useful, 6 years later. Thank you!

  • @likeyou3317
    @likeyou3317 5 років тому +3

    This is the most beautiful thing I've seen this day, shame on me that I haven't checked all of the coding challenges yet..

  • @stephenwalsh1006
    @stephenwalsh1006 7 років тому +7

    Thank you very much for this series! You are a very talented teacher

    • @TheCodingTrain
      @TheCodingTrain  7 років тому +8

      +Stephen Walsh thank you for watching!

  • @marco_gallone
    @marco_gallone 5 років тому +5

    This was my favourite illusion yet! This would look so cool if it were a candle blow out animation. You should keep it exactly as is but delete (or let the alpha fade out over time) previous points so that it creates a more dynamic smoke effect!

  • @anthonyikedakolar9375
    @anthonyikedakolar9375 7 років тому +5

    dude you are blowing my mind

  • @gloverelaxis
    @gloverelaxis 4 роки тому

    This is the funnest code-related channel out

  • @rosslahive
    @rosslahive 5 років тому +1

    This is really good stuff man.

  • @rebnoz5356
    @rebnoz5356 7 років тому +4

    I don't know anything about programming, but stil I'm watching your videos, because you're so excited about it. 😅

    • @JesseUnderscoreMartin
      @JesseUnderscoreMartin 7 років тому +2

      Philip Merian Why not start learning now? Daniel has a ton of great videos for beginners!

    • @kenan2386
      @kenan2386 3 роки тому

      @@JesseUnderscoreMartin Yea i agree Rebnoz should learn coding! Its not hard and is more than good to learn!

  • @Hyuts
    @Hyuts 5 років тому +2

    I like the video as fast as my cursor can get to the button. Succinct as always. Thank you.

  • @meikurogame9595
    @meikurogame9595 7 років тому

    I swear to God I want that t-shirt so bad hahaha. You're always so fun and interesting to watch, keep up!

  • @nofacee94
    @nofacee94 7 років тому +1

    Nice video.
    Optimization tip: You can create the paths with moveTo() and lineTo() (or with the line() function you are using) inside the for cols and for rows loops and then draw them with stroke() afterwards, outside of the loops; this will render it much faster - by rendering all the lines once instead of for each line.
    Bear in mind it will be a continuous line, so you will have to use moveTo to take the 'pen' off of the canvas and put it to the next line position. moveTo(xa,ya) e.g. 0,0 lineTo(xb, yb) e.g. 0,1 then update xa,ya and xb,yb with the next line positions inside the for loops and repeat. The call stroke() outside the loooops.

  • @karanverma1
    @karanverma1 8 років тому

    thanks a lot for such amazing stuff... looking forward for upcoming videos

  • @stanger963
    @stanger963 6 років тому +8

    "There's a bunch of few different things" xD

  • @leberkassemmel
    @leberkassemmel 7 років тому +47

    I like you. You make your code big enough, so even with a resolution of 144p i can still read it.
    I know, i should get faster internet. But it is so expensive!

    • @sallerc
      @sallerc 7 років тому +11

      Wow, that's dedication... I couldn't bare to watch anything in 144p :)

    • @leberkassemmel
      @leberkassemmel 7 років тому +1

      salle rc Yes. But imo it is not worth 50$ a month more just to watch them in 360p...

    • @sallerc
      @sallerc 7 років тому +1

      Michi Lo Ah I see. That's expensive, where do you live?

    • @leberkassemmel
      @leberkassemmel 7 років тому +1

      salle rc Germany. Bavarian Forest. Nowhere near other civilisation.

    • @sallerc
      @sallerc 7 років тому +1

      Didn't realize it's that expensive in Germany, but guess the "nowhere near civilization"-part has something to do with it :) You should move to Sweden, I pay like 15EUR/month for a 100MBit connection.

  • @skydeng1647
    @skydeng1647 7 років тому

    learn a lot, thank you !!!

  • @DerpRaptor
    @DerpRaptor 2 роки тому +1

    Not sure if someone has said this yet, A problem that I've seen is that when you draw the line from prevPoint to pos, there's some overlap of the lines, which if you're using alpha will produce circles at each of the points where the line is drawn. If you have a maxspeed which all of the particles reach, they end up creating dots at a uniform distance from each other.
    A fix that I think works is to add "strokeJoin(MITIR)" which makes all of the points at which the strokes join a flat line instead.

  • @emrenitim83
    @emrenitim83 3 роки тому

    Thank you, great video

  • @lemonlordminecraft
    @lemonlordminecraft 6 років тому

    I went back and watched them. Now I'm here.

  • @nagesh007
    @nagesh007 2 роки тому +1

    Thanks a lot

  • @JohnDoe_1237
    @JohnDoe_1237 6 років тому

    0:06 omg nice, this looks great
    :D

  • @exdcode3369
    @exdcode3369 7 років тому

    You are so awesome!!! And I'm not even learning or using JavaScript!) might try to apply some of your challenges to Java, but not sure still if will be able to)

  • @danielk1560
    @danielk1560 4 роки тому +2

    Thank You! Great video. Fortunately, I didn't have these performance issues... Was running it on 1920x1080 at 5 particles and got stable 80 fps!

    • @px64
      @px64 4 роки тому +2

      I was running in 4k with half a particle, same with me! , no lag at all..

  • @alexpraturlon1873
    @alexpraturlon1873 7 років тому

    +Danial Shiffman Love the videos. I enjoy following along using processing and learning a bunch including the converting from P5 to processing.

  • @tranceemerson8325
    @tranceemerson8325 4 роки тому

    cool you could use this to tell the particles to carve values off of a heightmap over time.

  • @deenchen4822
    @deenchen4822 3 місяці тому

    The way the particles are limited with a maximum speed reminds me of how light is limited as the object with the maximum speed in the world.

  • @johankarlsson20
    @johankarlsson20 6 років тому +1

    All my Simplex Noise Flow Field creations as CodePen TV: codepen.io/tv/Dwgqqd

  • @possumcode
    @possumcode 6 років тому

    That is sooooooooooo cool !

  • @kevnar
    @kevnar 6 років тому

    The crux.
    Such a great word.

  • @Simmonsstummer
    @Simmonsstummer 2 роки тому

    Ok this was amazing

  • @brothajonze
    @brothajonze 2 роки тому

    Just brutal watching this guy fumble and stumble over text that brackets his life.

  • @thomaswaller4517
    @thomaswaller4517 8 років тому +1

    That is a really nice program. Good job mate.

    • @TheCodingTrain
      @TheCodingTrain  8 років тому

      Thank you!

    • @thomaswaller4517
      @thomaswaller4517 7 років тому

      I have a question, I want to build a Indie game, with sound, and good graphics, and I want to code the whole engine myself, not use unity or anything, what language should I be using for such task? It's a Puzzle Platformer, and some creature like enemies will be in the game.

  • @PrivateIsleProductions
    @PrivateIsleProductions 7 років тому

    excellent work

  • @CharIie83
    @CharIie83 6 років тому

    really impressive

  • @kairotox
    @kairotox 5 років тому +2

    I was trying to figure out a way to make the smoke like lines fade over time, and I'm not really a programmer, so I'm really just spitballing here, but one option might be to have the smoke draw on a transparent white layer that also draws every time the program draws. So every time it's adding a bit of white to everything that wasn't just drawn, eventually making old lines fade out. There's probably a better way to do it, and I'm not sure if my way would even work.

  • @bono95zg
    @bono95zg 7 років тому

    love how detalied the tutorial is haha

  • @AB-Prince
    @AB-Prince 6 років тому

    You could also give a velocity to each vector by giving a w to the perlin noise and using it as a velocity

  • @aurelianobuendia24
    @aurelianobuendia24 6 років тому +41

    Im the only one hearing those creepy laughs ?

    • @zahidahmed586
      @zahidahmed586 6 років тому +2

      AHHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHH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AHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAH

    • @marcthompson647
      @marcthompson647 5 років тому

      No you aren't

    • @pflintaryan8336
      @pflintaryan8336 4 роки тому

      i think they are having party next door.

  • @sehyunkim4736
    @sehyunkim4736 6 років тому

    It's bunch'a cool stuff!

  • @juan_w_fer
    @juan_w_fer 7 років тому +4

    Daniel, I must thank you and UA-cam's new algorythm for recommended videos. Although I have some knowledge of Arduino and Python, this is the more interactive environment I want to have when coding(Battleship, Conway's game of life aren't that fun using print() in Python lol). Now I'm going to start watching your Processing playlist. Thanks, your videos are really nice to watch.

    • @TheCodingTrain
      @TheCodingTrain  7 років тому +3

      So glad to hear, thank you!

    • @jesuschrist6979
      @jesuschrist6979 7 років тому

      Juan Fernández try JavaScript learn native first then go to p5 for game development

  • @Stoupik
    @Stoupik 7 років тому

    Hi Dan.
    First of all, I love your videos. They really brought me to Processing and I became kind of obsessed with it. :) I really appreciate relatively simple code and outstanding results!
    But to this very coding challenge. I believe there's a bug in your edges() function (if not, please someone correct me). I am probably more unlucky than you were when you ran your program and my particles tested the edges to the limit. :)
    Your particles are allowed (due to edges method implementation) to have *y* values in a range ** (including border values. This was causing IndexOutOfBoundException when one of the particles was right on the edge (had y = height). In those instances the formula for flowfield's index (*x + y * cols*) gave invalid index. For example (pseudocode)
    size(400, 400);
    scale = 20;
    rows = cols = 400 / 20 = 20;
    flowField.length = 400; // index in the range from 0 to 399
    particle = new Particle(200, 400);
    // particles coors in the grid
    col = 200 / 20 = 10
    row = 400 / 20 = 20
    index = col + row * cols = 10 + 20 * 20 = 410 => invalid index
    So the edge() function should be
    private void edge() {
    if (position.x < 0) {
    position.x = width - 1;
    }
    if (position.x > width - 1) {
    position.x = 0;
    }
    if (position.y < 0) {
    position.y = height - 1;
    }
    if (position.y > height - 1) {
    position.y = 0;
    }
    }
    Keep those videos coming, they are really fun and full of brilliant ideas. Thanks!

  • @Pingoooeen
    @Pingoooeen 3 роки тому

    Love it!
    Even though what you did in the end was pointless

  • @SpringySpring04
    @SpringySpring04 2 роки тому

    I can't get over the fact that there are random sitcom laughter clips playing in the background at some points of the video lol

  • @yasiin_miim3278
    @yasiin_miim3278 Місяць тому

    8:57
    you are a great loving tecaher Daniel :)))

  • @onnio7998
    @onnio7998 Рік тому +2

    I got wayy into optimizing this. I can simulate 50 000 particles for 500 iterations in a second. The color of the traces can be dynamically changed. Thinking of making a video of it at some point.

    • @krccmsitp2884
      @krccmsitp2884 Рік тому +1

      Would be great to see that video and code.

  • @ResanChea
    @ResanChea 4 роки тому +3

    do you do these tutorials for the processing version? because i want to start learning processing more but most of the interesting projects are on p5js

  • @stephendelacruzone
    @stephendelacruzone 5 місяців тому

    Wow! 🤩

  • @linchen7258
    @linchen7258 5 років тому

    Thank you soooo much!! I really like Perlin noise! And I tried to follow the processing you upload in the Github...Can I ask why the effect is different from the version of p5js? sorry about the stupid question, I am just the beginner...

  • @torwine4895
    @torwine4895 2 роки тому

    Thanks a lot :-)
    Now i make beautifull pictures in Java.
    That's a nice playground.

  • @alexandralazarevski3265
    @alexandralazarevski3265 7 років тому +1

    where is this video on wind flows based on geo locations! !! Dying to see this!

  • @Mustafaismail22
    @Mustafaismail22 7 років тому

    thanks 😘

  • @nane1890
    @nane1890 8 років тому

    omg! you're awesome!!!

  • @theom3050
    @theom3050 7 років тому +4

    I can't seem to find the processing version on github, have you upploaded it?

  • @deathtrips
    @deathtrips 8 років тому +16

    looks good

  • @NicolaiWeitkemper
    @NicolaiWeitkemper 5 років тому

    Might be a nice screensaver

  • @aurelb62
    @aurelb62 7 років тому

    I think the previous position is always the same position as "pos". In the 'update' function, you should apply 'updatePrev' before adding vel to pos.

  •  5 років тому +1

    25:00 the force is strong with this one

  • @definty
    @definty 2 роки тому

    You could use the Simplex Noise algorithm its more effcient and does the same thing.

  • @noahmccann4438
    @noahmccann4438 6 років тому

    Very cool effect. Have you considered doing a coding challenge based around a Navier Stokes fluid solver? Those seem quite similar to the flow fields you’re demonstrating here, however you can have the fluid (equivalent to the particles in your example) affect the flow field - similar to real fluids, rather than relying on Perlin noise to drive the field.
    My apologies if you’ve already done this in another video - I couldn’t find one with a quick search.

  • @Eddytorial
    @Eddytorial 5 років тому

    even i really like what's going on here i kinda wondering what happening next room, must be something really funny :)

  • @Shockszzbyyous
    @Shockszzbyyous 7 років тому

    Your awesome

  • @Marcello30able
    @Marcello30able 7 років тому +5

    Hey! Quick question, is it possible to tie the flow fields speed to a microphone input?

    • @JesseUnderscoreMartin
      @JesseUnderscoreMartin 7 років тому +4

      Marcello30able Anything is possible. forum.processing.org/one/topic/how-can-i-detect-sound-with-my-mic-in-my-computer.html

  • @sariaghaziri6448
    @sariaghaziri6448 5 років тому

    I love your videos! But here I am struggling trying to decode your code from P5 to P3, any tips? I couldn't find a challenge done on P3!

  • @kevnar
    @kevnar 4 роки тому

    There's a typo in your github code for this project, in the flowfield class.
    void update() {
    float xoff = 0;
    for (int y = 0; y < rows; y++) {
    float yoff = 0;
    for (int x = 0; x < cols; x++) {
    float xoff = 0 is resetting the y loop, and vice versa. (Processing version)

  • @MrThonny15
    @MrThonny15 7 років тому +1

    You are saying that you have made the Perlin noise program for processing earlier but I can't seem to find it anywhere. I may have overlooked it on github but I think it is not there. Does any one know were to find it?

  • @msoulforged
    @msoulforged 5 років тому

    Yay we drew the hairs in the drain!

  • @musicdudejoe263
    @musicdudejoe263 4 роки тому

    I'm confused, can you use function draw() in say notepad, or is it something specifically used within p5?

  • @danrobinson1729
    @danrobinson1729 8 років тому +2

    This is so rad. I'm loving your books Dan.

  • @jialiu518
    @jialiu518 7 років тому

    n dimension Perlin noise = the sound of minds being blown right now

  • @kps2642
    @kps2642 7 років тому

    i like your videos man , but i am too busy with with c++, can i do this in c++ ? i do plan to learn JS in the future

  • @georgexu9591
    @georgexu9591 6 років тому +2

    Hi, Daniel, thank u for your hard work! I'm trying to write this in PDE, and got an error: "ArrayIndexOutOfBoundsException: xxxx". I found the problem is happening in the "edges()" function. Then I change the "pos.x = width;" and "pos.y = height;" to "pos.x = width-1;" and "pos.y = height -1;". And the problem solved temporarily.
    Do u have the same problem and how do u solve it?

    • @likeyou3317
      @likeyou3317 5 років тому

      Just instead of:
      cols=floor(width/scale);
      rows=floor(width/scale);
      do
      cols=floor(width/scale)
      +1;
      rows=floor(width/scale)+1;

  • @arunprabhu8120
    @arunprabhu8120 4 роки тому

    Sorry for such a silly query, but shouldn't zoff be incremented outside the y loop?

  • @anonymousstudent5871
    @anonymousstudent5871 6 років тому +1

    WHY it is "createP is not defined"and "particle is not a contructor" keep showing up in my console?

  • @tobyzxcd
    @tobyzxcd 7 років тому +12

    This was Uploaded on my birthday, Man... June 27th is an awesome day

    • @TheCodingTrain
      @TheCodingTrain  7 років тому +2

      +Toby Brooks happy belated!

    • @tobyzxcd
      @tobyzxcd 7 років тому

      Thanks Dan, and Thanks for the Great Video !

    • @WhiteIce2112
      @WhiteIce2112 7 років тому

      Toby Brooks we share the same birthday.

  • @oguzyardmc8551
    @oguzyardmc8551 6 років тому

    Okey I liked

  • @kennys1881
    @kennys1881 6 років тому

    @0:38 the good feeling when u really do it..

  • @mohamedmhmood2940
    @mohamedmhmood2940 7 років тому +3

    انت انسان مبدع

    • @jesuschrist6979
      @jesuschrist6979 7 років тому +3

      mohamed mhmood ALLAN SNACKBAR

    • @giganooz
      @giganooz 6 років тому

      Jesus Christ Lol ur the best

  • @robogaming3045
    @robogaming3045 5 років тому +1

    And remember kids: Shiffman is a particle

  • @gm_000
    @gm_000 7 років тому +5

    I do not understand 25:30 - Why do the vectors mostly point toward left? And why multiplying by 4? If noise returns between 0 and 1 and we multiply by 2PI we should have already the correct values... What am I missing?

    • @ronnetgrazer362
      @ronnetgrazer362 5 років тому

      When the increment variable was set to 1, all the tiles were mid grey. He then changed it to 0.1, and he got more variation, but nowhere near a range between black and white.

    • @iminni3459
      @iminni3459 5 років тому +2

      The values tend to be around 0.5 so if you multiply by 2PI they will tend to be around PI (which is the left direction).

    • @Kitulous
      @Kitulous 5 років тому

      @@iminni3459 Does this have to do something with the Gaussian distribution?

    • @iminni3459
      @iminni3459 5 років тому

      @@Kitulous maybe I'm not really sure

  • @NinJaTurtleSplinter
    @NinJaTurtleSplinter 7 років тому +9

    21:20 for a second i thought hes not wearing pants

    • @redpepper74
      @redpepper74 4 роки тому

      Oslo Cloonson Yep, I did a double-take too. Deception 100

  • @ariseyhun2085
    @ariseyhun2085 7 років тому +1

    Is the code to this in the processing version avaiable anywhere?

  • @logy80
    @logy80 7 років тому

    WOW

  • @realcygnus
    @realcygnus 7 років тому

    Top Notch

  • @FredoCorleone
    @FredoCorleone 5 років тому

    Why not HSB from velocity angle to color particles?
    I guess that instead of _p5.Vector.fromAngle(angle)_ you could have used (polar to cartesian) _createVector(cos(angle), sin(angle))_ and instead of _v.heading()_ you could have used _atan2(v.y, v.x)_ . Am I right?

  • @michaeldere2892
    @michaeldere2892 7 років тому

    Im new to this, how do I get started? I know some js, but willing to learn more.

  • @psdmaniac
    @psdmaniac 3 роки тому

    Can you make particle flow but with pressure? That you can't have many particles in one place. I have made something simmilar on mobile- vector array (vector values are based on touch data from the screen) and particles that are appearing in random position when flow outside the screen. It looks cool but without pressure all particles can be squized to 1px space and this looks bad.

  • @robloxfan60
    @robloxfan60 8 років тому

    Hi, Dan. Could you do a short tutorial on how you set up your local server? Maybe just a quick few minutes at the beginning of the next stream? Thanks a lot!

    • @TheCodingTrain
      @TheCodingTrain  8 років тому

      take a look at: ua-cam.com/video/UCHzlUiDD10/v-deo.html

    • @robloxfan60
      @robloxfan60 8 років тому

      Brillinat, thanks so much!