How to transform to and from mesh particle space?


I am trying to use mesh particles and assign a material to them that modifies their vertices. With regular meshes everything works fine, but I just can’t get anything to work with mesh particles. I have made several tests, but don’t understand the results. To demonstrate I created a material that simply transforms the world position into local space and outputs the color (clamped). On the right side is what it does to a regular mesh with different sizes. It is scale independent. On the left there is a slightly different material for mesh particles. The results look very different.

On top of the different result I also had to manually write the conversation code. A simple transform position from world to mesh particle space had an even worse output. Sort of looks like there is no transformation done at all:

What I am doing now is subtracting the particle position from the world position and then using a Transform for the result direction, but it still leaves me with the top outcome. I tried using a RotateAboutAxis node but it breaks with particles, they get skewed, scaled and apparently the space transformation does not properly work with a rotated mesh particle.

Does anyone have pointers on what to do or how to solve this?

Kind Regards