Original Post
I''m having problems using this function... It seems it isn''t correctly creating my normals.
These are the steps I''m doing:
1. Create a D3DFMT_A8 + D3DPOOL_SCRATCH texture with the dimensions (width and height) of the heightmap (lets call it pSrcTexture).
2. Lock pSrcTexture and copy the heightmap to it (this is done correctly)
3. Create another texture using FMT_R8G8B8 + POOL_SCRATCH with the dimensions of the heightmap (lets call it pDestTexture).
4. I call D3DXComputeNormalMap passing, first, the destination texture (pDestTexture), second the source texture (pSrcTexture), third NULL, flags 0, D3DX_CHANNEL_ALPHA and I''m passing an 1.0f for the Amplitude (this may be wrong as I don''t exactly know what does "Amplitude" means, and I quite don''t understand what the SDK means with "Constant value by which the height information is multiplied.", nevertheless, I''ve already sent 1.0f and 10.0f but the output is the same.
5. Finally, I copy the RGB contents of pDestTexture to my normal vector (float nx, ny, nz) dividing each value by 255 (as I understand, normals goes from 0.0f to 1.0f).
The output is different on every different heightmap, so, D3DXComputeNormalMap is doing the normal processing, and I''m having weird results like, a plain heightmap will result in a 1.0,0.5,0.5 (nx, ny, nz)
1.0,0.4,0.4
1.0,0.5,0.5
1.0,0.4,0.4 (etc.)
Normals output.
Does anybody know what I''m doing wrong?
Thanks in advance!