I am looking at this tutorial Geometry nodes for damage to stone. It uses a normal multiplied by some random vector to produce offset. What does multiplying a normal of a point with random vector result? Why does this only change points on the edges but not on the surfaces? When do we multiply by normal?
A normal is pointing outwards of a geometry perpendicular to its plane (in case of a vertex the mean of its connected edges/faces) and it has a length of 1.
The Offset in the Set Position node is what is added to the position of a vertex to move it. If you add the normal vector of that vertex to itself, it gets moved perpendicular outward by a length of 1.
So often people are using the offset with the normal if they want to make sure that vertices get displaced in the outward direction and not any random direction, simply spoken.
And since adding the normal to all points would only blow the mesh up evenly in all directions, which is not desired when you want randomization of the surface, you multiply each point normal with a random value, in case of the tutorial this random value is given by a noise texture.
Multiplying the normals with random values between 0 and 1 scales the normals so that their length changes from 1 to random values between 0 and 1, and thus making the offset not uniform for all points while still preserving the direction in which they are moved.
The Set Position node sets/offsets the positions of vertices, not only the edges but also the surfaces and it does exactly that in the tutorial directly after he plugged the multiplied normals into the Offset. The reason it only affects the edges is the way he combines the original mesh and the displaced mesh via a Mesh Boolean node.
To further explain the process of moving outwards in normal direction scaled by a noise texture, I tried to visualize it with a simplified 2D example.
Below you can see some vertices and their normals. They have a length of 1, so if you would use them directly as offset, the original position of the vertices would be moved a distance of 1 in direction of the normal.
In case you don't want a uniform outward movement on all vertices, you can (as one of different possibilities) use a Noise Texture which assigns a random value to each of the vertices. Since the texture produces values between 0 and 1, the normal gets scaled down to some percentage of its original length. Plugging this now into the offset moves the vertices only that percentage along the normal direction.
To avoid misunderstanding: The normal itself is of course not changed, it keeps its length of 1, it is just shortened in the image above to show the effect of multiplying it with a smaller value.
Now another thing which you could then do is, if the overall effect is too much or not enough, you can either scale it further down with a Vector Math node set to Scale with a value < 1 to decrease the effect, a value > 1 to increase it or even a negative value to move the vertices to the inside instead of the outside.
This group shows all the signs of having been created 'The Artist's Way', by improvisation, trial and error, so, from a mathematical point of view, your puzzlement is perfectly reasonable.
The 'Normal' to a plane is an outward unit-length vector perpendicular to the plane. When it comes to 'faces', only triangular faces are guaranteed to be planar.
Behind the scenes, effectively, faces are triangulated to calculate Vertex-Normals.
A 'Vertex Normal' is the average of the Normals of all the triangles that meet at the vertex.
If you offset a vertex by a positive scale of its Vertex Normal, you will move it outwards in a direction approximately perpendicular to the surface at that point.
What does multiplying a normal of a point with random vector result?
If you multiplied a Vertex-Normal by a random positive vector, the result would be a vector pointing somewhere in the outward-facing hemisphere around it. However, this group does not do that. It casts the
vector to a
float in the Math node. (Blender does that by taking the average of the components (RGB=XYZ) of the vector.)
So the result of the Vector Multiply (which casts the
Float back to a (f,f,f)
Vector) is a uniform scale, resulting in an offset exactly in the direction of the Vertex Normal, by a random amount.
The cast of
Float, because of regression to mean, results in a 'greying out' of the noise-variation.. a reduction in contrast between high and low values. This is perhaps why the tutor mentions there's not much effect, and feels the need for a Power node.
Why does this only change points on the edges but not on the surfaces?
The offset affects all points. The key to why it appears to affect only edges is the combination of Subdivision Surface and Boolean.
The (Catmull Clark) subdivision, because it interpolates adjacent faces, draws inwards only the vertices on the edges and corners of the mesh. It leaves the flat regions where they were.
Then the whole mesh is noise-inflated by the offset. But some of the edge vertices are not inflated by as much as they were drawn in by the subdivision. So when the Boolean Intersect is performed, they are still inside the un-subdivided mesh. The inflated flat faces are outside to the un-subdivided mesh, so the intersection cuts those away.
Someone on BSE may be able to suggest alternative, more economical, routes to this effect? That may be worth posting as another question.