VertexLit and CGPROGRAM confusion

I’m trying to understand shaderlab a little better and have read through all the docs (I think)

In the docs it takes apart the VertexLit program but stops before it reaches the CGPROGRAM code.
Later on in the docs it gives examples of Cgprograms but then says when you use one the normal shader pass stuff isn’t needed.
In other examples, even in this forum, I have seen the 2 methods mixed together so is there a gap in the docs?
How do you mix the 2 approaches?

What I would like to do is use the standard vertexlit shader but add a deformation to the vertex positions and normals before the lighting and textures are applied.

The thing is, when you start using shaders, all fixed function is gone.

So you can’t really do “I have a vertex shader where I do deformation, and then please calculate the lighting for me”. If you have a vertex shader, then no one will calculate the lighting (you have to do that yourself in the vertex shader).

It is possible to calculate limited vertex lighting in the vertex shader (full equivalent of fixed function vertex lighting won’t fit into instruction limits). E.g. vertex lit terrain shaders do that (with the limitation of up to 4 lights, and spot lights treated as point lights).

Ok that makes sense, so can you explain a bit more about what is actually happening in the current VertexLit shader, which seems to start fixed function but then has a bunch of CG code at the bottom, this situation doesn’t seem to be covered in the docs.

At the end of the VertexLit shader it has shadow caster/collector passes. Basically, things that are used for objects rendered as shadow casters.

Normally most shaders eventually fallback to VertexLit, and that’s where the shadow caster passes get “fetched from”.