I'm trying to experiment a workflow where I can manually paint normals to create stylized shading for a model.

Painting on the model, I want to use object-space normal, as it's easier to work with, but it's a problem that I end up with tangent space normals. Ideally I would want to just convert it back to tangent space in the shader.

At the very least I have to know whether or not it's possible to do what I'm trying to do?


The simplest way to do such a conversion is to calculate the dot products between the Object_Space_Normal and the Tangent plane, and then 'normalize' the result to RGB.

$\vec{Tg}_N = 0.5 + \begin{bmatrix} \vec{Tg} \cdot \vec{N}_{obj} \\ (\vec{N} \times \vec{Tg}) \cdot N_{obj} \\ \vec{N} \cdot \vec{N}_{obj} \end{bmatrix} / 2 $

And with nodes: enter image description here

This is the main process when working with vectors in World space.

In the case where your Normals are Object normals encoded into RGB, then you need to convert them first to world as in the following example: enter image description here

| improve this answer | |
  • 1
    $\begingroup$ Hi, yoür formula was really hard to read. I tried to convert it with proper formatting, but did I possibly mess up? Could you correct it, please? $\endgroup$ – Leander Aug 11 at 9:31
  • 1
    $\begingroup$ @Leander, it looks ok... I'll post the equivalent in nodes, for people less comfortable with math notation. $\endgroup$ – Secrop Aug 11 at 9:34
  • $\begingroup$ I'm especially confused because it says 0.5 * [...] / 2 which cancels each other out and results in [...]. $\endgroup$ – Leander Aug 11 at 9:38
  • 1
    $\begingroup$ @Leander, it's supposed to be a sum.. my fail, but corrected. :) $\endgroup$ – Secrop Aug 11 at 9:39
  • 1
    $\begingroup$ @meatandmahjong, I see now what you're trying to do... I'll update my answer later today, but you need to use the NormalMap node with your Texture, before plugging it into this node setup. (or 2*Tex-1) $\endgroup$ – Secrop Aug 11 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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