http://stackoverflow.com/questions/5281261/generating-a-normal-map-from-a-height-map
The normal map looks fine except it has pretty serious aliasing problem!
The aliasing problem should come from the size of the texture doesn't match the canvas's size but since The texture came from the previous rendering, they should have the same size. And the texture parameters were set with gl.NEAREST (turn off the mipmap) and gl.CLAMP_TO_EDGE (turn off the repeating) so even it's not power of two, it should be alright. The offset in the shader is like [1.0/canvas.width, 1.0/canvas.height]
Could anyone have any idea what causes the aliasing? Thank you so much,
Yi