Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am doing this Blenderguru tutorial on Making Fire and at some point he is adding the Vector Math node Dot Product to his material. And he says that he does not understand what he is doing but this seems the way how to do it (he is creating the material for a sphere that is used in the particle system).

Dot Product usage example

Now I realise that I have applied this Dot Product for a number of times and to be honest... I also don't know what I am doing. I googled and found some complicated math about scalar products and it is too long ago for me that I did that kind of stuff on university. Can someone explain in "noob language" what Dot Product does in Blender?

share|improve this question
up vote 18 down vote accepted

The dot product of two vectors measures two things:

  • how much are they "in the same direction" ?
  • how large are they?

Skipping the precise definition, we're usually interested in these properties:

  1. Vectors with the "same-ish" direction will have a positive product, a null one if they're orthogonal, and negative if they are in opposite directions
  2. If you double any vector, you double the product (if you double both, the product gets 4x larger)
  3. The product of a vector with itself depends only on its length (since it has the same direction as itself)
  4. If you see one of the two as a reference (say, an axis), then the product is how much does the other vector progress along this axis.

Speaking in terms of colors, the RGB vector can be very loosely interpreted as follows: the direction is the shade of color, and the length is the brightness. Now all the rest applies as with regular geometry vectors.

share|improve this answer

Let's start with some definitions:

Vector: A list of values that are all contained under the same "roof" so to speak. For instance, the location of an object in 3D space is a vector of 3 values (the X, Y and Z location of that object).

All Vectors in blender are by definition lists of 3 values, since that's the most common and useful type in a 3D program, but in math a vector can have any number of values.

Dot Product: The dot product of two vectors is the sum of multiplications of each pair of corresponding elements from both vectors. Example:

V1 = (1,2,5)
V2 = (2,1,3)
dotProduct = V1.x * V2.x + V1.y * V2.y + V1.z * V2.z
           = 1    * 2    + 2    * 1    + 5    * 3
           = 2 + 2 + 15 = 19

The particle velocity example: In your original question, we see a dot product of the particle velocity with itself. The velocity is an XYZ vector since it has components in all 3 axes.

In a smoke or fire simulation, some particles are going right (positive X), some left (negative X), some forward (positive Y), some backward (negative Y), but almost all are going up (positive Z). The velocity data reflects this. If a particle is going straight up, its velocity will be, for instance, (0,0,1). If it's going left, forward and up, its velocity can be something like (-1,1,1).

When you calculate a dot product of the velocity with itself, you cancel out the negative values (negative values multiplied with themselves become positive), so this is a quick way to convert the velocity gradient over all particles from a 3D XYZ gradient to a mostly 2D gradient along the Z axis.

enter image description here

And now the velocity's dot product with itself: enter image description here

Another Example: Parametric Geometry Input Node:

enter image description here

The Cycles Input --> Geometry node's Parametric option that's used here, generates a Vector (RGB) value for each point on the object's surface (image above). Each color channel's at each point has a value between 0 and 1.

If you calculate the sum of each point's RGB values (R+G+B), you'll get a single (scalar) value (top image in the figure below) that ranges between 0 (R=0,G=0,B=0) and 3 (R=1,G=1,B=1).

This is the same as the dot product of each RGB value and a Vector of (1,1,1) (2nd Image in the figure below).

enter image description here

And eventually, if you calculate the dot product of the parametric RGB with itself, you essentially multiply each color with itself (R*R + B*B + G*G) in each surface point (3rd Image in the figure above).

In this case it darkens the image significantly, because any value below 1 that's multiplied with itself produced a smaller number/value.

share|improve this answer
1  
You forgot to escape your asterisks in the second to last paragraph. You meant to write (R*R + B*B + G*G) but instead wrote (RR + BB +G*G). (I tried to edit myself, but edits by other users must be at least 6 characters). – Pharap Feb 24 at 11:26
    
Thanks, @Pharap, done. – TLousky Feb 24 at 12:13

The dot product is a way of multiplying two vectors that produces a scalar (i.e. real number) value.

Geometric Definition


The dot product of vectors V and U can be thought of as multiplying ||V|| (the magnitude of V) by the component of U that is parallel to V.

enter image description here

Notice how the vector U is split up into two perpendicular components, so that one is parallel to V (U||) and one is perpendicular to V (U). The dot product of U and V is defined to be ||V||xU||.

Here's a graphic showing how the dot product changes with respect to the relative angle between the two vectors, the red line represents U||.

enter image description here

Notice what this means practically. If U is parallel to V the dot product is simply ||U||x||V||, if U is perpendicular to V the dot product is 0, and if U is pointing away from V (i.e. the angle between U and V is > 90°) then the dot product will be a negative number. So essentially you are measuring how close the two vectors are to each other with respect to their directions.

Algebraic Definition


With some simple geometric trig and the aforementioned geometric explanation you can find the dot product to be equal to ||V||x||U||xCos(θ) where θ is the angle between the two vectors.

enter image description here

If you know the x and y components of the two vectors the dot product is equal to UxVx+UyVy, but I won't go into the derivation of that here.


In the case of the tutorial you are referencing, what Andrew is doing in his is equivalent to just squaring the magnitude of the velocity vector. This both makes negative values positive and creates a quadratic falloff curve.

share|improve this answer
3  
If whoever downvoted sees this I'd like to know why so I can improve. – PGmath Feb 23 at 20:33
1  
That's a great answer @PGmath. Someone also downvoted mine, might be a serial voting troll :) – TLousky Feb 23 at 22:20
    
it sure was not me. I am really impressed by your answers and I think a lot of people appreciate the work of you both !!! – Old Man Feb 23 at 23:10
2  
@JanScherders The rep doesn't really bother me that much, I just want to know what I can improve. (Glad you appreciate the 2 hours I spent making that graphic!) – PGmath Feb 23 at 23:14
1  
@PGmath Thanks for the drawings. I think I'll use them in my lectures. – Miz Feb 24 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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