I recently came across a set of models that include Derivative Maps. I'd like to use them in Blender, but from what I've seen so far Blender only supports exporting baked Derivative Maps, not importing them. Therefore I'm trying to convert these Derivative Maps into tangent space Normal Maps for use in Blender.

So far all the programs that I've seen (like xNormal etc) also only support exporting Derivative Maps (not importing them) so they haven't worked for me, but if anyone knows a program that can be used for this conversion that would be great.

As for developing a converter myself, I've done some research on Derivative Maps to try to understand the logic behind them, including reading these links and the original paper, but it's been a while since I've seen math in this level and I'm just not understanding it well enough to develop an algorithm that works.

Can anyone help be understand how I can turn a Derivative Map's pixels into a Normal Map's pixels? A simple explanation of the necessary equations, or even some pseudocode algorithm, would be a lot of help.


1 Answer 1


Suppose you have a function $f$ (think a height field) of $(x,y)$. A derivative map contains point samples of $\left( {\partial f\over \partial x}, {\partial f\over \partial y}\right)$, typically as a two-component texture.

What this means is that at a point $(x,y)$ the 3D vector $\left( 1, 0, {\partial f\over \partial x}\right)$ is parallel to the surface $z = f(x,y)$. Likewise, the vector $\left(0,1, {\partial f\over \partial y}\right)$ is parallel to said surface.

Now, a vector orthogonal to the surface $z = f(x,y)$ can be computed as the cross product of these two vectors, which expands into

$$\left(-{\partial f\over \partial x}, -{\partial f\over \partial y}, 1\right)$$ Normalizing this vector (dividing by its length) will give you precisely the normal.

  • $\begingroup$ Here's the thing though, both these maps are encoded as colors, meaning the value of each component has to be in the [0,255] range, right? If the derivative map has a df/dx component and the normal map has a -df/dx component (even if normalized), doesn't one of them have to be negative? How do we encode negative values in the [0,255] range of a color? $\endgroup$ Commented Jun 4, 2022 at 0:35
  • $\begingroup$ Also, I get why the derivative map wouldn't need a blue component, but in the maps I'm seeing here (and in this example) the blue component is never zero. Am I maybe decoding the images incorrectly? Am I supposed to just ignore the blue component? $\endgroup$ Commented Jun 4, 2022 at 0:43
  • $\begingroup$ Never mind, I think got it working. For future reference: the mapping from colors to vectors is linear, with a 255 being a 1, a 127 being a 0, and a 0 being a -1. As for the blue component, it turns out AppKit's NSImage decodes the image correctly (with all blues as 0), even though in the monitor it displays blue tones in the colors - that's what confused me. Thanks for the help @lisyarus! $\endgroup$ Commented Jun 4, 2022 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.