How to Use One Point attributes on Other Points in a VOP?

   320   2   0
User Avatar
134 posts
Joined: July 2010
I'm working on a 3D star catalog HDA.
It reads in a catalog of points with the 3D position of stars.
I want to fly through them, so I need to be able to calculate the distance from the camera to each point on a per-frame basis.
Which is needed to update the star color and brightness.
I have an object path parameter in my HDA where you specify the camera.
Inside the HDA, a fetch SOP references the object path.
I make a null a child of the fetch and call it starCamNull.
Inside another Geo node, I object-merge the point inside the starCamNull.
This is fed into the 2nd input on an attribute VOP.
The first input receives the 3D star point cloud.
Inside the VOP, I use a Geometry VOP Global Parameters node to get the star P point.
I use an Import Point Attribute node with Input set to Second Input, to get the camera point.
I then use a Distance node to measure the distance from the camera to the star.
The problem is that it is only doing this for the first star point in the list.
The rest are being ignored.
I'm assuming that it's expecting the camera input to have the same number of points as the star catalog, which would be inefficient.
Is there a way to force the VOP network to apply the calculation using the one point from the camera to all the points in the star catalog?
Edited by syntheticperson - Aug. 4, 2022 19:43:57

Screen Shot 2022-08-04 at 3.49.13 PM.png (20.3 KB)
Screen Shot 2022-08-04 at 3.50.09 PM.png (145.9 KB)
Screen Shot 2022-08-04 at 3.51.24 PM.png (120.7 KB)
Screen Shot 2022-08-04 at 3.57.48 PM.png (117.0 KB)

User Avatar
6693 posts
Joined: July 2007
plug Constant VOP with the value 0 into ptnum input of your import_cam_point node


you can completely avoid the hassle of creating null or objectmerging a point and just transform all your points P to camera space and get the length of it (assuming the camera doesn't have any scaling, which is the default behavior of houdini cameras)

in VOPs it would be:
P -> Transform VOP -> Length VOP -> Bind Export (distance)

Transform VOP would be set to:
from Space: space:current
To Space: ../rel/path/to/the/camera (ideally promote this input and change String Qualifier to List of Objects/Camera Only and disable menu)

in Wrangle:
string cam = chs("cam");
f@distance = length(ptransform("", cam, v@P));
Edited by tamte - Aug. 4, 2022 22:38:08
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
134 posts
Joined: July 2010
I went with your first suggestion for now: Constant VOP with the value 0 into ptnum input of import_cam_point node.
  • Quick Links