- Home /
Learning shaders for unity4
I am curious on what resources I could use to learn shaders for unity4. I tried strumpy shader editor and loved it, but it is messed up and not consistent in unity4 with its results.
What shader language does unity use? Cg? Or some other unity specific language. Can somebody explain general concept, or concepts that are often missed/messed up. I am also curious what other people's own lessons and such they have learn to do or not do for coding shaders.
I am sorry if this is too open ended and is not necessarily a concise question. I have looked online and there is so many different topics and things on shaders.
Thanks for your help :)
Read my getting started tutorial on Unity Gems - The Noobs Guide To Shaders - where I started from exactly where you are and decided to write the tutorial as I learned.
Unity Cookie recently started a training series on shader writing featuring general concepts and the implementation of different techniques. These are citizen tutorials however and require a membership at CGCookie Beginner Series Intermediate Series
Is the unity cookie membership free and just registration? And is there comprehensive materials for the "noobs guide" videos to demonstrate and talk about concepts in detail?
Unity Cookie is good - Noobs Guide is just there - go take a look, see if you get on with it.
Answer by Owen-Reynolds · Apr 01, 2013 at 07:41 PM
The basic concepts(*) of shaders are the same everywhere, so, like C#, you could probably learn from a non-Unity source. I learned from the "Red book" on OpenGL then later used NVidea's HLSL shader editor. Unity shader language is just more of the same -- the man pages are good enough once you know shaders in general.
(*) Uniform variables; perVertex vars; faces don't really exist; all fragment data is interpolated values; vert->rasterize->frag->post pipeline; texCoords and why you "sample" instead of reading a pixel; default frag/vert shaders.
Then Unity sort of has 3 shader languages. Figuring out those is where Unity-specific guides would help:
ShaderLab is like the old switches method. The OpenGL red book has a good explanation and examples in the "mostly obsolete" section. I assume lots of other places do the same. The shaderLab language isn't the exact same, but the idea of how you build it texture by texture+addHow is the same.
The one with the most examples is surface shaders. Those are "real" shaders, but the lighting step is left-off, and auto-added by Unity.
Then you can use "real" vertex/fragment shaders, which look mostly like Cg shaders.