2
$\begingroup$

I'm trying to replicate the behavior of a light source being shot to a mirror using Geometry Nodes, so the angle of incidence and the angle o reflection are the same.

In my setup, I set the endpoint Position of a line to the surface of a target, and then extruded that endpoint. However, I couldn’t figure how to match the angles properly. I was only able to extrude by the Normals of the target’s surface, or completely wrong angles.

enter image description here

This is what I’m trying to accomplish.

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ I apologize beforehand that I cannot provide a good answer, I only want to give a hint in a (possibly) right direction. In the Vector Math node you have the mode Reflect. As far as I know this calculates the reflection vector of two vectors (the ray vector and the surface normal?). However, and that's why I cannot write an answer, I don't seem to get it to work correctly. Maybe you can find out how to use Reflect. $\endgroup$ Apr 28 at 7:03
  • 1
    $\begingroup$ Gordon's done the job.. so not posting this as an answer, but here's another version that modifies a 'Ray Gun' object and uses Ray Cast to a given target . $\endgroup$
    – Robin Betts
    Apr 28 at 10:09
  • 1
    $\begingroup$ Thanks, Robin Betts, for this alternative. This is version using Ray Cast is a very interesting approach. $\endgroup$ Apr 29 at 1:12

1 Answer 1

4
$\begingroup$

I've recreated your nodetree to get a similar setup like you have. The reflection is calculated in the frame titled "REFLECTION ON SURFACE".

It is basically doing two things: First evaluating the normal of the target surface which you already had in your nodetree. Next using the Vector Math node set to Reflect to calculate the vector of reflection between the position on the surface and the surface normal, then using this as offset for the Extrude Mesh node instead of the normal in your setup.

reflection reduced setup

Note: Usually I would get the vector of the incoming mesh line by subtracting the position from (0, 0, 0) and then plugging it into the Reflect node. This would result in a vector that needs to be scaled by -1 to get the correct result.

To save some nodes, the scaling wouldn't be necessary if instead of subtracting the position from (0, 0, 0), you could switch those inputs and subtract (0, 0, 0) from the position which is simply the position itself. In this case with the lines' Start Location at (0, 0, 0) it works to get rid of a Subtract and a Scale node.

The "full" setup would look like this:

reflection full setup

And this is the result viewed from the side and the top. I've reduced the number of lines to 3 and the Offset Scale on the Extrude Mesh node to 0.5 so that it becomes more cleearly visible which the reflected lines are.

reflection result

$\endgroup$
1
  • 1
    $\begingroup$ Thank you. The solution was a lot simpler than I thought it would be needed. I didn't even know that you could extract that information from the position socket of the Geometry Proximity node. $\endgroup$ Apr 29 at 1:12

You must log in to answer this question.

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