Page 1 of 1

Random shifting of texture UV coordinates?

PostPosted: Tue Feb 26, 2019 3:31 am
by pcoombes
Sorry if this is basic, but I'm trying to randomly assign/shift the UV coordinates of a single wood material on approx. 125 separate planks/panels in a wall so that there are no repeating patterns. This is an imported model, so I can't use an Octane Scatter object or a MoGraph object (I've tried a Fracture object, but I couldn't get a result).
Can someone point me in the right direction?

Re: Random shifting of texture UV coordinates?

PostPosted: Tue Feb 26, 2019 8:04 am
by aoktar
Osl is the right way to look.

Re: Random shifting of texture UV coordinates?

PostPosted: Tue Feb 26, 2019 9:14 am
by milanm
Hi pcoombes

Well, for some reason builtin RandomColor node is not "seeing" the instanceID numbers in a Fracture setup but OSL does.
Instance Range works too.

This great script from Beppe should do exactly what you need.
https://render.otoy.com/forum/viewtopic.php?f=73&t=69211

You can use this instead of RandomColor node. It will work with Fracture + Explode segments. Or, for example, as an input in Gradient node (complex mode) to randomize (multi)textures.

Code: Select all
#include <octane-oslintrin.h>
shader RandomInstanceColor(
      int Seed=0,
      output color c = 0)
{   
      c = noise("cell",_getinstanceid(),Seed);
}


With this one you can mask individual objects based on ID. You will see that InstanceIDs mach Index numbers exactly.
InstanceIDs.PNG


Code: Select all
#include <octane-oslintrin.h>
shader InstanceID(
      color A = 1, color B = 0,
      int InstanceID = 0 [[int min=0, int slidermax=100]],
      int Swap = 0 [[string widget = "checkBox"]],
      output color c = 0)
{
   color outA = A;
   color outB = B;
   
   if (Swap==1) { outA = B; outB = A; }
   c = (InstanceID==_getinstanceid())? outA: outB;
}


Cheers
Milan

Re: Random shifting of texture UV coordinates?

PostPosted: Thu Feb 28, 2019 2:48 am
by pcoombes
Thanks, Milan, that's exactly what I needed.
And thanks Beppe!
It's a shame one has to resort to scripting to get something fairly common to work.

Cheers

Re: Random shifting of texture UV coordinates?

PostPosted: Sun Mar 03, 2019 9:51 am
by bepeg4d
Big thanks Milan for sharing the RandomInstanceColor.osl node :D
I have updated my post here with .orbx and .c4d example files.
Happy GPU Rendering,
ciao Beppe