Page 1 of 1
					
				Random texture offset (but cloner in cloner)
				Posted: Tue Dec 21, 2021 3:09 pm
				by wriedl
				Hi, 
I am unable to solve the problem I am currently stuck in:
I found great advice on how to randomize texture offset with the OSL shader method and
Code: Select all
color variance = noise("cell",rndm, Seed);
c = noise("cell",_getinstanceid(),Seed);
This works really great, but I have a cloner within a cloner. 
So the instance IDs the low-level cloner generates simply get repeated in each of the high-level cloner instances.
Do you have a hint for me on how I can get unique instance IDs?
Alternatively, I would love to use an instance-independent random number, but cannot find a way to generate one in OSL.
Thanks in advance
Wolfgang
 
			 
			
					
				Re: Random texture offset (but cloner in cloner)
				Posted: Wed Jan 05, 2022 6:19 pm
				by jobigoud
				For random numbers uncorrelated between neighbor instance ids you can use "Hash" noise instead. Something like this:
Code: Select all
float c = noise("hash", _getinstanceid());
To simulate a seed you can multiply the instance id by a number.
Note that you can also do this without OSL using the "Instance range" and "Random map" nodes.
 
			 
			
					
				Re: Random texture offset (but cloner in cloner)
				Posted: Thu Jan 06, 2022 11:43 pm
				by RSgraphics
				I hope Otoy makes a solution for people that dont know how to write code
			 
			
					
				Re: Random texture offset (but cloner in cloner)
				Posted: Fri Jan 07, 2022 1:09 am
				by aoktar
				Another try to do something similar
			 
			
					
				Re: Random texture offset (but cloner in cloner)
				Posted: Fri Jan 07, 2022 10:02 am
				by wriedl
				Thanks for the input, I appreciate the time you invested!
But still, my problem remains the same. When I have a cloner inside a cloner, the objids and instance IDs remain the same and get cloned.
So unless I am missing something, both of your solutions still produce a dimension of repetition.
In my case, I clone parts of a house vertically and then clone those parts horizontally. Those horizontal parts are then repeating the "random" offsets I created in the first-level vertical dimension.
			 
			
					
				Re: Random texture offset (but cloner in cloner)
				Posted: Fri Jan 07, 2022 10:17 am
				by aoktar
				What are you using? Render instances?
			 
			
					
				Re: Random texture offset (but cloner in cloner)
				Posted: Fri Jan 07, 2022 11:19 am
				by jobigoud
				RSgraphics wrote:I hope Otoy makes a solution for people that dont know how to write code
As I wrote you can do uncorrelated random numbers without code, using Instance range and Random map on hash noise, in standalone it would look like this:
To randomize UVs with this you can send it into the "Distorted mesh UV" projection.
wriedl wrote:
In my case, I clone parts of a house vertically and then clone those parts horizontally. Those horizontal parts are then repeating the "random" offsets I created in the first-level vertical dimension.
Could you use a 2D grid directly instead of nested 1D arrays ? Then each part will have its own ID.