#### Archived

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

# D3Dx and hightmaps

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

## Recommended Posts

is there a D3Dx function that would convert a hightmap to a bump map? if not is there a good explaination on how to do it Bobboau, bringing you products that work... in theory

##### Share on other sites
D3DXComputeNormalMap

##### Share on other sites
If you have Photoshop, you can convert the heightmap to normal map with NVIDIA''s conversion plugin. If you use it, you don''t have to load the heightmap and then convert it in the code, you just load the normal map directly. No need for heightmaps.

http://developer.nvidia.com/object/nv_texture_tools.html

##### Share on other sites
I am aware of that tool but the engine I''m makeing is designed for people be able to add there own media as easily as posable and it''s generaly easier to make a hight map than a normal map, and in the future we may use them for displaacement as well,

is there a solution for OGL also? becase there is an OGL layer too and I don''t want them to be left out in the cold.

Bobboau, bringing you products that work... in theory

##### Share on other sites
It's easy enough to write your own version of the filter.

Metacode follows:

Assuming 32-bit rgba pixel format for both surfaces:let w and h be width and height of the original pixel grid.for each pixel{Store the luminance difference (pixel[x,y] - pixel[(x+1)%w,y])/255 as slope in x.Store the luminance difference (pixel[x,y] - pixel[x,(y+1)%h])/255 as slope in y.Define z as inverse of the "bump depth" factor.Combine x, y and z to a 3-component vector, normalize it.normalmap[x,y].r = x*127.0+128.0normalmap[x,y].g = y*127.0+128.0normalmap[x,y].b = z*127.0+128.0normalmap[x,y].a = 255;}

One could use a different matrix to compute the slopes; for example, d3dx uses 3x3 average slope, which is much more high-quality than this.
However, my example contains the general idea for normalmap generation with heightmap as source.

kind rgds,
-Nik

EDIT:
Typo.

[edited by - Nik02 on November 30, 2003 11:20:18 AM]

1. 1
2. 2
3. 3
4. 4
Rutin
19
5. 5

• 14
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632927
• Total Posts
3009254
• ### Who's Online (See full list)

There are no registered users currently online

×