Search - User list
Full Version: Randomize UV shell between 3 positions
Root » Houdini Indie and Apprentice » Randomize UV shell between 3 positions
road_to_cga
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!
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
road_to_cga
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??
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
road_to_cga
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
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 ;


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
road_to_cga
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!
tamte
here is the mentioned no for loop method
road_to_cga
tamte
here is the mentioned no for loop method

Thank you o much! Looks pretty clean!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB