5
$\begingroup$

I'm trying to make a chocolate bar that looks realistic and I'm looking for advice.

This is my reference: enter image description here

Before reading the below, if anyone just has any tips in general for how to achieve this I would love to hear it!

That said...

My first attempt is to use Geometry Nodes to scatter a bunch of sphere across the surface of a vertex group. But there are some issue with this:

  1. It is VERY processor intense. Even with an Intel 13900KS my viewport is struggling. In this example it is workable, but as soon as I try and level up to any kind of realistic detail (i.e. scattering more points, adding more geometry to instance, etc) I'm dead.

And speaking of Geometry Nodes:

  1. For some reason, even though I have a vertex group selected in my GN setup, it is also trailing the spheres down the side of the object (but for whatever reason not on the top, bottom, or back).

This is what I've got so far, and my setup:

enter image description here

enter image description here

Note that I have my vertex group set up thusly:

enter image description here

enter image description here

But this is what is happening:

enter image description here

PROJECT FILE

Would love advice, tips, redirection, etc, thanks!

$\endgroup$
4
  • $\begingroup$ blender.stackexchange.com/questions/84745/… $\endgroup$ Jan 21, 2023 at 15:27
  • $\begingroup$ Hey @DuarteFarrajotaRamos thank you for highlighting that. That does seem to be a possible solution to my project and I will try it out. I was under the impression that particle systems were more processor intense than Geometry Nodes, but I did have to use a "Realize Instances" node in order to make it work, so that probably negates the above. $\endgroup$ Jan 21, 2023 at 20:56
  • $\begingroup$ I wonder why the concern with viewport performance? Isn't this a one-off .. the modifiers would all be applied? $\endgroup$
    – Robin Betts
    Jan 22, 2023 at 20:53
  • 1
    $\begingroup$ @RobinBetts I would like to keep it dynamic so I can make changes as needed, but the changes take such a frustratingly long time to see already that I don't think leveling up the amount of particles I want/need for realism would even work. I keep getting Blender's "white screen of death" and have to force quit and try again :( $\endgroup$ Jan 22, 2023 at 21:05

1 Answer 1

2
$\begingroup$
  1. It is VERY processor intense

Unfortunately, boolean operations in Blender are notoriously slow. For anything but the smallest scale examples, I'd even claim that it's basically unusable. The Fast mode on the Boolean modifier (as opposed to Exact) is more performant, but that also comes with its own problems regarding accuracy:

enter image description here

Duarte Farrajota Ramos' suggestion might be worth investigating, but it still requires boolean. If that turns out to be a non-starter, I think it'd be a good idea to perhaps look for a shader solution. There are many tutorials for foam or sponge-like shaders, it might not be that hard to customize one of them for chocolate. Or you might distribute and boolean some small amount of real mesh spheres but blend it with a shader to help bridge the gap.

  1. For some reason, even though I have a vertex group selected in my GN setup, it is also trailing the spheres down the side of the object (but for whatever reason not on the top, bottom, or back).

In your setup, you are distributing spheres on a vertex group ("This") of a big cube object ("Hole Node Setup"), then subtracting them from your Chocolate object. The vertex group of Chocolate ("Holes Here") isn't used anywhere in the setup. Chocolate and the big cube share their bottom and side faces, but not their top; that's why there are no holes on the top of your chocolate object. There are no holes on the back face because there are no spheres distributed on the big cube there as well:

enter image description here

That's fine, but why are some spheres distributed on the side faces of the big cube in the first place, when your vertex group doesn't include those faces? The technical answer is "domain interpolation". A vertex group is exactly that: a vertex group. If a face gets selected by a vertex group, that's only because all its constituent vertices are selected—it is a side effect. The Distribute Points on Faces node, however, uses Face Corner as its domain (why not the Face domain, I've no idea). So, when you feed the Selection socket with your vertex group, you are giving the Distribute node a bunch of vertices, not faces, and in turn it asks "Which face corners these vertices belong to?"—meaning, it interpolates values between the Point domain and Face Corner. The four vertices of the vertex group each belong to three corners of three faces, so those (side) faces get a bit of point distribution as well. Side faces have only half of their vertices/face corners selected though, so they get about half as many points as the front face (notice they get sparser towards the back). The back face doesn't have any of its vertices or face corners in the vertex group, so it doesn't get any points.

We can demonstrate this easily using a cube with its side faces subdivided a bunch of times. Notice how the distribution spills over to the neighboring side faces, but since those faces are smaller, points don't go that far back:

enter image description here

So, a vertex group might not be the best way to make a selection in this case. Depending on the specifics of the object and the setup, you can use many other methods to do that. Here are two examples where we filter by the direction of the face (using Dot Product) and simply by its index:

enter image description here

Evaluate on Domain used to be called Interpolate Domain. Here, it instructs the Distribute node to specifically consider the Face indices instead of using its default domain (Face Corner).

$\endgroup$
4
  • $\begingroup$ Thinking about a really close imitation of the foam, this one has me thinking about sphere-packing with GN.. (possibly using simulation?) .. may post that as a Q of my own... $\endgroup$
    – Robin Betts
    Jan 22, 2023 at 20:50
  • $\begingroup$ @RobinBetts OP actually had a question about volume packing a while back: blender.stackexchange.com/questions/280669/… I had a rudimentary answer there but I'd love to see better methods if they exist. For 2D surface distribution maybe an iteration on Entagma's Relax Points method: youtube.com/watch?v=rr0_cgP3WfY ? $\endgroup$
    – Kuboå
    Jan 22, 2023 at 20:56
  • $\begingroup$ What a great Kuboå answer (that I'd previously missed) ! I'm so glad I didn't work too hard on my own before you pointed it up.. thanks! Yup.. I'm subbed to Entagma :) $\endgroup$
    – Robin Betts
    Jan 22, 2023 at 21:05
  • 1
    $\begingroup$ @Kuboå Thank you for this answer and explanation about the faces/vertex group behavior. (Also note that I screwed up in my post and actually renamed "This" to "Holes Here" after I took that screenshot, but in reality they were the same vertex group, sorry for that confusion!) Your thorough explanation is very helpful, as well as your solution in geonodes... I'm going to apply it now. Cheers! $\endgroup$ Jan 22, 2023 at 21:08

You must log in to answer this question.

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