Fixed borders not working
Merged @StarBrilliant's matrix calculation with modifications for correct 3d rendering.