Geometry Shaders in URP - Plus how to create code shaders from shader graph

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

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

  • @jeffking2249
    @jeffking2249 4 года назад +9

    Fantastic tutorial!! Would love to see more complex tutorials using geometry shaders!

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

      Thanks! I'll see what i can come up with 🙂

  • @GameDevBill
    @GameDevBill  4 года назад +6

    Update for Shader Graph version 10.x (and URP version 10.x) - from Unity 2020.2+
    1. You no longer right-clicking on the master node to view the source. You instead select the shader graph, and inside its inspector hit the button "View Generated Shader"
    2. If you take a code shader from SG 8.x, it will not run in SG 10.x. But, if you follow all the steps in this video again, it will work. There are just some differences in the parts of the generated file we don't touch that will need to be updated by URP itself.

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

      Great tutorial, was hoping to get the file for this custom shader to do a diff with a "blank" shader to see where the code goes as it's real easy to misplace the code insertions, a problem exacerbated by the poor support for HLSL in any given IDE inc. Rider.

  • @deusxyz
    @deusxyz 4 года назад +1

    These videos are really high quality content. This is the stuff i've been searching for. Good ole reddit.

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

      thanks for the kind words :)

  • @ChronoWrinkle
    @ChronoWrinkle 11 месяцев назад

    Awesome! also(if im not mistaken) you can just feed vertices to triangle strip and it will produce triangle for each new vertex after 3rd, hance triangle strip

  • @travisotwell4747
    @travisotwell4747 4 года назад +4

    I'm glad you found your glasses! Those are important

  • @daslolo
    @daslolo 4 года назад +1

    You make it sound so easy. Subscribed

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

      thanks :)

    • @daslolo
      @daslolo 4 года назад

      @@GameDevBill Something I really want to know is: can you make a mesh node? That would totally make life easier

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

      @@daslolo That would be awesome! I haven't thought of a way to do that yet, but if I do I'll be sure to post about it :)

  • @jakkos-net
    @jakkos-net 4 года назад +2

    Really great tutorial, you really deserve more views! Would love an example of using geometry shaders for grass that you mentioned :)

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

      Thank you for the kind words! Yes, grass would be good. I'll put it on the list. :)

  • @peterparkerr
    @peterparkerr 4 года назад +1

    Amazing tutorial, simple and direct. Thanks for shared.

  • @MortalVildhjart
    @MortalVildhjart 4 года назад +1

    Ah yes, top shelf stuff! This was great. Thank you!

  • @GameDevBill
    @GameDevBill  4 года назад +4

    This Random But Related Quote of the Week comes from Schoolhouse Rocks:
    _Every triangle has three corners_
    _Every triangle has three sides_
    _No more, no less, you don't have to guess_
    _When it's three, you can see_
    _Its a magic number_

  • @nyandash69
    @nyandash69 9 месяцев назад

    THANK YOU VERY MUCH!!!

  • @ThomasChen-ur2gt
    @ThomasChen-ur2gt 4 года назад +1

    This is great, thank you for making it

  • @mikhailhumphries
    @mikhailhumphries 7 месяцев назад

    I'm trying to make geometry shader that shows quads when editing for a 3d modeling software I'm developing. I tried multiple shaders from github but they revert to tris when editing mesh.

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

    Awesome stuff!
    If I wanted to do a dissolve effect for a low poly game where the object is "turned inside out" by gradually rotating every single triangle 180 degrees around some vector orthogonal to the (original) normal, would a geometry shader be the way to do that? Apart from the normals, what would I need to change in the vertex outputs? The world space coordinates?

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

    Amazing tutorial!!

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

    I have been using this for grass in hdrp but with latest versions it has stopped working and it may have to do with how packed varyings are different in code shader now. The first 2 passes seem to require different geomdata and geom than the rest but I can't quite figure it out.

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

    Fantastic tutorial, thanks for your work!

  • @soundrraj3880
    @soundrraj3880 4 года назад +1

    thanks for the info ! and I have a Q : is the zombie being sad for loosing his hand or his balloon ?

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

      Ha! You know, I assumed it was the balloon, but it's hard to say for sure :)

  • @deusxyz
    @deusxyz 4 года назад +1

    Hey! As for specific things I want to do with shaders, I would like to know if its possible to do a voxel model with geometry shaders, or for general shaders, I would like to pass in bone transforms so I can calculate that in the shader. Atm I'm doing all this on the CPU. Particularly the bone calculations and mesh updating every frame is too heavy! (As unity ECS did not have animations a year ago so I implemented my own)

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

      Voxels & Geometry - It can be done, but I'm not sure about the efficiency. My main concern would be the cost of feeding all that data in. hmm. I don't have a good answer here.
      Bones - this should be a lot easier with some caveats... maneuvering the verts is something a vertex shader should be good at, but then you have to deal with normals. I don't have a video yet (soon?), but I do have a written post on re-calculating normals inside a shader graph gamedevbill.com/shader-graph-normal-calculation/. Or you can use a geometry shader as described in this video to recalculate them. The other caveat is that data transfer. It can be costly to transfer TONS of extra data into a shader each frame, so that's just something to keep in mind. All in all, there's a good chance that this will have better performance in a shader than in C#, but it's not an obvious winner (to me). It could go either way depending on implementation details.

    • @deusxyz
      @deusxyz 4 года назад

      @@GameDevBill Ahh I recall the cost can be pretty high for thousands of vertexes being uploaded per frame so for voxels itll be pretty high too! But If i restricted it to just characters I think.. least i could make a cool boss fight haha
      Hmm I might try to write a shader then for bone animations! It's just a transform matrix multiplied by original vertex, while I reupload the bone transforms every frame to the shader! :)
      Thank you again looking forward to more of your videos!

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

    hi~ great tutorial! How would you do a fur shader on the URP for mobile / VR application? something really performant that can run on mobile.

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

      fur in VR! that would be awesome. I'll add it to my investigation list, but generally to do fur on mobile VR you'll want something super stylized, so it can be non-realistic and thus cheaper to render. If I can come up with something I'll make a vid on it!

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

    Could you do the same for the HDRP pipeline. I cant pass the part where you fill the GeoData, cant find those variables.

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

      thanks a lot for this tutorial, its so hard to find doc or examples on to customize UDR or HDRPm in my case i would like to see this on HDRP also how can we use Structured buffers from compute shaders to affect geometry or even just particles, the tricck of generating the shader code is really a game changing, always felt so limited with HDPR because i cant customize anything . Anyway would love to see more stuff like this

  • @slowswift_I
    @slowswift_I 4 года назад

    I would really like to see a tutorial on making a low poly water shader.

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

      Good idea. Thanks for the suggestion!

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

    What an epic and sooo sooo good tutorial im gonna watch all a big like to you

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

      Thanks for the kind words :)

  • @yankeshi5983
    @yankeshi5983 4 года назад

    i do the same work in geofromgraph shader,but it unwork and show tips(Shader warning in 'GeoFromGraph': Program uses geometry shaders, treating as if '#pragma require geometry' was present at line 72),is it the problem about verson(2019.4.1f1)?

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

      I'm not sure I understand the issue. You can add details here, or if it's easier to use an actual forum, reply to this thread on the Unity forum here: forum.unity.com/threads/gamedevbill-tutorial-comment-thread.945515/
      With some more details, I can see how I can help. Perhaps attach the entire shader file to that forum thread.

  • @almost_everything
    @almost_everything 4 года назад

    I do want to remove some mesh from a model, can we have it using geometry shader, say I am generating a avatar character based on image, it is generating till shoulder, but i do want till neck portion, since i am attaching it with my headless avatar.

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

      That's possible, but remember that geometry shaders are going to be run every render frame. So if this is a relatively static thing, having it in a pre-baked mesh is more efficient than generating it every frame. Geometry shaders are most useful for dynamic things. Now, if you are using the shader to make a seamless neck connecting two objects that are moving (body and head), then perhaps it would make sense to use this technique.

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

    So with this method could I extend my shader graph shader to use tessalation if I implement hull and domain?
    I was always affraid of coding shaders that's why I always used shader graphs and avoided coding shaders.

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

      I'm like 82% sure that will work. Very curious to hear results if you try it out!

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

      @@GameDevBill I will, but it could take sometime as it's not top on my todo list.
      This video was really eye opening for me, it opened up bunch of possibilities, thank you!

  • @mrx10001
    @mrx10001 4 года назад

    Does Amplify Shader Editor have Geometry shader support in its node system?

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

      I honestly don't know, though I'm mostly sure the answer is "no". I'd guess you could do something similar to the above technique, but I also don't know if Amplify lets you generate a code shader off of a node graph.

  • @chris.davidoff
    @chris.davidoff 4 года назад

    What would be different for HDRP? I'm assuming that may be a long winded answer..

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

      Well, I'm not 100% sure. I did a quick test, and HDRP does seem to generate a very similar shader file. That being said, HDRP doesn't quite have the same platform compatibility that URP has, so I'm not sure what gotcha's you'd run into if trying this more in depth.
      In short, "probably the same in HDRP, but I'm not sure".

    • @chris.davidoff
      @chris.davidoff 4 года назад

      @@GameDevBill Interesting! I'll have to give it a shot. The practice of taking idea to.. shader.. is a challenging concept thus far

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

    Yes ther one thing i want to how to create i real time refletion on urp sheder and how to create billboard

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

      Good suggestions. I'll put those on the list of future tutorial ideas!

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

      @@GameDevBill ok thenx

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

    That's good content :D thanks.

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

    I have too many passes. Generated shader has 8252 lines

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

    Ha! Very cool.

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

    I think it is bad idea to teach basics of Geometry shader beginning with code generated from Shader Graph. Why don't you just use simple HLSL code (vertex + fragment), and add geom function to it ?🤔