I've developed a camera frustum culling tool in Houdini's Solaris environment using VEX. My tool calculates camera transformations over time to ensure all primitives are accurately included for culling throughout an animation sequence. I retrieve the camera's transformation using usd_attrib and usd_worldtransform with time-sampled values, as shown below:
for(inttime = int(start_frame); time <= end_frame; time += int((end_frame - start_frame) / frame_sample)){matrixcamTransform_anim = usd_attrib("opinput:0", cam_path, "xformOp:transform", time);
}
Although I iterate over the necessary frames to capture every relevant position of the camera, evaluating every frame's transformation is not required beyond this point. Essentially, I wish to consolidate the time-sampled data into a static form after this iteration, as my culling decision doesn't need to be recalculated for every frame thereafter.
Could you advise on how to either prevent the automatic evaluation of attributes at every frame or how to remove/flatten these time samples after they've been calculated? I aim to optimize the tool by avoiding unnecessary recalculations of the camera's position outside the specified frame range.
on your Attrib Wrangle VOP set Sampling Behavior to Sample Frame Range and set it to a single frame range like 1,1,1 or whichever single frame you want to have your timesample on, like 1001, 1001, 1
this way it will author your property only on that frame running the computation once
tamte on your Attrib Wrangle VOP set Sampling Behavior to Sample Frame Range and set it to a single frame range like 1,1,1 or whichever single frame you want to have your timesample on, like 1001, 1001, 1
this way it will author your property only on that frame running the computation once
thank you for reply but I am using houdini 19.5, there's no Sampling Behavior options. is there any other way?
dishuman but the param seems also green, it's still timesample base.
Yes, it should have exactly 1 timesample, it shouldn't execute your code more than once
I personally dont know another way that wouldn't recompute when you change frame
Thank you for your reply again I think it's related to the build in function 'usd_attrib' if use a specific time number, should return non-time sample result.
dishuman Is there any way to remove the attribute timesample for now?
You'd probably need to dip into the USD Python API to do this. For example:
prim=stage.GetPrimAtPath('/cameras/camera1')attr=prim.GetAttribute('cam_trans')val=attr.Get(0)# query a time-sample valueattr.Clear()# remove all the time-samplesattr.Set(val)# set a default (non-time-sample) value
At this point you might consider just doing the whole process in Python instead: