How to use Compute Shaders in Godot 4

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

ความคิดเห็น • 55

  • @KuroKitten
    @KuroKitten หลายเดือนก่อน +1

    I was trying to figure out how to pass textures into a compute shader, and now that I see how it's done... I definitely wasn't close to figuring it out, lol. This is gold, thanks mate!

  • @1cedragon
    @1cedragon 8 หลายเดือนก่อน +3

    Excellent tutorial! Thank you for taking the time to explain compute shaders. I wish Godot had more documentation about them because they're such a powerful tool for advanced effects.

  • @leerpret3950
    @leerpret3950 2 ปีที่แล้ว +6

    This is great, thanks! Info on compute shaders are so rare, hopefully it becomes more mainstream.

    • @crigz
      @crigz  2 ปีที่แล้ว +4

      I hope so too! You can do some incredible things with them, it's a tool everyone should have in their belt.

  • @binary_soup
    @binary_soup ปีที่แล้ว +11

    Turns out RGBA8 is required to use a texture in a sampler. If it doesn't have an alpha channel then the rendering device will throw an error. To fix this, you can use `image.convert(Image.FORMAT_RGBA8)` to convert its format first.

    • @mezzofortestudios7342
      @mezzofortestudios7342 ปีที่แล้ว

      this was helpful, thank you

    • @chriszymurgist
      @chriszymurgist 4 หลายเดือนก่อน

      I have been banging my head on this issue until I came across your comment. As an addendum the PNG also can not have mipmaps.

  • @AslanSilva
    @AslanSilva 2 ปีที่แล้ว +1

    Another vid so quick! Amazing stuff.

  • @planetbridging4249
    @planetbridging4249 6 หลายเดือนก่อน +1

    I dont normaly give comments to youtube videos but this one actually got me to my solution i needed and to avoid using unity. Thank you so much for helping so i can make my idea using the godot 4 with compute shaders utlizing the cpu and the gpu for my ai architecture design :D

  • @ViktorFerenczi
    @ViktorFerenczi 2 ปีที่แล้ว +1

    Your video has been super useful and came at the exact right time for my project. Thanks! Subscribed.

  • @giantfrogstudios839
    @giantfrogstudios839 2 ปีที่แล้ว +1

    Nice video

  • @jiro4559
    @jiro4559 3 หลายเดือนก่อน

    Music.... would love to have it toned down

  • @brettfleeman6014
    @brettfleeman6014 2 ปีที่แล้ว +2

    First

  • @Galomortalbr
    @Galomortalbr 2 ปีที่แล้ว +13

    amazing video, i wish there was more content like this, Godot 4 is truly a step up from Godot 3

  • @Gredran
    @Gredran 2 ปีที่แล้ว +8

    Godot 4 tutorials are comin in!! Great video! Its a cool thing to show off that the engine can do! You definitely earned a subscriber 😊

  • @wellhellotherekyle
    @wellhellotherekyle 2 ปีที่แล้ว +8

    Wow, you’ve quickly become one of my favorite Godot resources!

  • @farianderson168
    @farianderson168 ปีที่แล้ว +1

    Do we have to use external editor for writing compute shaders?

  • @question_mark
    @question_mark 2 ปีที่แล้ว +2

    lezgooooooooooooooooooooooooooo thank u so much

  • @addmix
    @addmix ปีที่แล้ว +2

    Thank you. You actually cared to explain what each segment of code did. I was getting very frustrated trying to understand compute shaders, but this video helped me understand it better.

  • @thehattedhedgehog
    @thehattedhedgehog ปีที่แล้ว

    I can't figure out how to clean after submitting. The memory is bulking (Godot 4.1.1.stable)

  • @ZagrajmyzPszemkiem
    @ZagrajmyzPszemkiem ปีที่แล้ว +6

    A wonderfull tutorial! There is so little information about any of this online, it's great to see somebody taking their time to investigate what's possible.

  • @RyanForresterDev
    @RyanForresterDev 2 ปีที่แล้ว +2

    Great video, lots of stuff learned watching this! I'm hoping to have the time at some point to try a water shader using compute shaders and use the outputs for water physics.

  • @RyanScottForReal
    @RyanScottForReal 2 ปีที่แล้ว +2

    This is great, thank you. Would love to see what IS a more efficient way to do it. :)

  • @AgnisNeZvers
    @AgnisNeZvers 2 ปีที่แล้ว +1

    Killer video!
    I'm having doubts that Splatoons is used compute shaders for Wii U (Splatoon 1 in 2015) & Switch. My guess is that it's just a collision system + some approximate area calculation based on collision position.

  • @johanngambolputty5351
    @johanngambolputty5351 ปีที่แล้ว +1

    Ooh, do the compute shaders support doubles? I tried to do some fractal stuff in Godot before because of the ease of setting up ui and input, but you very quickly hit precision limits...
    Also, can it only do compute shaders through GL? How about OpenCL (would be nice since I've already written some OCL stuff now...)

    • @mezzofortestudios7342
      @mezzofortestudios7342 ปีที่แล้ว +1

      Currently the `RenderDevice` class uses only a Vulkan backend for compute

  • @Galomortalbr
    @Galomortalbr 2 ปีที่แล้ว +3

    hey, as much as i love the computer shader solution, i can't help but to feel it's over engineered, a simpler solution would had to been to use a viewport to downscale the 2048x2048 texture to 32x32 and then calculate based on that, could be done even in the main cpu thread without much of performance impact.
    it's obviously not fun solution but solves the issue without having to taxs the GPU or a entire thread, i still would like more content about computer shaders.

  • @JustVoylin
    @JustVoylin หลายเดือนก่อน

    My brain is basically fried right now xD

  • @Chevifier
    @Chevifier 10 หลายเดือนก่อน

    *Cuts off head to rub brain*😅

  • @nemene8585
    @nemene8585 ปีที่แล้ว

    How do you make the fancy operators, like merging >= and ==?

  • @indieology7336
    @indieology7336 2 ปีที่แล้ว +2

    Thank you!

  • @savhasuvhe
    @savhasuvhe 2 ปีที่แล้ว +1

    Can you do next anime shader?

  • @Barnaclebeard
    @Barnaclebeard 2 ปีที่แล้ว +1

    Beastly content, and appreciated

  • @MACMAN2003
    @MACMAN2003 2 ปีที่แล้ว +1

    would it be possible to take in an image and change the colors around a bit? like if i wanted to change color1 to color2?

    • @crigz
      @crigz  2 ปีที่แล้ว +1

      Yes, you can do something like that.

    • @MACMAN2003
      @MACMAN2003 2 ปีที่แล้ว +1

      @@crigz Do you have any idea on how to get started on doing that? Cause there's no documentation for compute shader stuff xd

  • @AbeTheApe126
    @AbeTheApe126 ปีที่แล้ว

    Out of interest, in the performance comparison. Is the CPU version completely single threaded? E.g. no usage of threads on the system etc? Likely you would still not get close to the gpu perf but it would make for a slightly more 'fair' comparison potentially.

  • @arez-dev
    @arez-dev 2 ปีที่แล้ว +1

    Very dope video! You definitely deserve more attention.
    It would be cool to see trails (particle trails or if there are other types of trails) explained, as i just cant get them working right!

    • @crigz
      @crigz  2 ปีที่แล้ว

      Cool idea! What in particular did you struggle to get right with them?

    • @arez-dev
      @arez-dev 2 ปีที่แล้ว +1

      @@crigz Somehow whenever i tried particle trails i couldnt get them to render properly. They always were a random mess of stretched triangles or whatever. Also sometimes they became super large or the actual particles didnt even render (just the trails, but those buggy)

    • @crigz
      @crigz  2 ปีที่แล้ว

      @@arez-dev is that in Godot 4.0? I had to scrap the splash particles I set up because they're currently so buggy in the beta.

    • @arez-dev
      @arez-dev 2 ปีที่แล้ว

      @@crigz Yep it is!

  • @leeuwarden20
    @leeuwarden20 ปีที่แล้ว

    Did you manage to draw a triangle with RenderingDevice?

  • @eigenman2571
    @eigenman2571 ปีที่แล้ว

    Super helpful! Thanks

  • @marc.lepage
    @marc.lepage ปีที่แล้ว

    Thinking of doing some non-game stuff in Godot 4 and this will come in very handy!

    • @marc.lepage
      @marc.lepage 7 หลายเดือนก่อน

      Just to say I have indeed been doing non-game stuff, now on Godot 4.2, and working on sharing my non-visual data (processed by compute shader) with a graphics shader without going through the CPU, so I can visualize the data but maintain framerate.

  • @prozacgodgamedev
    @prozacgodgamedev 2 ปีที่แล้ว +1

    I was watching your previous splatoon tutorial and was thinking of a way to get rid of the seams. Regardless of the way the texture is unwrapped.
    This would only work on a compute shader because of the search space, but it should be massively parallel.
    I'm not 100% sure how to do this. In blender is there a way to generate a texture that matches the XYZ coordinates of a 3D surface using the same unwrap as the painting texture.
    This would give you a texture where paint can be splashed, and a lookup table for all splashable surfaces in 3D.
    In this way, we have a texture that matches the unwrapped texture, but we have XYZ coordinates for the entire level.
    Then when a splash happens you feed in this texture, the coordinate of the splash and the output is a texture of said splash.
    The way it works is ... if a 3D texture lookup triplet is inside the 3d radius of this splash sphere, it would fill in the output texture with the splash color.
    This should work quite flawlessly.

    • @crigz
      @crigz  2 ปีที่แล้ว

      I'll have to look into this for sure!

    • @prozacgodgamedev
      @prozacgodgamedev 2 ปีที่แล้ว

      @@crigz Thanks, I hope my explanation was ... adequate!

    • @prozacgodgamedev
      @prozacgodgamedev 2 ปีที่แล้ว +1

      @@crigz I was looking into this myself and quickly realized you can easily paint through walls and backfaces, so there's a technical thing there to sort out. Seems similar issues would happen in your version too.

    • @crigz
      @crigz  2 ปีที่แล้ว

      @@prozacgodgamedev Painting through walls and back-faces aren't an issue in this system, it's mostly painting over into other UV's if you don't leave enough margin, and there's not a proper wrap around on corners unless you perfectly place the UV map (not always possible). I've got a few ideas I'm experimenting with to fix this though.

    • @prozacgodgamedev
      @prozacgodgamedev 2 ปีที่แล้ว +1

      @@crigz I'm setting up to attempt to build something akin to your splatoon level and a godot fps scene to attempt a real go at it. I'm not ... that well versed in ... well anything here, I'm winging it :D
      It'll be fun!