Does anyone have a algorithm or code for generating a normal map ?

Here are a few methods that might suit your needs: https://github.com/prime31/Nez/blob/master/Nez.Portable/Graphics/Textures/TextureUtils.cs