I am creating a shader which will write the vertex distance from its object's origin on it's XZ axis only to the R Channel. The restrictions are 1. the distance has to be before scaling but after rotation, 2. no variables should be passing in from C# (since this will be a particle effect, I am trying not to loop through the particles to pass in things individually). So if I have a sphere, its radius is 1, it should look like this at any rotation from top down: Currently, I am using 1 - length(v.pos.xz) to produce the above image, but it does not take rotation into a account, and will produce incorrect result if the rotation on XZ axis are other than zero. Does anyone know how to solve this?