4
$\begingroup$

I have set a Raycast node to shoot rays in Normal positive direction.
I want to target Sphere object (for height map). It works perfectly for convex shapes, but issued for concave surface. Rays hit Sphere from sides and generates faked (unwanted) height.

How can I limit rays only for those that hit negative Normal of target object?
(marked red in screen)

enter image description here

  • Grey ray - isn't hit
  • Blue ray - hits positive normal of target (to be seen as "isn't hit")
  • Red ray - hits negative normal of target

In this example with Monkey - visible on ear.

$\endgroup$

1 Answer 1

4
$\begingroup$

Instead of using the Hit socket from Raycast, you could do a separate Is Inside? check for the spheres, and use that as your multiplier, automatically eliminating hit distances that's coming from outside the target mesh:

enter image description here

The Is Inside? node group is down below. For every point of a sphere, it gets a vector that reaches from the vertex to the closest point on the target surface, then calculates the Dot Product of that vector and the Normal of the hit surface; meaning, it checks to see if these two vectors are pointing in the same direction―when the dot product is positive, the vertex is inside the target mesh.

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ It seems you are answer for everything for me :) Thanks for quick response ... "Sample Nearest Surface" node ... Undefined? Blender 3.5? $\endgroup$
    – vklidu
    Nov 20, 2022 at 20:30
  • 1
    $\begingroup$ Yeah I'm using 3.5. Sample Nearest Surface is one of the new nodes that replaced the Transfer Attribute node (you can still use that for now if you want): blender.stackexchange.com/questions/276087/… $\endgroup$
    – Kuboå
    Nov 20, 2022 at 20:31
  • $\begingroup$ Oh ... thanks ... and btw nice solution :) Proximity should cover most of the cases. Speaking to Monkey example I guess there is not a solution for sphere on top oh monkey's head, like seen from top (cage) so height map will represent this sphere seen from outside (means in its max diameter) ... now it takes into account only middle part. I'm just currious, if you think there is an solution I will ask a new Q. $\endgroup$
    – vklidu
    Nov 20, 2022 at 21:05
  • $\begingroup$ It's hard to understand just by words. Sphere on top of the monkey's head looks like this in my setup: i.imgur.com/HcTbvsF.jpg What do you mean by "only middle part"? Can you draw on this image to explain the problem perhaps? $\endgroup$
    – Kuboå
    Nov 20, 2022 at 21:10
  • 1
    $\begingroup$ I played around with the setup more and indeed it does fail in some cases, though I have to admit I don't understand why exactly--I didn't get your "pass through mushroom leg but can't reach whole hat" comment haha. Anyways, luckily there are smarter people with more robust "Is Inside" setups out there. I tried Bradley Animation's and it seems to work. It's called "G_Is Inside Volume". You can download it free: bradley-animations.gumroad.com/l/… $\endgroup$
    – Kuboå
    Nov 20, 2022 at 22:32

You must log in to answer this question.

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