# Mathematically, what does Faceforward function mean?

Blender's description of Faceforward function is, quoted from Blender's document:

Orients a vector A to point away from a surface B as defined by its normal C. Computes (Dot(B,C)<0)?A:-A

I have a few questions regarding this description.

1.. A Dot Product between a surface (B) and a vector (C)? Is this Mathematically correct? As far as I know, there's no concept of Dot Product between a surface and a vector.

2.. This is the Faceforward node, why is B here defined as "incident (vector)" whereas it was defined as a "surface" in the document? So what actually is it, a surface or a vector?

3.. Why did the developers name the normal vector as "Reference"? Why didn't they just name it "normal"?

4.. Assuming B does act as surface according to the document, what controls the orientation of the surface then? Surface B or normal vector C?

5.. “Orients a vector A to point away from a surface B as defined by its normal C” - Is the function’s job really just to make A points away from the surface? Because it does make vector A points into the surface too.
(Dot(B,C)<0) ? A : -A means:
-- If B points inwards (i.e. B•C < 0), keep A that way (even if A pointed inwards or outwards, doesn’t care, keep it that way).
-- If B points outwards (i.e. B•C > 0), flip A (if A pointed inwards, flip it to point outwards and vice versa).
So does Faceforward’s job really to only make A points outwards?

Thank you. Any help is appreciated!

• The question is very good, and I personally am interested in the answer too. I took the liberty to add the tag geometry-nodes, because there is the same vector-node, and I have faced this question there a few times too. Surface>Vector>Incident, Huh? Nov 21, 2022 at 7:16
• @quellenform Thank you! I've asked around, if you're interested in hearing a few people's opinions on this problem, you can check here: ---- devtalk.blender.org/t/what-does-faceforward-formula-mean/26634/… ------ reddit.com/r/blenderhelp/comments/yyftzk/… -------- Nov 21, 2022 at 8:27
• I'm reasonably sure the reddit comment is wrong since A is definitely your main input vector and you're not interested in its dot product with anything. You're interested in the dot product of two other vectors (B and C)—if those are pointing in the same direction (dot product is positive) then A stays untouched, if not, you flip it (-A). One of those is a "surface as defined by its normal" and the other is an incident vector. I think they used the OpenGL nomenclature here: docs.gl/sl4/faceforward, which is equally poorly/obscurely written. (cont.) Nov 21, 2022 at 9:25
• The explanation for the same method in Unity is much clearer: "Conditionally flips a vector n (A) if two vectors i (B) and ng (C) are pointing in the same direction. Returns n if dot(i, ng) < 0, -n otherwise." Wording here is much more generalized, even though the letters used—i and ng—points to the same terminology underneath: i for incident and ng for normal. In summary, the second video in your devtalk thread is a pretty neat demonstration and yes, manual seems to be clumsily written. Nov 21, 2022 at 9:29
• @IanAmbrose Correct. Robin's example in his answer is a nice one. Imagine your camera's position is your incident vector, if it's on the "wrong" side of the billboard, it flips your main vector so the writing always looks normal to you no matter where you're looking at it from. Manual tries to convey both the "meaning" of the whole operation (there's a plane and we care about its orientation incidental/in relation to another point) and the technically correct nomenclature (we use not the surface itself, but its normal as the reference), but ends up jumbling them both. Nov 21, 2022 at 17:17

I don't think there's much mystery to what the function is doing. The mystery (to me, anyway,) seems to be in the vocabulary used to describe it, and when you would want to use it?

The Vector input is a vector, (any vector) to be modified. Incident and Reference are two other vectors. Again, any vectors.

If Incident and Reference point into the same hemisphere, then Vector is reversed. Otherwise it's left alone. Effectively, this group:

Below, Incident is the blue arrow. Reference is the green arrow, normal to the plane 'surface'. The 'F' is aligned to the input Vector, as modified by the node:

So, if, for example, you textured a single-plane billboard with an advertising slogan, you could fix it so it reads correctly from both sides.

• Thanks Robin for the visualization! Now I understood it too. Here is another highly simplified example: i.stack.imgur.com/7TLCA.gif (with a reference plane instead of a Vector) Nov 21, 2022 at 17:28
• @quellenform zackerly! I'm getting the feeling the whole thing was cooked up to texture billboards / bump / other lighting effects on single-sided faces, and just migrated to GN because it was there? But that's only a feeling. Maybe someone knows. Nov 21, 2022 at 18:26
• +1 another great answer from the master !! Nov 22, 2022 at 6:09