2
$\begingroup$

I'm trying to figure out how to use normals of a target as Ray Direction in the Raycast node instead of the source's normals, so that my source wraps around the target as if I was using a Shrinkwrap modifier set to Target Normal Project.

Here's my setup:

Nodes

I tried adding a Capture Attribute node between the Subdivision Surface and Raycast nodes set to vector with the Normal node plugged in and using that for Ray Direction, but that doesn't seem to do anything.

I also tried the same, but with the Transfer Attribute node, which kinda works, but the result is all jaggy because of the interpolation.

I thought about using the Raycast node in reverse, but I can't figure it out.

Here's an animation of two overlapping objects, one with the geometry nodes setup (yellow) and the other using shrikwrap (orange) wrapping around an not-selected wall. I want the yellow object to behave the same way as the orange one.

Animation

And here's how the Shrinkwrap modifier looks:

Shrinkwrap Modifier

$\endgroup$

2 Answers 2

1
$\begingroup$

The problem is that the raycast goes from individual points along the source geometry in the ray direction looking for the target geometry. Since everything is from the source's perspective, the source position and ray direction inputs to the Raycast node are evaluated in the context of the source, not the destination. Your use of normal * -1.0 is the right idea, but the wrong normal. It's the normal of the source point.

What you need is some way to go from a source point to a target normal. This is always going to be an approximation. One way is to just look at the nearest point on the target mesh. In this graph, remember that the unconnected sample position on the left is implicitly the position of the source geometry:

node diagram using Sample Nearest Surface

If you had a really detailed mesh that might not be correct and you might need to iterate or otherwise improve the approximation.

You can also extend this idea if you're doing some kind of "shrink wrap" by offsetting the source position a tiny bit so that you always cast from the outside even if the source geometry is sometimes slightly inside the mesh:

enter image description here

$\endgroup$
0
$\begingroup$

I guess you probably found the solution now, but if you use the Sample Index Node set to Vector and Face and connected to the Normal Attribute it will work between the Subdivision Surface Node and the Raycast Node.

enter image description here

$\endgroup$

You must log in to answer this question.

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