Fixing The Coding Train’s Code (Water Ripple Shader)

Поділитися
Вставка
  • Опубліковано 23 січ 2025

КОМЕНТАРІ • 40

  • @TheCodingTrain
    @TheCodingTrain 2 роки тому +122

    Incredible! I may actually have the strength now to go back and revisit this! When I get back to streaming I would love to feature this. I'm also planning some shorts now with quick answers to questions so maybe I reference this is one too!

    • @BarneyCodes
      @BarneyCodes  2 роки тому +27

      I would absolutely love to see you revisit this, your videos are such an inspiration to me (and to so many others)!
      Looking forward to the streams and the shorts when you get around to them!
      Thanks so much for the comment :)

  • @BarneyCodes
    @BarneyCodes  2 роки тому +63

    Show your love for The Coding Train here! 🚂🚂

    • @morejpeg
      @morejpeg 2 роки тому +9

      He's the best!

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

    Well done! just like Dan, I tried this myself and got into a deep rabbit hole of shaders.

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

      Thank you! It's such a broad topic, so much to explore!

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

    I'd love to have more shader + p5.js tutorials. Specially a starter tutorial about it will be really cool.

    • @BarneyCodes
      @BarneyCodes  2 роки тому +5

      I'll definitely be doing more shader videos in the future! I think a proper intro to shaders in P5 video is a great idea. Thanks for your comment!

  • @badunius_code
    @badunius_code 9 місяців тому +1

    This is unbelievable. Someone else is also aware of Hugo Elias' articles.

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

    I appreciate the content. Really nice and not overcomplicated. If I can make a small suggestion, please leave the code on the screen for 1s
    It makes a bit easier to pause to read it
    And thanks again

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

      That's a great suggestion and honestly I can't believe I didn't think of it hahaha! Thanks so much for the comment!

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

      No worries. Maybe I'm just too slow :)

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

      No not at all, they are definitely a bit too quick sometimes! I'll be more mindful of it in the future!

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

    You don't need to make the rectangle the width and height of the canvas, you can actually just call rect(0, 0, 0, 0), or with whatever parameters you want, at line 61 and it will work.

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

      Oh that's good to know, thanks!

  • @morejpeg
    @morejpeg 2 роки тому +9

    Coding Train has been real quiet since this dropped

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

      Looks like he just posted 😂

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

      @@BarneyCodes yeah jk, good video dude. I've been putting off really learning shaders. I'll definitely revisit this video when I finally stop dragging my feet

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

      @@morejpeg Thanks! Shaders definitely open up a lot of cool techniques. I highly recommend checking out the book of shaders and shader toy if you haven't already!

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

      @@BarneyCodes Yeah I've dabbled in both before

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

      Ah good stuff, it definitely took me a few goes to get into shaders!

  • @kevinstern2490
    @kevinstern2490 2 роки тому +2

    Thank you so much ! Please do more shader stuff with p5 and glsl ! Shaders are amazing.

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

      Will do! I've got a few more ideas for shaders planned. If there's anything in particular you'd like to see then let me know!

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

    I'm not able to get the ripple to work when I created a point in mouseDragged method as compared to creating it in the draw method under mouseIsPressed. I'm not sure why it did not work, I thought that it would be the same. Any Idea why its not working?

    • @BarneyCodes
      @BarneyCodes  2 роки тому +2

      Hmm that's a great find, I'm not sure why that wouldn't work either! My only thought is that the mouseDragged method is triggered by an event, outside the render loop so I wonder if it is interacting strangely with the shader code? I'll have a play with it when I get some time and let you know if I come up with anything. Let me know if you find something too!

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

      @@BarneyCodes Yeah, I'll keep having at it in the meantime.

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

    didnt dan schiffman create p5js

    • @BarneyCodes
      @BarneyCodes  2 роки тому +5

      I'm not sure that he created it, but he's definitely involved with the Processing Foundation which P5js is a part of, and of course heavily involved with promoting its use in his videos!

    • @TheCodingTrain
      @TheCodingTrain 2 роки тому +9

      @@BarneyCodes Correct, Lauren McCarthy is the creator of p5.js! I am a director of The Processing Foundation which organizes community initiatives and software development related to p5 and Processing. For more: processingfoundation.org/

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

      @@TheCodingTrain Thanks for clarifying!

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

    what is this a crossover episode ?!

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

    Another great video! I'm inspired to actually dig into this now.

    • @BarneyCodes
      @BarneyCodes  2 роки тому +2

      Thanks Steve! They're a bit daunting at first but it really opens up a lot of possibilities!

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

    it's insane !
    I try a lot of things with it 😁😁but I have a really hard time with the colors.
    For example I can't get the background to be white and the circles to be black. If you have any clues...
    Anyway, thanks a lot for this video !!!

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

      Glad you're trying stuff out!
      I think the problem you're running into is that we use the output of the previous frame as the input of the next, meaning anything we do to manipulate the colour will affect the values we're reading in next time.
      This wasn't an issue for the case of my blue ripples, since the red channel held the raw simulation value, so I could just read that.
      Say we were reading the green channel instead, where the output was "next/2.0 + 0.5" (putting the value in the range of 0.5-1).
      To use this as the input we need it back in the original range of 0-1, so once we've read the green value, we would have to go "(g - 0.5) * 2.0".
      Note: if you're reducing the size of the range, you're going to reduce the accuracy, but for something like this it probably won't be too noticeable. To minimise the effects, you should read in the colour channel with the biggest range.
      Essentially, changing the values for display puts them into new ranges, but we need to "undo" those changes to get the raw simulation value back, before we can calculate the next frame.
      So if you want black circles and white background, you are using a range of 1-0 for display, but we need it as 0-1 for simulation. Outputting the value as a colour would be "1.0 - next", and converting the colour back into the simulation value would be "1.0 - val", where val is the colour value of whichever colour channel you read in.
      Example:
      editor.p5js.org/BarneyCodes/sketches/ezHuZKOV9
      I hope that helps! Let me know if you have any questions!

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

      @@BarneyCodes thank you so much your answer that's awesome ! let's have fun with it 😀😀👍👍

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

      No problem at all, keen to see what you come up with!

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

    FANTASTIC work, but one gentle, constructive remark-- please, please s-l-o-w down. It was very hard to follow your explanation d/t the tight editing and rapid talking. Would be much more helpful if it were a slower-paced ten minute vid instead of the super fast five minute one. Again, excellent work!!

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

      Thank you so much for the feedback, really appreciate it! I'll certainly keep that in mind for future videos 😊