7
$\begingroup$

Is it possible to reference World coordinates in Geometry Nodes without using an external object?

For example, can you establish a ray direction for the Raycast node which always points towards global X (1,0,0) no matter the object's rotation?

$\endgroup$
3
  • $\begingroup$ That's a good question, and I hope someone comes along with a "proper" answer. Until then - does it absolutely have to be without an external object ? I only ask because I think it could be achieved relatively easily if you used an empty for the "reference location" . $\endgroup$ Commented Mar 19, 2022 at 0:16
  • 1
    $\begingroup$ I'm not against learning Object Info tricks, but it's not always feasible or optimal having to use an external object, especially when sharing node groups and assets with others, preventing a "just append, and it works" type of workflow. Still, what would your neatest solution be if an external object was ok, if I may ask? $\endgroup$
    – Kuboå
    Commented Mar 19, 2022 at 0:39
  • 1
    $\begingroup$ To be honest - I learned all of geometry nodes for 2.93 - then they changed it for 3.0 alpha - so I learned it again for 3.0 alpha - then they changed it for 3.0 official - now I'm still in the process of re-learning it for 3.0 official and I haven't even looked to see what's changed for 3.1. Needless to say, you're probably best being advised by someone other than me when it comes to "new" geometry nodes. I only mentioned it because empties have classically been the "go to thing" for a reference point, or "non-existent" (for the purpose of the scene) reference object. $\endgroup$ Commented Mar 19, 2022 at 0:51

2 Answers 2

5
$\begingroup$

Would you be OK with an Object Info that references the object itself? Then you could invert the object's own transformation to get to World coordinates:

screenshot showing node graph of object-world transformation

'Self' is the input you would need to set to the object itself, and the 'Calculate Origin Vector' frame does all the work of inverting the transformation. The 'Project onto Target' frame does a Raycast onto the input Target. Here are two Mesh objects, each projected onto a Suzanne at the origin:

screenshot showing raycasts from two mesh objects

The inversion breaks when one of the scale components is negative - the Object Info doesn't seem to give you the negative-ness, so you can't invert it.

Here is the blend file: https://pasteall.org/media/1/3/133c230497bbf9a522b184ff0b2c9fff.blend

There is an extra frame in there that projects individual lines from each point of the object to the origin:

screenshot of radial line projection nodes

screenshot of radial lines


Edit to add 'parallel rays' option. [I kinda understood the previous bit, but this next bit is at the edge of my intuition right now, so I am just futzing around to make it work. Maybe it will become more clear on reflection.]

If you want to specify a single raycast direction in World coordinates, the Location / Translation component of the Object Info is irrelevant, and so is the Position of the vertexes you're projecting from. It looks like you just need to transform your chosen direction vector by the Object Info's Rotation and Scale, and plug that into the Raycast node:

screenshot showing node layout for parallel projection

The Combine XYZ node sets the projection direction (in this case -Y (0,-1,0). First image below is the Back Orthographic, showing how the projection is straight down the Y axis. Second image is a perspective. (I've subdivided my mesh to get better resolution since my first post):

screenshots showing parallel projection

You could bring the projection direction vector out as an input, so you could make it different for each object.

And, acknowledgement to Erindale's video of the Raycast node, without which I couldn't have done this: https://www.youtube.com/watch?v=ZCCQXoJoIK4

$\endgroup$
3
  • $\begingroup$ Hi David, thank you v much for the answer. I had thought about using "self" to do something similar, but I don't know much about math so I was lost. Also not sure I'm understanding everything going on here so let me ask for an example so I can grasp it. With your setup, rays coalesce on the world origin in a prism. How would you send them all on the -Y direction, parallel to each other, like this: i.imgur.com/VfKdc1M.png ? If I change the vector math to "Add" instead of subtract and use that as the Set Position vector, I get sth like it, but not quite: i.imgur.com/rTxYpPT.png $\endgroup$
    – Kuboå
    Commented Mar 20, 2022 at 0:23
  • $\begingroup$ Hi @Kuboå - I'm not sure I understand everything going on here! :) I've had a go at the parallel projection and it seems to work fine. Happy to be corrected. $\endgroup$
    – David Wood
    Commented Mar 20, 2022 at 21:42
  • $\begingroup$ Thank you! Now it clicked for me. It is pretty easy, actually! Rotate your desired world-coordinate vector by the same amount of your object's rotation in reverse so the rotation (if there's any) is negated. Your first setup ties it to the object's world-location, creating a mirror effect with the world origin as the pivot, which was not I had in mind and that's what confused me. I also didn't understand dividing by scale since it didn't seem to do anything but now I see that it's only for the cases where the scaling is not uniform in all axis. If only we had a "self" toggle for Object Info... $\endgroup$
    – Kuboå
    Commented Mar 21, 2022 at 8:48
1
$\begingroup$

For reference, I provide here another approach that avoid the need to reference self everytime. It just needs an arbitrary fixed object hardcoded into the modifier, and uses then the Relative and Original options of Object info to recover the position of the current node (unfortunately this approach fails when the object is scaled) Blender: get/set absolute location of object in Geometry nodes

$\endgroup$

You must log in to answer this question.

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