I just can't figure this out.
How do I extrude polys by a random amount?
If I type the following expression into “Depth Scale” all polys have the same random extrusion: rand(1)
So, I created an a random attribute r that differs on each poly.
But, typing this won't work either:
prim(opinput(“.”,0),$PR,“r”,0)
How to do it?
Random Extrusion?
6810 3 0-
- Soothsayer
- Member
- 875 posts
- Joined: Oct. 2008
- Offline
-
- Soothsayer
- Member
- 875 posts
- Joined: Oct. 2008
- Offline
Interestingly, typing this python expression doesn't produce an error but still extrudes all polys the same amount:
hou.node('/obj/geo2/random_attribute').geometry().prims().floatListAttribValue('r')
I would have thought they do exactly the same as
prim('/obj/geo2/random_attribute',$PR,“r”,0)
?
hou.node('/obj/geo2/random_attribute').geometry().prims().floatListAttribValue('r')
I would have thought they do exactly the same as
prim('/obj/geo2/random_attribute',$PR,“r”,0)
?
--
Jobless
Jobless
-
- graham
- Member
- 1926 posts
- Joined: Nov. 2006
- Offline
The main problem with your extruding is that the Extrude Sop doesn't know about the variable $PR. It has no idea what it is. This can be observed by simply putting $PR in the Depth Scale parm. In order to do this you will want to use the PolyExtrude Sop with your expression in the local TZ parameter. This works as expected.
Typing the rand(1) value gives you all the faces extruded by whatever the rand function returns as Extrude is not evaluating on a per primitive basis as described above. Same with why prim(opinput(“.”,0),$PR,“r”,0) doesn't work.
As for your Python expression not being the same that is because it is only ever evaluating primitive 0 every time, whereas the hscript is using $PR so since each prim has a different value than primitive 0 the result will be different.
I should also mention that since you are using the attribute create it is creating a local variable you can use so instead of a prim() expression you can merely use $R to get the value of the r attribute for each prim. In Python expressions you can use lvar('r').
Hope that helps.
Typing the rand(1) value gives you all the faces extruded by whatever the rand function returns as Extrude is not evaluating on a per primitive basis as described above. Same with why prim(opinput(“.”,0),$PR,“r”,0) doesn't work.
As for your Python expression not being the same that is because it is only ever evaluating primitive 0 every time, whereas the hscript is using $PR so since each prim has a different value than primitive 0 the result will be different.
I should also mention that since you are using the attribute create it is creating a local variable you can use so instead of a prim() expression you can merely use $R to get the value of the r attribute for each prim. In Python expressions you can use lvar('r').
Hope that helps.
Graham Thompson, Technical Artist @ Rockstar Games
-
- Soothsayer
- Member
- 875 posts
- Joined: Oct. 2008
- Offline
-
- Quick Links

