0
$\begingroup$

How does one make an object raycast onto itself? Using these nodes, I get a reaction. The entire mesh scales to twice its size. As if everything is getting cast upon simultaneously. enter image description here

So my assumption is that the rays are in fact hitting the object. Just not actually casting out and hitting at a distance, like you'd expect. Rather, they're touching at the 0 point. So I'm wondering how to make it stop doing that, and actually cast on itself normally. Anyone know how? Or got any ideas?

$\endgroup$
7
  • $\begingroup$ Each point is hitting itself in this setup, and that seems to be what is expected. What do you want to do exactly? $\endgroup$
    – lemon
    Commented Apr 10, 2023 at 8:05
  • $\begingroup$ I don't want each point to hit itself. But also, I want points to be capable of hitting other points on the same object. All the raycast tutorials involve creating two or more objects, and then projecting one object onto another. But what if you only have a single object? And you want to project that object onto itself. Not in totality, but only for the parts that hit. $\endgroup$
    – Smeebit
    Commented Apr 10, 2023 at 16:32
  • $\begingroup$ Simply offset the source position a bit, the way you want. $\endgroup$
    – lemon
    Commented Apr 10, 2023 at 16:36
  • $\begingroup$ How do I do that? I tried attaching a position node, and a vector math node, into the source position, in hopes of shifting the Z coordinate slightly. But when I do that, the mesh warps in a weird way. I'm pretty sure that it's shifting the z coordinate according to global coordinates. But I'm trying to get it to shift Z based on the local position of each point. $\endgroup$
    – Smeebit
    Commented Apr 10, 2023 at 17:01
  • $\begingroup$ You should describe what you want to do, at final. $\endgroup$
    – lemon
    Commented Apr 10, 2023 at 17:04

1 Answer 1

4
$\begingroup$

A mesh can cast on itself, but to avoid each point of the mesh to cast to the same point (which can give some kind of scaling effect), you need to shift the points a bit.

enter image description here

In this setting, the raycast is Z down and the source position is each point of the mesh, but offsetted a bit in the same direction.

As a result, some points effectivelly hit the mesh and others are not affected.

$\endgroup$
4
  • 1
    $\begingroup$ This is what I was looking for. I don't really understand it at the moment, but it works like intended. I found another way to offset the rays by using the "dual mesh" node, and scaling it down slightly, making the dual mesh the target geometry. But I like your way better, because it doesn't require doubling the mesh. Also, if you plug a normal node into ray direction, then it will make all of the rays extend outward from the mesh, and only faces that are facing each other will hit. $\endgroup$
    – Smeebit
    Commented Apr 11, 2023 at 19:46
  • $\begingroup$ cool! happy if I was able to lead you in the good direction. thanks $\endgroup$
    – lemon
    Commented Apr 11, 2023 at 19:48
  • $\begingroup$ I forgot to mention this, but I'm using version 3.5, and it doesn't have a "scale" node. Rather, I had to use a vector math node, set to scale. This was confusing at first. But ended up being beneficial, because vector math's version of scale allows you to manipulate vectors. And so I plugged a normal node into the vector of the scale node. This, I think(?), made it so that each point scaled relative to the normals. Setting the scale value to -0.001, I'm fairly certain it pushed the rays ever so slightly outside of the mesh. Completely eliminating starting collision. I'm not 100% sure, but 90% $\endgroup$
    – Smeebit
    Commented Apr 11, 2023 at 20:27
  • $\begingroup$ FYI, "scale" above is just a value node renamed to "scale". $\endgroup$
    – lemon
    Commented Apr 12, 2023 at 5:11

You must log in to answer this question.

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