9
$\begingroup$

I'm working on a project in blender and I've encountered a problem. I want to make a marble run. I have a tube that the marble will go through. It is made from a few hollow cyllinders. I want to make each one of them glow when the marble goes through them. Kinda like with lights that detect movement. I'm still pretty new so I've started messing around with geometry nodes but I have no idea what to do and cant't find something that would help me. If anyone has any ideas or videos on yt or smth. with tutorial for that it would me really helpfull.

$\endgroup$

5 Answers 5

15
$\begingroup$

You could use a Geometry Proximity node to check how close an object's (here, a marble) mesh is to the tube's and output that information as an attribute, which then can be used in its material to affect any channel you want (here, emission strength):

enter image description here

enter image description here

Details can change depending on your specific needs. For instance, since this setup affects the faces independently and the marble is always slightly closer to some faces then others, you can get frames in your animation where not all of a tube part's faces light up at the same time (1). That might be an effect you like, it might not be. If not, you could, for instance, forgo the output attribute altogether, and set the material wholesale inside GeoNodes instead (2):

enter image description here

enter image description here

Note that you're not limited to outputting a 0/1 boolean filter (is it close or not?), you could, say, output the Distance socket directly and do calculations with that number inside your shader (maybe your glow will get brighter and brighter as the marble gets close, instead of just being on/off). You could also employ the Group Input side, for ex, to bring in vertex groups etc...

$\endgroup$
6
$\begingroup$

The "classic" solution with shaders could look like this: Use this nodegroup in your material:

enter image description here

You material of each tube looks like this: so you can easily choose your colors.

enter image description here

result:

enter image description here

$\endgroup$
4
$\begingroup$

Kuboå solution is good, but the problem is that it works only for one marble. As I understand, the problem is that there are a lot of marbles and a lot of tubes, which may interact with each other. So there is my solution:

enter image description here

The key things here:

  • If you are using rigid body physics, record it into keyframes first, because Blender will address to initial coordinates, not real ones. So you have to record physics to keyframes (Object ⇾ Rigid body → Bake to keyframes)

  • To get coordinates to each tube, you need to get object data. The only way to do this is to make Object Input field and set object itself for each GN modifier:

enter image description here

  • To set color output data into vertex color:

enter image description here

Now, how it works. We get all marbles from collection "marb" and calculate the distance between each of them and the current tube. Then we get the closest distance using Attribute Static node. This information goes into Vector color "Col" and used in Emission input of shader.

$\endgroup$
1
  • $\begingroup$ Good point, I didn't consider multiple marbles at all. I really hope we get an "Object Info—Self" node or mode soon, the need for it turns up quite often and it's cumbersome to set up as a group input. $\endgroup$
    – Kuboå
    Mar 31 at 13:53
3
$\begingroup$

Update 3: Faster method and no interference from outside marbles

render result

As you can see, with this method marbles don't affect the tubes from outside.

Explanation:

First, create the tube. Then, in Geometry Nodes, create a long thin cube in the tube's center:

cube inside tube

In the Geometry Nodes, we get the proximity to the cube of all the marbles in a collection and send the smallest distance to an attribute.

Geometry Nodes

naming attribute

material nodes best

In the material we just need to calculate if the distance is less than the needed to activate the glow. Play with the value or use the cube's distance to the tube's wall.

Done, you can just duplicate the cube to get another glow tube.

$\endgroup$
2
2
$\begingroup$

Is this the intended result? https://youtu.be/VDdW__7_pAE

Every cylinder is a different object, but they all share the same geometry nodes.

Raycast with the balls position as source position.

Since the cylinders are not closed meshes the inside/outside detection is a bit special. If they always are located in the same plane it would be enough to send a ray in one direction. I opted for one ray along each axis. This should be enough for tube shaped meshes located in any orientation.

The raycast part should be grouped. Repeated three times here to show everything in one image.

Geometry nodes

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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