Page 4 of 6
Re: Create random textures over instances
Posted:
Fri Sep 15, 2017 2:34 pm
by Yugs
Hi,
Would it be possible to have this scripted graph working with an image texture input instead of a string value ?
That way one could, for instance, link an image node with UV transform information directly to the script. I tried to do it but I don't know the first thing about LUA. I just managed to change the string input to a texture one, but all I get is a blank material.
Thanks for this anyway, it comes very handy!
Cheers,
Yugs
Re: Create random textures over instances
Posted:
Mon Mar 19, 2018 8:49 pm
by smicha
Could you please help and make this script working under V4?
Re: Create random textures over instances
Posted:
Mon Apr 09, 2018 3:00 am
by roeland
As far as I can see the script still works under version 4.
Yugs wrote:Would it be possible to have this scripted graph working with an image texture input instead of a string value ?
It's possible to create a similar script with texture inputs, how exactly depends on what exactly you want to achieve. Do you want one image texture input with a bunch of random additional transforms applied to it?
--
Roeland
Re: Create random textures over instances
Posted:
Mon Apr 09, 2018 7:58 pm
by whersmy
It's possible to create a similar script with texture inputs, how exactly depends on what exactly you want to achieve. Do you want one image texture input with a bunch of random additional transforms applied to it?
Would be very welcome.
Would it be possible to create an Amount and Scale input for the scatter node? I would like to reproduce a texture like this on a big surface
Actually OSL should be able to simulate this I think
Re: Create random textures over instances
Posted:
Mon Apr 09, 2018 8:48 pm
by roeland
Yes, this can be done using an OSL texture: You can start from the laminate example here:
viewtopic.php?p=326508#p326508Set the plankAspect to 1.0 for square tiles.
However, this shader will generate a random offset for every row of tiles. To get a regular pattern like in your picture find and replace the lines
- Code: Select all
// random offset for each row
float x = p[0] + noise("cell", y, 0);
with
- Code: Select all
// alternate offset for each row
float x = p[0] + 0.5 * ((int) y & 1);
Re: Create random textures over instances
Posted:
Tue Apr 10, 2018 9:18 am
by whersmy
Getting there! Is it possible to add a random rotation for the square planks/tiles? In practice you would only need 4 options, each 90 degrees turned. In order to get the right irregularity for now I solved it roughness.
Re: Create random textures over instances
Posted:
Tue Apr 10, 2018 9:25 am
by smicha
Share the scene please - great job.
Re: Create random textures over instances
Posted:
Tue Apr 10, 2018 9:36 am
by whersmy
Here we go. Usable for buildings as well if displacement is not necessary.
Re: Create random textures over instances
Posted:
Wed Apr 11, 2018 4:44 am
by roeland
Yes. The script as it is contains code to randomly rotate the texture by 180°:
- Code: Select all
int flip = (rnd - floor(rnd)) < .5;
// make UV mapping per cell and evaluate the right texture
float plU = x - floor(x);
float plV = y - floor(y);
if (flip)
{
plU = 1 - plU;
plV = 1 - plV;
}
We can extend this code: for instance this randomly picks any of the 8 combinations of rotation (0°, 90°, 180°, 270°) and mirroring.
- Code: Select all
int flip = (int) ((rnd - floor(rnd)) * 8);
// make UV mapping per cell and evaluate the right texture
float plU = x - floor(x);
float plV = y - floor(y);
if (flip & 1)
{
// flip U
plU = 1 - plU;
}
if (flip & 2)
{
// flip V
plV = 1 - plV;
}
if (flip & 4)
{
// flip over diagonal
float tmp = plU;
plU = plV;
plV = tmp;
}
Re: Create random textures over instances
Posted:
Wed Apr 11, 2018 7:20 am
by Rik
Hi Rowland
Can you tell us how we would use this in the plugins? I use max but have no idea about how to incorporate the code.
It look like it would be really useful.