3

The Bump map node has a Normal input. This lets you make alterations to your Normals before the Bump is applied. The Normal Map node does not have this. It always acts on the base mesh Normals without letting you modify anything first.

Is there a way around this limitation? Could a node group be made that does the same thing as the Normal Map node, but lets you choose the input Normals? Or is there some other way to do Tangent displacement on arbitrary Normals, even if its not using a Normal map?

Ascalon
  • 6,579
  • 8
  • 55
  • 121
  • 3
    Does this answer your question? How to Combine two Normal Maps? – Crantisz Sep 02 '21 at 09:06
  • @Crantisz That method won't work as it is still operating on the meshes normals. Its for mixing two different regular normal maps. I want to apply a normal map to any arbitrary normals, including object/world normal maps or ones generated in the material, without necessarily involving the actual mesh normals. – Ascalon Sep 02 '21 at 18:44
  • "Could a node group be made that does the same thing as the Normal Map node, but lets you choose the input Normals" You'd need the tangent and bitangent (sign) too of course. This is the normal mapping code, I think, for reference. – scurest Sep 20 '21 at 13:53
  • @scurest Are we able to get those with just nodes? Is the tangent we need what we get if we take normals and put them through a vector math node set on tangent? I can about half understand what i'm looking at in that code. I'm not sure what some of the inputted things are, like vec4 info. It is getting used, but what is in that? – Ascalon Sep 20 '21 at 21:16
  • @Ascalon If you want to supply your own normals, you also need your own tangent and bitangent, so you would be the one who knows if you can get those with nodes. You need to use the same normal/tangent/bitangent that your normal map was created for. Nothing to do with vector math tangent. I'm pretty sure sign(info.w) is whether the object has negative scaling. – scurest Sep 21 '21 at 14:49
  • @scurest There's a tangent node that you can use to get the UV tangent. The binormal is just the cross product of the tangent and the normal. It is possible to make a from-scratch normal mapping node. I've implemented one, although it was subtly different than Blender's normal mapping node and I didn't know why. So it is possible, although I'm not interested in recreating it. A different way to do this is to just give your mesh custom normals, or to use an object-space normal map. – Nathan Sep 22 '21 at 15:21
  • @Nathan Yeah, but since any two of (normal, tangent, bitangent) uniquely determines the third, if you use Blender's tangent and bitangent, you also use Blender's normal, defeating the point. Unless you're going to use a non-orthogonal frame or something. – scurest Sep 22 '21 at 18:20
  • I didn't edit the question myself, as I'm not sure I understood it, perhaps it would be best to modify the question to state explicitly, you want to 1. use a Normal Map node, 2. Tangent Space, 3. You want to modify the base normal of the mesh, that is modified by the tangents in the image texture. If I'm correct, seems to be a duplicate as pointed out by Crantisz. – Markus von Broady Sep 22 '21 at 20:32
  • @MarkusvonBroady Thank you but that is not correct. The Normal Map node is hardcoded to displace off the mesh's normals. I want to displace off any arbitrary normals that I choose, like the Bump Map node can. So it is different. I have figured out most of the problem and have a working group. So I think I can put an answer to this in a bit once I figure out a few details. – Ascalon Sep 22 '21 at 20:37
  • @Ascalon I'm wrong in understanding your question? It seems to me you simply don't want to use tangent space, and then calculate your own normal by having a normal A, a normal B, and mixing them together (now, simply color mixing is probably incorrect, but those intricacies are discussed in the Q&A linked by Crantisz). Once you calculate your own normal by doing A ∘ B (whatever ∘ is), you just pass it to a Normal Map node as Object space. If you want the calculation to be the same as in Normal Map node with Tangent Space, then you have to recreate the logic by following Scurest's link... – Markus von Broady Sep 22 '21 at 20:47
  • @MarkusvonBroady I want to do a tangent displace off normals that are not the mesh's normals. (Such as arbitrary normals from an object space normal map, or ones created procedurally). This means being able to feed in any arbitrary normal, tangent, bitangent, and also tangent normal texture (color input.) So yes, I need to recreate the logic from Scurest's link, which I have been able to do. (I'm now figuring out if I can actually get satisfactory tangents and bitangents for what i'm trying to do, but that is technically a different issue.) – Ascalon Sep 22 '21 at 21:15
  • @scurest No. The normal, binormal, and tangent used are determined by the base normals. They create the space in which the normal map is then evaluated. The normal map is just a remapped vector in the sample's tangent space (a space where the z is normal, x is tangent, y is binormal). – Nathan Sep 22 '21 at 23:34

1 Answers1

4

I went through the linked source code for the normal map node, and came up with this:

enter image description here

This is giving me the same behavior as the Normal Map node set on Tangent Space, but has the Normal and Tangent exposed as sockets. Proper use is to input the mesh's Normals from a Geometry node, and a Tangent from the Tangent node with the UV map that matches the color texture.

However, there are some things missing as compared to the Normal Map node's source:

  1. The source code has an input called vec4 info, and is using the sign of its .w as part of calculating the Bitangent. I could not figure out what this Info is. But it seems that sign(info.w) must be turning out to be 1 (as opposed to 0 or -1), because I'm not getting any visual differences in my testing.

  2. Similarly, I am assuming that tangent.w is also 1. In the source, the tangent is a vec4, but in the nodes its all vec3s. This also hasn't caused any issues in my testing, but I don't know if there are circumstances where it might.

Ascalon
  • 6,579
  • 8
  • 55
  • 121