Original Post
Hi, I am looking for a simple way of mapping a normal map onto a sphere. I am building a planet by subividing a sphere into square patches which can be covered with water or land. For water patches I would like to use normal maps for lighting calculations. The problem is that the normal maps are based on the xy plane with z being up. That works fine for a planar water surface but the patches I am talking about are maped onto a sphere. Somehow I have to transform the normals of the map into the space of the patch. I looked around and found some examples of how to rotate vectors, but that was too expensive for per pixel lighting. Somehow there must be a simple solution, but I can't see it. In the pixel shader I have access to the normal map via a texture2D and the Patch normal P. The Patch Normal orients the patch on the sphere in the global coordinate space. I first have to transform the normal from the texture map into this space, before I can use the normal for lighting calculations. I am hoping that there is a simple solution that does not require too many calculations. The solution does not have to be exact as long as it is good enough for specular lighting. Cheers Jochen P.S. Here is a little screenshot of where I am at so far (http://www.geist3d.org/1.JPG)