Archived

This topic is now archived and is closed to further replies.

Bump Map Creation

This topic is 5530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How exactly do you create a bump map? I have used them and I know how they function but I don''t know how to generate them for I have used PhotoShop for it. What I want to do is to just get an rgb value for a nrmalized vector, and turn it into a color to be used in a DX application. All vectors would have a Z coordinate of at least 0. Does anyone know where a formula is?

Share this post


Link to post
Share on other sites
Ah, what you''re talking about is a NORMAL MAP (i.e. normals encoded as RGB values). Usually you create that from a height map by treating each pixel in a source height map texture as a vertex for a triangle. The x and y values for the vertices are simply the x and y positions and the z values are specified by the values in the height map. You then just use the same method of finding the normal as you would for any triangle (e.g. cross product), then encode the resultant value as a colour.

As for how to generate them:

1) There is a PhotoShop plugin available on the nVidia site IIRC which generates normal maps from height maps.

2) D3DX has a function to do it too: D3DXComputeNormalMap()

3) Finally you''ll find source code to do it in samples on the nVidia and other IHV websites. The OpenGL code is just as applicable to D3D as long as you''re consistent about which space the normals are in/which elements of the vector maps to R, G and B.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
I am not using height maps, it is for a totally different technique. All I really need is the relationship between RGB and XYZ which is what I have been looking for. Is it as simple as R = (X*0.5)+1 or is it more complexed?
Thanks...

Share this post


Link to post
Share on other sites
So you already have a normalalised normal vector per pixel (e.g. you''re doing something like collapsing geometric detail into bump maps) ?. If so here''s a snippet of code:

nmap[i*width+j].r = (BYTE)(128 + 127*nx);
nmap[i*width+j].g = (BYTE)(128 + 127*ny);
nmap[i*width+j].b = (BYTE)(128 + 127*nz);


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
What I am doing, incase you are interested, is making a light direction map which would be used together with a lightmap and a bump map to allow for a static bump mapped specularity effect. I know I can do that by taking a direction vector at each vertex for each light and normalizing it with a normal cube map, but I want something more customizeable and I think this technique would be faster, as only the vector between viewpoint and vertex would need calculation. Although it wouldn''t be strictly accurate with multiple lights, it should do a better job based on efficiency.

Share this post


Link to post
Share on other sites