Randomize UV shell between 3 positions

   791   8   1
User Avatar
Member
12 posts
Joined: 7月 2026
オフライン
Hello! i just started learning Houdini and im trying to create a newspaper pile generator as a practice.
At this moment im trying to randomize the position of the first page of the newspaper over 3 positions of my texture because i want to limit the drawcalls.
Here i join a screencapture:

I've centered the uv shell with a vertex wrangle and some code i've found.
But i can't get it to move to the coordinates of the add node:

How can i solve this?
Thx in advance!

Attachments:
setup.png (2.1 MB)
add_node.png (43.6 KB)

User Avatar
Member
152 posts
Joined: 10月 2015
オフライン
Hello ,
so you could use an expression like this in a wrangle (acting on point or vertices depending of your uv attribute kind)

v@uv+=point(1,"P",chi("point_number"));

the click the + stuff above the code to have the slider
then in the slider you can use an expression to vary the point to choose randomly with your iterations for example
User Avatar
Member
12 posts
Joined: 7月 2026
オフライン
Benjamin Lemoine
Hello ,
so you could use an expression like this in a wrangle (acting on point or vertices depending of your uv attribute kind)

v@uv+=point(1,"P",chi("point_number"));

the click the + stuff above the code to have the slider
then in the slider you can use an expression to vary the point to choose randomly with your iterations for example

Wow that worked like a charm, thank you!
The thing is that all the uv shells of the instances jump to the same coordinate... can't they be randomized??

Attachments:
Newspaper.png (1.2 MB)

User Avatar
Member
9720 posts
Joined: 7月 2007
オフライン
road_to_cga
The thing is that all the uv shells of the instances jump to the same coordinate... can't they be randomized??
you can randomize it based on 'iteration' detail attribute from your metadata1 block begin node
alternatively, you can avoid for loop by enumerating points on the line as an attribute and after copy you can use that attribute to randomize your UVs

would be easier if you post an example file with your issue
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
12 posts
Joined: 7月 2026
オフライン
tamte
road_to_cga
The thing is that all the uv shells of the instances jump to the same coordinate... can't they be randomized??
you can randomize it based on 'iteration' detail attribute from your metadata1 block begin node
alternatively, you can avoid for loop by enumerating points on the line as an attribute and after copy you can use that attribute to randomize your UVs

would be easier if you post an example file with your issue
Yes ofc, sorry
Image Not Found

Here we have my file

Attachments:
issue.hip (599.3 KB)

User Avatar
Member
152 posts
Joined: 10月 2015
オフライン
i can explain it too if you want to try
first you got to know the iteration number you are at in the foreach loop
to do so you got to create the metadate node like this ;


then you can plug like this ;




the code ;

int ite=detail(2,"iteration",0);
int choice=int(rand(ite+chi("seed"))*npoints(1));
v@uv+=point(1,"P",choice);

first line grab the iteration number from third slot a detail attribute called iteration
second line create a random choice between all your point (the npoints(1) give me the number of point you have)
then third line is the same except i'm using the choice variable i just create randomly

don't forget to press the + button so then you can move the seed value and have different result
i hope you can learn something from this
Edited by Benjamin Lemoine - 2026年7月29日 07:00:56

Attachments:
create_metadata.png (92.7 KB)
plug_to_wrangle.png (120.1 KB)

User Avatar
Member
12 posts
Joined: 7月 2026
オフライン
Benjamin Lemoine
i can explain it too if you want to try
first you got to know the iteration number you are at in the foreach loop
to do so you got to create the metadate node like this ;
Image Not Found


then you can plug like this ;

Image Not Found



the code ;

int ite=detail(2,"iteration",0);
int choice=int(rand(ite+chi("seed"))*npoints(1));
v@uv+=point(1,"P",choice);

first line grab the iteration number from third slot a detail attribute called iteration
second line create a random choice between all your point (the npoints(1) give me the number of point you have)
then third line is the same except i'm using the choice variable i just create randomly

don't forget to press the + button so then you can move the seed value and have different result
i hope you can learn something from this

Thank you Benjamin.
It worked!
I had also forgotten to connect the metadata node to the attribute wrangle node. XD
Thanks again!

Attachments:
result.png (1.4 MB)

User Avatar
Member
9720 posts
Joined: 7月 2007
オフライン
here is the mentioned no for loop method

Attachments:
issue_no_for_loop.hipnc (554.8 KB)

Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
12 posts
Joined: 7月 2026
オフライン
tamte
here is the mentioned no for loop method

Thank you o much! Looks pretty clean!
  • Quick Links