I didn´t test this code, but I think it should be

my.material = mat_flat;

I can´t say if the method works, there was once a very long thread about this issue, and it wasn´t really solved. Someone even tried to write a shader, but it didn´t work.
So I was surprised (and somewhat sceptical) about this very simple solution.
Anyway, I hope it works ...