5
$\begingroup$

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?

$\endgroup$

2 Answers 2

6
$\begingroup$

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.

normal offset

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.

scaled normal offset

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.

$\endgroup$
3
  • 3
    $\begingroup$ You could hardly have explained it better, good job! $\endgroup$
    – quellenform
    Nov 3, 2023 at 8:54
  • 1
    $\begingroup$ cool. This is super helpful. I was wondering, and this is mathematical, does multiplying normal by a random value not change the direction of the vector? In that video a normal is multiplied by a random vector? $\endgroup$
    – ph_zero
    Nov 3, 2023 at 18:05
  • 1
    $\begingroup$ @ph_zero If he would actually multiply by a vector, i.e. the X, Y and Z components separate from each other, this would have changed the direction. However, he is plugging the Color output (x, y, z) of the noise into a standard Math node - not a Vector Math - which only accepts a float as input, which automatically converts the vector input into an average float, so (x, y, z) becomes (x+y+z)/3 and he could have simply used the Fac output of the Noise Texture node. This way it works like in my example and the vector is scaled uniformly on (x, y, z) and does not change its direction. $\endgroup$ Nov 3, 2023 at 21:16
3
$\begingroup$

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.

Normals

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.


enter image description here

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 f 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 Color (Vector) to 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.

$\endgroup$
4
  • $\begingroup$ Stop boasting with your knowledge by explaining what I already did, just better :D $\endgroup$ Nov 3, 2023 at 10:56
  • $\begingroup$ Sorry @GordonBrinkmann ... I'd started writing mine before yours was posted.. Yours illustrates what a Normal is much better.. it's a lovely post. I just thought this would still be an OK supplement. (I have to confess, part of my motivation was mild irritation with the toot :) .. probably unfair ) $\endgroup$
    – Robin Betts
    Nov 3, 2023 at 11:02
  • $\begingroup$ I know this starting to write an answer and not getting finished before someone else comes up with one :) But all good, you also talk about the boolean part which I didn't. $\endgroup$ Nov 3, 2023 at 11:07
  • 1
    $\begingroup$ Thanks for pointing out casting of float to a vector and the result of multiplying normal by a uniform vector $\endgroup$
    – ph_zero
    Nov 3, 2023 at 18:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .