More documentation on Shaderlab?

I really want to understand how the toon shader and also the xray shader is functioning.

The clump of code that does the work I just can’t comprehend. It’d be nice if somewhere in the docs it went over it line by line covering the math behind it and everything.

The math behind such things are documented on the web, the shader dev books as well as the different computer science 3d courses available around the globe.
A start would be google and the nvidia / ati pages.

Requirement naturally is that you have a solid university level background in the required 3d topics and math (vector, matrices, light calculation, meshes, normals, tangents, vector spaces, …), otherwise the readings are useless as you lack the basics.

The commands etc itself are covered in the cg documentation.

I have a very thorough understanding of 3D from an application point of view, but vector mathematics are still a vague thing to me.

And I understand that the code is just thrown out there and for someone to really understand it will require them to have alot of background in the subject. But you know, me, and alot of people won’t. And if Unity is going to become more accesible, it’d be nice to have some article go through a complex shader like this a few times explaining all the specifics. I mean, I don’t even know what functions of vector mathematics to study in order to figure out this shader.

I only say this because so far the Unity documentation has had everything so thoroughly well explained. But I got to these shaders it’s the most intricate, and has the least amount of explanation.

Just some notes like ‘does dot product of x and y here for reason z’… ideally a few diagrams cause that makes understanding vectors easier.

Yes I know. Thats why I tried to explain that it is an expert topic, neither a beginner nor really an advanced one (part of the shaders can be understood with advanced knowledge but some are really expert only)

That won’t help as you can’t understand why it works, even if every single line was explained.
All you could do would be copy paste and copy paste articles on such topics already exist on the web although not for cg but normally HLSL and XNA where the largest amount of “beginners” try to shader program.
the math is the same on both ends, the shader language sytnax is just slightly different

Learn vector maths and learn cg from the cg documentation on the NVIDIA website. That gives you the basic tools to be able to analyze what the shader does :slight_smile:

The unity docs cover the whole technology.
But what you do with it and how to unleash it is really nothing you can document as it then would be 50-150 times as large as it is and still not cover even nearly everything.

Once you understand cg and have a basic background on the topics in question, you will likely not have much problems understanding something simple like the toonshader (toon shaders are commonly among the simplest things shaderwise, aside of texture blenders for texture splatting and similar)