Search Unity

Shader Learning?

Discussion in 'General Discussion' started by mbarq, Apr 27, 2016.

  1. mbarq

    mbarq

    Joined:
    Oct 4, 2015
    Posts:
    10
    Hi guys, I was interested in learning more about shaders and wanted to know what's a really good way to get started?

    I've played around with shader creation in unreal's material editor, but as you guys knows unity doesn't have that unless you count shader forge.

    Should I just buy a copy of shader forge and learn my way through that, or do you guys have a quick way to get into writing shaders that I can then use to get into more complex things?

    Thanks!
     
  2. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    There isn't really nothing about learning Unity's Shaders online, I mean there's some stuff, but nothing I've ever ran into goes beyond the most basic of the basic stuff.

    I think the reason behind this is, yes there might be HLSL, but each system has its own way of interpreting it, like if you go on google and type in HLSL water shader, find one, put it into a Unity Shader file, it won't work. Because Unity handles these things differently because of Shader Lab I believe.

    So I found for me the best learning resource is just trying to understand the mess of no explanation shaders they release.
    Google Unity Built In Shaders Download and you'll find a link to all the default shaders Unity comes with.
     
    mbarq likes this.
  3. NotTesla

    NotTesla

    Joined:
    Feb 1, 2015
    Posts:
    24
    mbarq and Ryiah like this.
  4. mbarq

    mbarq

    Joined:
    Oct 4, 2015
    Posts:
    10
    incredible! thank you so much.

    Yeah, this is great. The results I'm getting online go to more theory, whereas I'd just like a tutorial that goes, "okay, you want to apply a soft tv-like glow to this whole thing? here's this and this is why" or "you'd like to have a texture that scrolls uvs, ok, here's how", I guess more applied stuff.
     
  5. Deleted User

    Deleted User

    Guest

    There's actually more about than you'd think, maybe not quite as simple to find as others. So Unity's ShaderLab is similar in a lot of ways to Nvidia's CgFX which is very much similar / same as HLSL.

    http://developer.download.nvidia.com/shaderlibrary/webpages/cgfx_shaders.html

    These examples are a little outdated, as CG is long gone.. But there are plenty of examples / docs to study and the base principles still apply.

    Along with the shader examples and whitepapers, there is also many GPU Gems docs I looked into which contains tutorials: http://http.developer.nvidia.com/GPUGems/gpugems_ch32.html

    On top of that if you have a subscription to digital tutors, there is quite a handy shader overview on there too.

    Then you have Unity's own CG / HLSL examples: http://docs.unity3d.com/Manual/SL-PropertiesInPrograms.html

    http://docs.unity3d.com/Manual/ShaderTut2.html

    Moving on to DX11:

    http://docs.unity3d.com/520/Documentation/Manual/DirectX11.html

    Once you understand the principles and want to speed things up, you can use surface shaders:

    http://docs.unity3d.com/520/Documentation/Manual/SL-SurfaceShaders.html

    Then once you understand the principles of how Unity's shaderlab works, then you can start looking at all the HLSL tutorials (which there is a boat load) and siggraph's etc. filling in any gaps from the HLSL to Shaderlab.

    Much prefer to use a material editor though, it's so much quicker :)..
     
    mbarq, Martin_H, MikeTeavee and 5 others like this.
  6. mbarq

    mbarq

    Joined:
    Oct 4, 2015
    Posts:
    10
    Woah, thank you!

    Yeah, the material editor was so much more easier to get started with especially with tutorials from ImbueFX where you can learn a boatload just through making a magical ground cracking spell cast.

    The type of tutorial that I was hoping to get were those similar found on gametutor.com, their shader forge one's are really great, but I want to learn shader stuff using just what unity provides me with.

    well, thanks again, and any other high quality resources that are a little more heavy on practical application would be appreciated.
     
    Deleted User likes this.
  7. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    GPU Gems, OpenGL orange book (OpenGL Shading Language), Also see books section on OpenGL website. I also used to have "Computer Graphics Using OpenGL 2nd edition" (Francis S.Hill) long ago, if new books are as good as that one, I'd recommend to grab them. It was one of the few books that bothered to explain low level algorithms.
     
    mbarq likes this.
  8. MikeTeavee

    MikeTeavee

    Joined:
    May 22, 2015
    Posts:
    194
    I really admire all of you understanding in learning shaders, it's scary at first and not easy. It also bored me to death, I gave up to learn other things, and in the meantime just drag and drop film-grain and bloom shaders from assets I have downloaded When need be.
     
    Last edited: Apr 29, 2016
    mbarq likes this.
  9. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    976
    I was crazy scared of shaders and avoided them for the longest time. But after finally biting the bullet and getting into them, I noticed they're not so scary at all - you just need to spend some time with them. And once you do learn how to write your own shaders it's one of the most rewarding skills you can have in game development.
     
    mbarq likes this.
  10. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    There are a lot of problems if you want to write shaders that deal with stuff like depth and deferred properly. These things are often either undocumented or poorly documented.

    A lot of the built in functions you'll see are very hard to fully understand, realistically you need to dig through the crazy stuff in the cg includes.

    If you don't need to work with this stuff, it's not so bad. But really understanding all the stuff like SHADOW_CASTER_FRAGMENT(i) - is not for the squeamish.
     
    mbarq, Martin_H and neginfinity like this.
  11. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    That's true. Shadowcasting/lighting macros is a mess and badly needs refactoring. Completely non-customizeable, also changing order of includes can change visual result.
     
    mbarq and Martin_H like this.
  12. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    It's not just that, it's also that those macros are realistically the only reference you have on how to do things properly.
     
    mbarq and Martin_H like this.
  13. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    I tore them apart while experimenting with raycasting. Those macros aren't doing things properly. They may be used as a reference that illustrates how things work. But not about how to do things "properly".

    I'm quite sure about it. It is a mess.
     
    mbarq, Martin_H and frosted like this.
  14. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    The worst part is when highly technical comments are inaccurate which also happens.
     
    mbarq and Martin_H like this.
  15. mbarq

    mbarq

    Joined:
    Oct 4, 2015
    Posts:
    10
    Thanks for these! Yeah, I was just wondering how in the world people even begin to think of making all these different types of shaders.

    The GPU Gems book seems like a really great book! The math is kind of intimidating since the last time I touched any type of Calculus level algorithms was in high school (8 years ago), so I have forgotten quite a bit :/

    Thanks guys!
     
  16. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    I will suggest to learn linear algebra and/or calculus instead of Unity shaders. If you want to become a graphic programmer then you'll probably need both to get a head start.
     
    landon912 likes this.
  17. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    686
    Math, math and the math. This you should master at first. Trigonometry, calculus, linear algebra etc are very necessary tools.
    http://www.amazon.com/Mathematics-Programming-Computer-Graphics-Third/dp/1435458869
    http://www.amazon.com/Introduction-Differential-Equations-Undergraduate-Mathematics/dp/3319020986

    Then a quick tour on graphics API if you are familiar with c/c++. If not, pick a book on that.
    http://www.amazon.com/Introduction-Programming-DirectX-Computer-Science/dp/1942270062

    Then, GPU gems and GPU pro series.
     
    landon912 likes this.