Hello

The code for computing normals in not accessible from the user in BGRABitmap. Though you can compute it yourself from the height map.

The normal is a 3D vector pointing upwards. From the site you mentioned, I suppose the up way is the z component equal to 1.

To compute the normal vector, you can do the cross product of the slope vector in x and the slope vector in y.

Sx: Slope vector in x

x = 1

y = 0

z = height difference in x = a

Sy: Slope vector in y

x = 0

y = 1

z = height difference in y = b

n: Normal vector:

n = Sx * Sy

x = -a

y = -b

z = 1

The vector is normalized to be of length 1. It is stored as RGB where :

red = x*127 + 128

green = y*127 + 128

blue = z*127 + 128

Regards