I have a skinned mesh character whose animation sometimes brings some clothing vertices under the floor. I would like to draw those vertices at y=0. I understand there is no way to get the vertices position after skinning is applied. So I was wondering if it would be possible to do this via CG code?
It should be possible. In the vertex shader you would compte the world position by multiplying with _Object2World matrix. Then if y is < 0 you would set y to 0. Then you would multiply by the view matrix and by the projection matrix. Now, AFAIK, the view matrix is not available, so you would have to supply it through script. The projection matrix should be UNITY_MATRIX_P
EDIT: I guess a slightly better alternative would be to go back to object space by using _World2Object and then multiply by UNITY_MATRIX_MVP. This way you don’t have to supply a view matrix from script.