How do I align the texture perfectly to the normal of a face?

I’m using ProceduralMesh and each face has it’s own material.
When using the WorldAlignTexture it works good only if the mesh has it’s faces facing up,left,down,right,back,forth.
If it cahnges a bit, it will start getting stretched and mixed.
Example:


Is there any way to fix it?