Skip to main content
GameDev.net gamedev.net
🔒 Locked

ComputeNormalMap function trouble

Started by Martaver Nov 17, 2004 at 5:20 AM 0 replies 600+ views
Original Post
Martaver
Martaver
Hi guys, I'm trying to use ComputeNormalMap (D3DXComputeNormalMap function in the C++ library) to generate a normal map from my height map. My height map is a greyscale 8-bit bitmap. I load it into a Texture with 1 mipmap level, with an 8-bit luminance channel format:

heightMap = TextureLoader.FromFile(Graphics.Device,
				heightMapPath,
				x, y, 1,
				0,
				Format.L8,
				Pool.Managed,
				Filter.Box,
				Filter.Box,
				0);
			
			byte[,] heights = (byte[,])heightMap.LockRectangle(typeof(byte), 0, LockFlags.ReadOnly, x, y);
			heightsNormalized = new float[heights.GetLength(0), heights.GetLength(1)];

			for(int i = 0; i < heights.GetLength(0); i++)
			{
				for(int j = 0; j < heights.GetLength(1); j++)
				{
					heightsNormalized[j,i] = ((float)heights[j,i])/byte.MaxValue;
				}
			}
			normalMap = new Texture(Graphics.Device, x, y, 1, 0, Format.A8R8G8B8, Pool.Managed);
			TextureLoader.ComputeNormalMap(
				normalMap, 
				heightMap, 
				0, 
				Channel.Luminance, 1);
The heightmap works just fine, I'm rendering with it and everything - but when I go to computer the normal map at the end I get D3D_INVALID_CALL. Any ideas anyone?
circlesoft
circlesoft
Have you checked for debug output in your IDE? If a DirectX function call returns D3D_INVALID_CALL, it will always output information, pertaining to exactly what went wrong.

Check out this section of the FAQ about DX debugging.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.