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?
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?
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:
'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:
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:
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:
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):
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
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