How to calculate Normal Vectors in Shader Graph

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

Комментарии • 46

  • @kyleemery175
    @kyleemery175 10 месяцев назад

    Awesome information here! Thanks so much for this!!

  • @simondev758
    @simondev758 3 года назад +3

    Did you have to actually make the hat, or was it just a consequence of working in a gamedev office?
    Btw, great explainer on normal generation!

    • @GameDevBill
      @GameDevBill  3 года назад +1

      Lol, I've definitely been hit in the head more than a few times during nerf wars. Thanks for the feedback :)

  • @snowman1722
    @snowman1722 3 года назад +1

    Great tutorial!
    If you've got a fairly complex vertex distortion with several nodes, is there a way to recalculate at the end, rather than having 3 duplicate node trees? Thanks!

    • @GameDevBill
      @GameDevBill  3 года назад

      Well, it's possible, but depends on what your distortion logic is doing. In some cases, there are math formulae that are better to use than my technique in this video. Those are generally very complex, and require a deep understanding of the math behind your distorion.
      The more straightforward case is if some chunk of your logic does not invalidate the normals. For example, if the first bit of your logic just adds Y to the position, then you can do that before calculating neighbors. Or if the end of your logic does something similar, then you could recalculate your normals early, before finishing the position transformation.
      All in all, this technique is set up to be generic and somewhat brute force. The benefit is that it'll almost always work. The downside is that it is hard to optimize.

    • @snowman1722
      @snowman1722 3 года назад

      @@GameDevBill in your example, the distortion is caused by a math set up. A real cool one at that. I'm driving my distortion with voronoi noise planner plus a 2D LOD texture, and subtracted by another texture mask. So there are a few different items involved, and of course the result is distorted geometry that doesn't shade according to the distorted normals. I tried to use your nodes at the end of my tree but it didn't work, I'm assuming because it needs to be placed before the distortion? I'm wondering if I can take the final output of my vertex displacement, and offset that output?

  • @naileye900
    @naileye900 Год назад +3

    This tutorial is a gift to the world. Many thanks!

  • @bridget4148
    @bridget4148 2 года назад +3

    This was super helpful!! It's a damn shame you don't have more subs, you deserve them. Thanks so much!

  • @erikm9768
    @erikm9768 2 года назад +1

    Great videos, but please consider not overlaying your portrait when showing shader graph or code etc especially when covering relevant areas

  • @dirkboercom
    @dirkboercom 6 месяцев назад

    Damn, this stuff is crazy! Thanks a lot!!

  • @marcinsanatares5668
    @marcinsanatares5668 2 года назад

    I tried in Godot but I don't understand :(
    vec3 normal = NORMAL; //??
    vec3 point = NORMAL; //??
    vec3 position = VERTEX; //??

    float d = normal.x * point.x +
    normal.y * point.y +
    normal.z * point.z;
    (...)

  • @immeasurability
    @immeasurability Год назад +1

    GameDevBill, Hello Hello! I try to use this for shape deform for my characters in the game but cant get correct result, like the shape normal not recalculated and i have wrong normals result as it work by default. How recalculate normals for the shape deform?

  • @towyan8187
    @towyan8187 2 года назад

    Man, great tutorial. Super helpful and selfless. But I think you should have a better name for the title. It's too "humble" for you to name like this. I literally thought it's an beginner level tutorial which just talks about normal node. You should mention "after deform" to get more views IMO.

  • @AlanZucconi
    @AlanZucconi 3 года назад +3

    That's great! 👏

    • @GameDevBill
      @GameDevBill  3 года назад +2

      Thanks for the kind words Alan!

  • @geri4367
    @geri4367 3 года назад +2

    Bill walking around with his hat covered in nerf dats: "What are you all looking at? It's a perfectly normal hat"
    Keep the amazing content up, I'm learning and enjoying it a lot :D

    • @GameDevBill
      @GameDevBill  3 года назад

      "perfectly NORMAL hat".... normal...
      Thanks for the kind words, and the intentional or accidental normal pun!

  • @Khytau
    @Khytau 3 года назад +2

    Hey, great video, results are stunning, thanks !
    I had a hard time figuring out how from a plane orthogonal to the original normal, we could ever get a different normal resulting of cross product of vectors made from the neighbours on the already orthogonal plane.
    It turns out we apply the transformation on neighbours as well, the written tutorial helped me to figure out I missed that step in the video.
    Thanks!

    • @GameDevBill
      @GameDevBill  3 года назад

      Glad you got it worked out! I try to keep the videos high level and the write ups more detailed, but sometimes am too far one way or another. Just glad you got to the solution :)

  • @ElSenorEls
    @ElSenorEls 3 года назад +2

    Thanks! The real life "hat + nerf darts" example made it really clear.

  • @lucyboydwilson
    @lucyboydwilson 3 года назад +2

    This is awesome! Thank you so much!

  • @igorov3d331
    @igorov3d331 Год назад

    Glad I found this ....but using these two subgraphs has no effect on my normals. is this really usable also for terrain-like meshes with more complex geometry?

  • @Chris-jo1zr
    @Chris-jo1zr 9 месяцев назад

    Sweet jesus man this is helpful, the number of vertex shader things out there that don't even mention normals is upsetting.
    This is massively helpful stuff.

  • @JeffEnriqueJohnson
    @JeffEnriqueJohnson Год назад

    Thank you very much. Unlocked some ideas for my shader. 🙏

  • @MikeCroswell
    @MikeCroswell Год назад

    That neighbors subgraph looks amazing - so much to learn from! Thank you!

  • @marcellrideg2965
    @marcellrideg2965 Год назад

    Thanks for the tutorial! Is there any way to recalculate the normals when the source of displacement is a texture map?

  • @stevphiericardo2790
    @stevphiericardo2790 Год назад

    Pls continue making videos dude!...

  • @Zraune
    @Zraune Год назад

    Thanks man, I was a bit lost on that one.
    Very helpful

  • @rgclube6672
    @rgclube6672 3 года назад +1

    Cool video thank you for the effort!

  • @yuhochih
    @yuhochih Год назад

    Useful tutorial, thank you so much

  • @MikolajF
    @MikolajF 2 года назад

    that is interesting. I must try this method in UE.

  • @getarobo
    @getarobo 2 года назад

    little late but you are awesome!

  • @fogzheng2717
    @fogzheng2717 2 года назад

    Great tutorial! easy to understand

  • @chadjosewski8460
    @chadjosewski8460 3 года назад

    My shape is totally jacked. Noob issues... how to get the transform of the object at 0,0,0?

    • @GameDevBill
      @GameDevBill  3 года назад +1

      I'm not totally sure I understand the question. If you are saying that your model isn't centered around 0,0,0, but you want to do some math that, say, moves things outwards. So you want to figure out where the object-space 0,0,0 is, right?
      There are a few ways to figure this out, the most straightforward is to feed object-space position into the color output of your master node. If everything is black, then the position is negative, and you need to do a one-minus to figure things out. If it's full brightness on one or more color channels, then you can divide to work out scale (maybe the feet are at 0,0,0, but the head is at 0,100,0, so you need to divide the Y by 100 to see a color gradient)... or subtract if it's too high. All in all, this is a guess and check method, but it'll help you visualize through the shader how the coordinates are getting fed in.

    • @chadjosewski8460
      @chadjosewski8460 3 года назад

      @@GameDevBill this helps! Thanks!

  • @slash7076
    @slash7076 2 года назад

    Very cool 👍😊

  • @Cara.314
    @Cara.314 3 года назад

    Really nice video! The info on your website vanished though :(

    • @GameDevBill
      @GameDevBill  3 года назад

      Ugh, it is broken. Thanks for the heads up. I'll try to get that back up and running today or tomorrow.

    • @Cara.314
      @Cara.314 3 года назад

      @@GameDevBill looks like you got it now, Thanks a lot! :)

    • @GameDevBill
      @GameDevBill  3 года назад

      yeah, I just got it back up! Hope it helps :)

  • @Maufdiot
    @Maufdiot 3 года назад

    You are an absolute Legend !