I have seen a lot of information about moon phase calculation, but need an accurate moon shape calculator/algorithm given the observer's position and time. This implies that the illuminated portion may be rotated, and not only have a right-left orientation as traditionally depicted.
There is an accurate depiction of the moon phase and shape in Stellarium (see below) that you might find useful. You can select your observing location and time anywhere on Earth (or another planet if you so wish). Then you can just search for the moon in the search window (if you cant spot it in the sky), and you have a real representation of how the moon looks at that specific time and location. However if you need to repeat this calculation many times then this isn't the best solution.