Shader Learning?

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!

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.

1 Like

Catlike Coding is doing a tutorial for shaders. I personally have not done it but he has fairly high quality tutorials for the most part.

2 Likes

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.

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 :)…

8 Likes

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.

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

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.

3 Likes

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.

2 Likes

It’s not just that, it’s also that those macros are realistically the only reference you have on how to do things properly.

2 Likes

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.

3 Likes

The worst part is when highly technical comments are inaccurate which also happens.

2 Likes

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 :confused:

Thanks guys!

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.

1 Like

Math, math and the math. This you should master at first. Trigonometry, calculus, linear algebra etc are very necessary tools.

Then a quick tour on graphics API if you are familiar with c/c++. If not, pick a book on that.

Then, GPU gems and GPU pro series.

1 Like