Rotate wheels of instanced cars in LOPs

   3097   5   2
User Avatar
Member
169 posts
Joined: Nov. 2013
Offline
Throwing this out here as I've tried a few things and am not sure of the best plan of attack.

I have a pop traffic system which has cars instanced onto the points using an Instancer node in LOPs. The points inside the Instancer have a rotation value stored in an attribute on those points, which I intend to apply to the wheels of each instanced car.

What is the best way in LOPs of applying this value to each instanced car? Obviously I need to isolate the wheels and apply this primvar as some sort of override, and I am assuming that Instanceable Reference/Inherit will be the only instancing that will allow access the various prims of each car.
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
The only way to set a unique-per-instance value on point instancer instances in USD is as a primvar on the point instancer prim, which can only be used to affect the shading of the prim. So if you can "rotate" your wheels in the shader, you shouldn't have to break instancing at all.

If the rotation values fall into "buckets", where some percentage of the cars each share a limited number of rotation values, than you can make separate prototypes for each unique rotation value. So a larger number of prototypes, but still fairly efficient and easy to set up.

If each car has unique rotation values for its wheels, and you can't make the wheels look rotated with just a shader parameter, then your best bet is probably to split the point instancer up. One point instancer would be the cars with the wheel hidden (or absent) from the prototypes. The second point instancer would just be the wheels. Again, you'd need only one prototype, and each wheel would be positioned independently (and rotated independently) by the point instancer. This would require some additional work to create the wheels as separate instances constrained to the car positions with the per-wheel rotations, but it will be very efficient to render.

I'm sure there are other ways to shear this particular sheep, but these are the ones that spring to mind for me...
User Avatar
Member
8538 posts
Joined: July 2007
Online
Rather than doing such work in LOPs Id suggest representing each car as 5 points in SOPs, copy to each of your current car points and use your rotation value to apply to the wheel points rotations or steering, also maybe some additional offsets for 5th point for some suspension, etc
Then just use the resulting points in LOPs to instance chassis and wheels to corresponding points that would already have correct transforms
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
169 posts
Joined: Nov. 2013
Offline
mtucker
The only way to set a unique-per-instance value on point instancer instances in USD is as a primvar on the point instancer prim, which can only be used to affect the shading of the prim. So if you can "rotate" your wheels in the shader, you shouldn't have to break instancing at all.

What about for Instanceable References/Inherits? It looks like each prim inside the car asset is 'accessible' when they are Instanceable References. Is there any way to override transform/rotate/scale values for select instanced prims? Or, like Point Instances, are the only overrideable Primvars those that are used for shading?
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
Hamilton Meathouse
mtucker
The only way to set a unique-per-instance value on point instancer instances in USD is as a primvar on the point instancer prim, which can only be used to affect the shading of the prim. So if you can "rotate" your wheels in the shader, you shouldn't have to break instancing at all.

What about for Instanceable References/Inherits? It looks like each prim inside the car asset is 'accessible' when they are Instanceable References. Is there any way to override transform/rotate/scale values for select instanced prims? Or, like Point Instances, are the only overrideable Primvars those that are used for shading?

The prims inside an instanceable reference are called "instance proxies". They are not editable. Most LOP nodes will put up a warning if you ask them to modify an instance proxy. So yes, like point instancers, the only modifications you can make to prims inside an instanceable reference (without breaking instancing) are setting primvars on the root of the instance which get inherited by contained prims and can drive shaders.
User Avatar
Member
169 posts
Joined: Nov. 2013
Offline
So I've tried Tamte's solution. I can get it working for the most part, but random prototypes plugged into the instancer just seem to be ignored. The instancer throws a cryptic warning if using an attribute like asset_name which exists on both the source points and Prototypes:
Warning 
Skipped instance 8 because it has invalid prototype name "car_subaruforestera_wheel". Also skipped 6 other instances.

Or if I do something simpler like use 'Index Attribute' (my source points have an index attr that is the same as ptnum):
"Warning 
Skipped instance 0 because it has invalid index 43. Also skipped 43 other instances.

Can anyone tell me what an invalid prototype name or index actually is?
Edited by Hamilton Meathouse - Sept. 18, 2021 22:03:24
  • Quick Links