Learn GODOT 4 Compute Shaders with RAYTRACING!!

Поділитися
Вставка
  • Опубліковано 26 чер 2024
  • Source Code:
    github.com/nekotogd/Raytracin...
    List of people in the video (in order of appearance):
    ‪@NagiDev‬
    ‪@mohsregTV‬
    ‪@leonstansfield‬
    ‪@fabianvelander‬
    also technically ‪@Acerola_t‬ ?
    Intro Background from ‪@Gamescapes‬ :
    • Sunrise at the Temple ...
    David Kuri Raytracing Articles:
    blog.three-eyed-games.com/2018...
    Memory Qualifiers and Atomic Functions:
    www.khronos.org/opengl/wiki/S...
    Scratchapixel Cow Mesh Raytracing:
    www.scratchapixel.com/lessons...
    Official Minimal Compute Example by Clay John:
    github.com/godotengine/godot-...
    Conway's Game of Life in Godot 4 with Compute Shaders:
    github.com/snailrhymer/Comput...
    Support me on Ko-Fi!
    ko-fi.com/nekoto
    List of music in order:
    Eve - Last Dance
    Persona 3 - Iwatodai Dorm
    Legend of Zelda: Wind Waker - Dragon Roost Island Theme
    Ace Attorney Investigations - Pursuit: Lying Coldly
    Persona 5 - Life Goes On
    Legend of Zelda: Breath of the Wild - Korok Forest (Night)
    Phoenix Wright: Ace Attorney - Jingle
    Persona 3 - During the Test
    Eve - Dramaturgy
    Persona 5 - Wake Up, Get Up, Get Out There (Instrumental)
    Outro Song is made by me
    References:
    Kuri, D. (2018, May 3). GPU Ray Tracing in Unity - Part 1. Three Eyed Games. blog.three-eyed-games.com/2018...
    Möller, T., & Trumbore, B. (1997). Fast, Minimum Storage Ray-Triangle Intersection. Program of Computer Graphics. fileadmin.cs.lth.se/cs/Person...
    Scratchapixel. (2014, August 15). Ray-Tracing a Polygon Mesh (Ray-Tracing a Polygon Mesh (Part 2)). www.scratchapixel.com/lessons...
    Whitaker, R. B. (2009, January 21). Creating a Specular Lighting Shader. RB Whitaker’s Wiki. rbwhitaker.wikidot.com/specula...
    Chapters:
    0:00 Intro
    1:06 Introduction to Compute Shaders
    1:28 Regular Shaders vs Compute Shaders
    1:55 Why even use a Compute Shader?
    2:43 How do Compute Shaders work?
    4:05 Creating a Compute Shader
    4:22 Storage Buffers
    5:29 The "main" function
    6:08 Binding the Compute Shader in GDScript
    7:36 Raytracing Theory
    9:48 Anime OP
    10:02 Improving the Raytracer
    11:03 Implementation Caveats
    12:07 Some other uses for Compute Shaders
    12:15 Outro
  • Навчання та стиль

КОМЕНТАРІ • 144

  • @NekotoArts
    @NekotoArts  Рік тому +13

    Theres a small error at 5:42
    To read and write data you use "image_out.data[some_index]".
    Think of it as a struct named "image_out" and you're accessing the "data" variable inside the struct.

    • @ARCAD3BLOOD
      @ARCAD3BLOOD 7 місяців тому +1

      You talk about gles if I understand correctly, but how about vulkan?
      Can you raytrace with vulkan in godot?

    • @NekotoArts
      @NekotoArts  7 місяців тому

      @@ARCAD3BLOOD This tutorial was made using Godot's Vulkan backend. As far as I know compute shaders aren't supported by Godot's GLES backend

  • @Acerola_t
    @Acerola_t Рік тому +43

    I sure do love compute shaders

    • @Acerola_t
      @Acerola_t Рік тому +7

      also I followed the same tutorial series 2 years ago. Great resource! glad you adapted it for godot

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

      @@Acerola_t ikr! David Kuri's raytracing articles are a goldmine of knowledge

  • @LucyLavend
    @LucyLavend Рік тому +43

    Bro popping off with the editing!! I'm now going to take a couple of days to mentally process all of the info that was pumped into my brain

    • @NekotoArts
      @NekotoArts  Рік тому +8

      Oh pshhh... I just binged editing tutorials for a few hours that's all.
      Also I will continue pumping shader knowledge into you >:) I will turn you into a shader God!!!

    • @LucyLavend
      @LucyLavend Рік тому +4

      @@NekotoArts shader big brain time let's gooooo

  • @mohsregTV
    @mohsregTV Рік тому +16

    Honestly your best work yet. Good job Nekoto 💟

  • @Ombarus
    @Ombarus Рік тому +4

    Amazingly well presented and very useful info!

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

    This is my new favourite video about Godot it is so good. Well done neko!

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

    Great info and solid editing - you gotta make more of these my man! Truly amazing job.

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

    Wowza that was really good! It has to be your best video yet. Well done!

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

      Thank you Kevin!! I'm quite happy with how this one turned out too!

  • @marc.lepage
    @marc.lepage 3 місяці тому

    Actually a decent explanation, thanks!

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

    soo well made!

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

      Thank you!! I'm glad you like it, it took quite a while to edit

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

    my brain started logging out when all the math formulas came up on screen 💀

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

      LMAO. I had to read the Wikipedia page like 6 times to get it as well, and I'm studying an Engineering degree XD

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

    your vids are the bomb!

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

    thanks very useful !

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

    Nice video! I've been looking forward to compute shaders on Godot for ages, so I'll be s̶t̶e̶a̶l̶i̶n̶g̶ borrowing your expertise!

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

      Your comment reminded me that I forgot to add a license to the repository. All the code is CC0, so feel free to steal as much as you need :)

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

    After I sussed out compute shaders I was wondering how to implement raytracing!
    Epic editing btw mate, I need to learn to edit like this for my videos 👀

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

      Oh hey! I saw your video halfway through editing, I really appreciate that you took the time to explain texture uniforms too!!

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

    I can't even comprehend the work went into making this!

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

      Editing this one took quite a while! Thank you for appreciating the editing :D

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

    Thanks. Complex, but good reference.

  • @WiLDbEAsTGameSHere
    @WiLDbEAsTGameSHere 7 місяців тому

    Yay! you gained a.. new subscriber 🎉

    • @NekotoArts
      @NekotoArts  6 місяців тому +1

      Thank you so much!!

  • @qubitx64
    @qubitx64 Рік тому +6

    You have my "Raytraced" respect. Great introduction to compute shaders.

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

    Wow this video is amazing and you are funny. Very well made and fun to watch video.

  • @jordan.rushing
    @jordan.rushing 9 місяців тому

    My brain melted, nice job

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

      Mine melted as well when I had to code this project 😵‍💫

    • @jordan.rushing
      @jordan.rushing 9 місяців тому

      @@NekotoArts I legit cannot fathom trying to do what you did here.

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

    Watched this twice. First time was entertained. Second time was educated. Thank you.

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

      Thank you! I like to have fun while teaching, otherwise it gets boring to teach. Glad you enjoyed the video!

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

    i know nearly nothing about computer science and can barely use godot, but i watched this video all the way through and thoroughly enjoyed it! i'm definitely not qualified to say that you did a good job in terms of accuracy or whatever but you definitely did a great job entertainment-wise :)

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

      Thank you so much! I try to keep things light hearted and fun when teaching, otherwise it gets boring to learn anything.

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

    Aqesome that you also know Acerola. I discovered him this year and his content is awesome. (yours is also really nice)

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

    this video was Junferno meet Acerola meet Godot and i love it

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

      Hehe, they were both inspirations for me

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

    My answer to that question somewhere before middle or so is "No, I don't know". ;)
    It's a nice video, I didn't catch about anything if I'm not wrong. xD

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

    It's like acerola but for godot! And I mean that as a compliment!

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

      Haha thank you! I love Acerola's videos.

  • @dialectricStudios
    @dialectricStudios 9 місяців тому

    amaing

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

    Quality

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

    Who is this Nekoto and what has he done with my friend? Seriously though love the content my guy it's so impressive, love the editing and finally love you too!!

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

    thank you for the tutorial, there is sure quite some boilerplate needed to get it running. somehow godot likes to crash every now and then, unsure if it is realated to my compute shader usage... still, they are fun!

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

    Hi!
    What musics are you using in the video? And, I don't know if it's just my problem, but aren't they a bit too high?
    Thank you!

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

      List of music in order:
      Eve - Last Dance
      Persona 3 - Iwatodai Dorm
      Legend of Zelda: Wind Waker - Dragon Roost Island Theme
      Ace Attorney Investigations - Pursuit: Lying Coldly
      Persona 5 - Life Goes On
      Legend of Zelda: Breath of the Wild - Korok Forest (Night)
      Phoenix Wright: Ace Attorney - Jingle
      Persona 3 - During the Test
      Eve - Dramaturgy
      Persona 5 - Wake Up, Get Up, Get Out There (Instrumental)
      Outro Song is made by me
      Also yes, someone else also mentioned that the music might be bit too high. I'll lower it next time

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

    THe shader god has return on its glory!!!! Awesome video btw, sad I didnt understood anything xDDDDD just kidding, something I learned here, but Acerola reference I got it!!! a funny story about how I found him: I was surfing on youtube, watching brazilian videos, then youtube recomended me a shader video from acerola, at first I tought it was a brazilian because "Acerola" in portuguese is a name of a fruit LOL!

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

      Hey! Glad you learned something! Acerola's channel is super awesome, I'm glad you got the reference. I didn't know it was a fruit in Portugese!

  • @faru-music
    @faru-music Рік тому +2

    Made me laugh several time. Hope you didn‘t lose a (cat)life during the research 😉

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

      FaRu!! Thank you so much! Learning about raytracing was quite fun, I think my implementation is still incorrect but I'll fix it soon

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

    Well, now I feel stupid. Still really cool stuff!

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

    LET'SA FUCKING GO ACEROLAAAAAAAAAAAAAAAAAAA

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

    Theres not yet a way to pass the buffer straight to the main rendering device is there? Having to readback to the CPU really limits some of the cool stuff you can do.

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

      Yeah :/ that's whats limiting us from doing indirect rendering using compute shaders right now.
      AFAIK, it is a planned feature though. So eventually we will be able to do that too!

  • @WeirdBrainGoo
    @WeirdBrainGoo 24 дні тому

    Can you use glsl files in Godot natively? If not, it would be great if you mentioned how to get them to work. Sorry if it's a dumb question, I'm new to shaders.

    • @NekotoArts
      @NekotoArts  24 дні тому

      There is no such thing as a dumb question!
      Basically, in Godot 4 the .glsl files are used only for storing compute shaders (at the moment), and all other shaders are stored as .gdshader or .shader files. However, all shaders written for Godot (compute, vertex, fragment, etc.) are written in GLSL.
      Hope that helps!

  • @_vofy
    @_vofy 7 місяців тому

    "Invalid pipelines cache header" when creating rendering device. Any ideas?

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

    How do you animate those math equations? Its so smooth.

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

      Its from the open-source python library made by the math UA-camr 3Blue1Brown! Its called "Manim", you can check it out here: docs.manim.community/en/stable/
      P.S. Little helper note to get you started that gave me a big nightmare when setting this up. "Manim community" edition is a completely different thing from just "Manim", make sure you setup the community version

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

      @@NekotoArts Oi thanks!😊

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

    This is amazing.......Ill stick with fragment and vertex shaders😂

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

    music so loud i can barely hear you

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

    What fps you've achieved? Have you done any optimization?

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

      Rendering the spheres gives me 60 FPS no problem. Like I mentioned in the video, I've optimized the shader for warp sizes of 64 plus I tried to write generally efficient code

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

    Hey I see a fellow Eve fan right here! Also, Godot 4 looks lit!

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

      Hello!!! I'm new to Eve's music, the only one I knew before was Kaikai Kitan but recently I've been listening to more!
      When I heard Dramaturgy and Last Dance I just knew I had to put them in the video hehe

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

      @@NekotoArts That was me half a year ago, I have listened many of his songs (not even close to finishing his playlist.) If you find any confusion which song u want to listen first, go with the more popular ones, they are popular for a very good reason.

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

      @@extremehyperventilation4377 thank you! I'll listen to those ones then!

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

      @@NekotoArts and, another thing, I am just a 17 year old student prepping to get into college, so u can drop the formalities since u are technically older.

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

      @@extremehyperventilation4377 good luck on your college applications! I will still use formalities with you though :D

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

    my brain hurts

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

      Me too ;-; I took months to get the raytracing working

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

    I have a maybe stupid question but I don't understand why we use compute shaders for raytracing. Don't fragment shader fire for each pixel? Wouldn't that be a better candidate? I'm a total noob when it comes to shaders but it's something that's been bothering me for a while.

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

      That's not a stupid question at all! While there are implementations of raytracers that use only fragment shaders, using compute shaders actually unlocks a few extra benefits for us.
      Namely: the ability to pass multiple variable size arrays to the shader (with fragment shader it has to be fixed size array), and also the ability to communicate between shader invocations (impossible to do in fragment shader).
      On top of that, in Godot you currently cannot use custom structs as uniforms for a fragment shader, but compute shaders allow us to use structs in the storage buffers.

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

      @@NekotoArts Hi and thanks for answering! Ok so it would still be perfectly possible with fragment shaders, simply way less convenient to do so, got it! Thanks!

  • @awesomedude70
    @awesomedude70 7 днів тому

    What's the benefit of writing your ray tracing shader in a compute shader over a vertex shader operating on a mesh like a box? It seems quite a bit simpler, but I guess I'm imagining it's not as flexible as the computer shader method.

    • @NekotoArts
      @NekotoArts  6 днів тому

      Apologies, I'm not sure I understand your question. Vertex shaders are not designed to do any kind of path tracing / ray tracing calculations at all.
      Vertex shaders run once for every vertex on a mesh, but raytracing requires you to compute the path of a ray for every pixel on your screen.
      Also vertex shaders output vertex information like vertex position and normal information. But for raytracing you need to find the final color on screen after all physical effects have been applied to the ray.

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

    Wouldn't a fragment shader work just as well for this?

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

      If Godot supported uniform structs and variable size uniform arrays then yes, you could probably just do this with a fragment shader.
      I think raytracing is a good way to showcase compute shaders though. It seems that many people use raytracing as an example for compute shaders too.

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

    Can you link the original video for the stylized bush, at 1:34, Thanks!

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

      It's a screen recording I took for this project: github.com/FaRu85/Godot-Foliage

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

      @@NekotoArtsThanks you so much for anwsering! I'm new to Godot and 3d gamedev. Can I download the bush project from Github and import it into Godot 4, or is the link not about that? I'm not sure what Github actually does tbh. I see a bunch of files, but not a download link.
      You said you took a screen recording for the project, did you make a video of it here on youtube? If not, would you consider making one? I would love to learn how to create those beautiful Ghibly Studio stylized trees and bushes. I searched around, but all the examples are for Unreal Engine and unity.

  • @-Name-here-
    @-Name-here- Рік тому

    I’m 10 minutes in and you’ve completely lost me 😂
    I am just barely starting to grasp godot shaders normally so they make a bit more sense and it’s not just me randomly coding till it works, so this is way above my head right now

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

      Compute shaders are universal - they could do whatever you want them to do!
      The drawback is that they are MUCH harder to work with xD
      Stick to fragment(also known as pixel) shader and vertex shader for now - they would serve you well for a very long time before you would even need to touch compute shaders at all ;-)

    • @-Name-here-
      @-Name-here- Рік тому

      @@igorthelight yeah lol

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

    i'm trying to make a compute shader that modifies image pixels, but i cant get it to work... could you tell me how?

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

      I actually wrote an article on exactly how to do that, as well as reading textures from compute shaders: nekotoarts.github.io/teaching/compute-shader-textures
      Hope that helps!

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

      @@NekotoArts thanks!

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

      @@NekotoArts i have one question: what is the difference between a image2D and a sampler2D?

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

      @@pvini07BR you can write out colors and read colors from an image2D, but you have to access all the pixels of the inage2D using integer coordinates / texel coords.
      A sampler2D is only for reading a texture and comes with multiple sampler types, mipmaps, and filtering. You read samplers using UV coords.

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

    Sheesh Godot youtubers are getting huge these days!

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

    I'am absoluetly unable to focus on the actual content becasue of the J-RPG music in the background. But I'll get over it someday, I'm sure.

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

    The zoomer editing.... :D
    (^._.^)ノ

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

    @NekotoArts Hey Nekoto, is it alright if I ask you a question about shader optimization for mobile? What's the best way to contact you?

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

      Yeah of course anytime! Discord: Nekoto#2266

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

    Fun video! You really stuck it to Twitter! 😐Now do one for GPU based cloth sim...pls...

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

      Haha, perhaps I could try that in a game sometime. If I ever get around to doing it I'll make sure its in a video!
      Still have to finish up that other article I promised Twitter I'd make though

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

      Ok, cool.👍

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

    8:33 The reason is the that the feature is too new :>

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

    Hey, what anime is that 1:55?

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

      Ore Monogatari Episode 6.
      More importantly, what song is being played at: 02:43?

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

      @@Omnibus4Everyone Thanks!. It is Ace Attorney Investigations - Pursuit: Lying Coldly, it says so in video description.
      Most importantly 0:20, what is an Idoit?

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

      @@zenzen4982 Idoit would be referring to me :)
      More importantly, what was I going to say at 1:02 ?

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

      @@NekotoArts Ebola (/ω\)

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

    dang.. i mean, i am a software engineer and always had outsmarted my teachers, friends and surroundings since I was a kid.. but when it comes to the complexity of shaders especially raytracing, I feel like a special dummy ;))

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

      I think compute shaders are one of the hardest ones (as far as I know).
      One small advise: don't be discouraged when you didn't grasp something momentarily - it's totally ok to repeat and retry something a few times. Human brain has it's limits, so the harder the question - the more often you would hit it's limitations.
      It's totally fine!

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

    AAAA bro it seems like u is Indian cuz the accent is a lil similar am I mistaken?

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

    Are you some kind of a son of ElectroBOOM? Your editing and style is exactly like his. ^^

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

      HAHA omg, yes I love ElectroBOOM's channel!! I guess his style has really rubbed off on me.
      Is it really that noticeable? I'm surprised! Your comment made me smile :D

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

    Now let Godot RT by default 😂

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

    8 cores can crunch only eight pixels at any given time? That's utter nonsense? What about pipelining? SSE? AVX? Don't exist?

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

      Fair point!
      Still, not as much as GPU could ;-)

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

    bro you just stole the main music theme acerola

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

    wtf

  • @user-in4ij7cs1z
    @user-in4ij7cs1z 4 місяці тому

    "Compute Shaders" huh... How can you call them "compute" when they can't even "compute" GLSL version of FastNoiseLite, it freeses the entire engine at `compute_list_begin` call... Guess I have to split GLSL FastNoiseLite into sub-shaders, to make it work as expected, and not ruin the system...
    Compute Shaders are good at computing simple paralel tasks, but can ruin everything if task is too hard to complete...

  • @flannelbeard4621
    @flannelbeard4621 9 місяців тому

    Few seconds in and a BLASPHEMY - unnecessary. Absolutely ridiculous.

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

    content is ok, but too much cringe

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

    I never tryied Compute Shaders so It's even better moment to start with.. but.. what does mean that "gl_GlobalInvocationID.x" on reading writing data to buffers? If there is x on end then there would be y or z in other scenerious? Or its just stupid Shader thingy that nobody knows why but everyone do it the same?

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

      As far as I understand, it's a Vector3. So any Vector3 MUST have 3 parameters. X, Y, and Z are their "default" names. They are not always represent actual coordinates. Same with Vector4 and RGBA - if that's a color, then those floats represent Red, Green, Blue and Alpha. If that's not a color - those are just four float with default names.

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

      Like @IgorTheLight mentioned, gl_GlobalInvocationID is a Vector3, its basically the global position of the current invocation.
      Now, imagine I dispatch a compute shader with the dimensions (8, 1, 1). That means there are 8 invocations lined up in a row on the x-axis.
      So, when I read or write using "data[gl_GlobalInvocationID.x]", I'm basically accessing an array from whatever my current x-coordinate is! Since the invocations is just a line of 8 invocations as mentioned earlier, we're basically just accessing the first 8 elements of the array!
      Hope that helps!

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

      @@igorthelight hi! This is correct. gl_GlobalInvocationID is a uvec3 (basically means its a Vector3 where all of the values are positive integers).
      It represents the global coordinate of the current invocation we are working on, so if my shader says that the invocation size is (8, 1, 1) for example, that just makes a 1D line of 8 invocations.
      Using gl_GlobalInvocationID.x then allows us to access the first 8 elements of the array in our shader!

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

      @@NekotoArts ooh.. Ok now.. this actually makes a lot of sense to me Big thanks ;D

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

      @@bartusew764 glad I could help!

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

    disliked