Random Texture Transforms over Instances

Forums: Random Texture Transforms over Instances
Forum for OctaneRender Lua scripting examples, discussion and support.

Random Texture Transforms over Instances

Postby smicha » Wed Jul 30, 2014 9:27 am

smicha Wed Jul 30, 2014 9:27 am
Dear Lua Coders,

First of all I'd like to thank to everyone who contributed to "Render and save all render targets to PNG".

Now I have a huge request which is extremely important in my work. It is possible to construct nodes - see orbx attached, but on the greater scale - LUA is necessary.

Namely: I can use "random color texture" and assign to gradient control points the same jpg texture and modify their input values independently - see the screenshot. This allows to transform the same texture over instances. The effect is - THEY DON'T LOOK THE SAME :) In my simple example (the screenshot) you see only 3 different transforms. But I can add more and more control points to the gradient node and get more and more different transforms of the same texture.

Let's assume I have 1000 instances. And I want to create 1000 control points in the gradient, connect the same image texture to them (as copies) and modify their transform independently and randomly.

The script may look like this (I am not LUA coder, so forgive me my way of presenting the algorithm)

1. Set N (no of max transforms/control points), to e.g. 1000.
2. Create the gradient node with N control points.
3. Let "i=1,...,N" enumerate consecutive control points in the gradient.
4. For every i-th control point set its position value equal to
pv(i) = (1/(N-1))*(i-1)
(If N=1000, pv(1)=(1/(1000-1))*(1-1)=0;
pv(2)=(1/(1000-1))*(2-1)=0.001;
...
pv(1000)=(1/(1000-1))*(1000-1)=1)

5. Load an image texture (would be very nice to load more than one :))
6. Connect the same image textures (as copies) to i-th value (let's call it v(i))
7. Randomly assign values for 3D transforms, also for gamma and power if possible.

in a do loop form:
=========
N=1000;
for i (from 1 to 1000);
set i-th position value (in the gradient node)to pv(i)=(1/(N-1))*(i-1);
connect an i-th image copy to v(i);
randomly assign values (taken from the input panel)to the image texture 3D transforms, (also to gamma and power if possible);
i=i+1;
endfor;
=========


The input panel for random values may look like this - see the attachement.

Guys, I am begging you - please help with writing the script. This is the most important feature I need. I am creating tons (literally millions of mouldings on my classical architecture buildings) and the must by UVed and unfortunately they look the same. This script would solve this problem.

smicha
Attachments
random2.jpg
Example of the input panel for random transforms
random1.jpg
Node structure
random texture transforms.orbx
modify seed to see the effect
(2.48 MiB) Downloaded 634 times
Last edited by smicha on Tue Aug 05, 2014 6:21 am, edited 1 time in total.
3090, Titan, Quadro, Xeon Scalable Supermicro, 768GB RAM; Sketchup Pro, Classical Architecture.
Custom alloy powder coated laser cut cases, Autodesk metal-sheet 3D modelling.
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3151
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Random Texture Transforms over Instances

Postby rappet » Wed Jul 30, 2014 10:11 am

rappet Wed Jul 30, 2014 10:11 am
This is like random color texture, but now it is just working with color, right?
And you want to see a random image texture (instead of only color) with kind of mixture... Is that correct?
I have also a lot of problems with textures that repeat is seen on large surfaces... Is that one of the problems to solved then?

If I understand it correctly... I say 'yeah, yeah, yeah... Please go for it'
User avatar
rappet
Licensed Customer
Licensed Customer
 
Posts: 1962
Joined: Fri Apr 06, 2012 3:57 pm
Location: The Netherlands

Re: Random Texture Transforms over Instances

Postby smicha » Wed Jul 30, 2014 10:43 am

smicha Wed Jul 30, 2014 10:43 am
rappet wrote:This is like random color texture, but now it is just working with color, right?
And you want to see a random image texture (instead of only color) with kind of mixture... Is that correct?


I want image texture to be randomly transformed, scaled, rotated - over instances. But surely you could mix it with random colors.

Please download the orbx attached in the first post and play with seed values. You'll see the effect.
3090, Titan, Quadro, Xeon Scalable Supermicro, 768GB RAM; Sketchup Pro, Classical Architecture.
Custom alloy powder coated laser cut cases, Autodesk metal-sheet 3D modelling.
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3151
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Random Texture Transforms over Instances

Postby abstrax » Wed Jul 30, 2014 11:19 am

abstrax Wed Jul 30, 2014 11:19 am
Hi Smicha,

that's quite a clever way to "scatter" textures over instances. There is only one problem: The gradient node only allows up to 256 (I think - would need to check the code) input textures. You could create more pins, but to achieve a fast (constant time) mapping from input value to to output texture, the maximum number of possible positions needs to be limited. When I wrote it, I thought 256 should be enough. In the beginning it was even limited to 16 positions...

We can have a look at how hard it would be to create a random float value node instead. Basically with a min/max/step for X/Y/Z as displayed in your mockup.

Cheers,
Marcus
In theory there is no difference between theory and practice. In practice there is. - Yogi Berra
User avatar
abstrax
OctaneRender Team
OctaneRender Team
 
Posts: 5483
Joined: Tue May 18, 2010 11:01 am
Location: Auckland, New Zealand

Re: Random Texture Transforms over Instances

Postby smicha » Wed Jul 30, 2014 12:16 pm

smicha Wed Jul 30, 2014 12:16 pm
abstrax wrote:Hi Smicha,

that's quite a clever way to "scatter" textures over instances. There is only one problem: The gradient node only allows up to 256 (I think - would need to check the code) input textures. You could create more pins, but to achieve a fast (constant time) mapping from input value to to output texture, the maximum number of possible positions needs to be limited. When I wrote it, I thought 256 should be enough. In the beginning it was even limited to 16 positions...

We can have a look at how hard it would be to create a random float value node instead. Basically with a min/max/step for X/Y/Z as displayed in your mockup.

Cheers,
Marcus


Marcus,

N=256 is more than enough. So please if you can try to code it. And a random float value node is something I asked some time ago.

Look forward to see some code guys :)
3090, Titan, Quadro, Xeon Scalable Supermicro, 768GB RAM; Sketchup Pro, Classical Architecture.
Custom alloy powder coated laser cut cases, Autodesk metal-sheet 3D modelling.
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3151
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Random Texture Transforms over Instances

Postby abstrax » Mon Aug 04, 2014 8:14 pm

abstrax Mon Aug 04, 2014 8:14 pm
Ok here is a first version of the script:
Texture Scatter.lua
(19.36 KiB) Downloaded 772 times

Please make sure that you use version 2.05.2, since previous versions have a bug in the property binding which breaks the script (basically the greyscale check box and texture directory field aren't read out).

I hope it does what you want. I have limited the maximum number of variations to 256 which is the maximum number of input pins that make sense on the gradient node (for the reasons I explained before).

The last settings will be stored in a file in your temp folder and loaded automatically the next time you run the script.
In theory there is no difference between theory and practice. In practice there is. - Yogi Berra
User avatar
abstrax
OctaneRender Team
OctaneRender Team
 
Posts: 5483
Joined: Tue May 18, 2010 11:01 am
Location: Auckland, New Zealand

Re: Random Texture Transforms over Instances

Postby smicha » Mon Aug 04, 2014 8:34 pm

smicha Mon Aug 04, 2014 8:34 pm
abstrax wrote:Ok here is a first version of the script:
Texture Scatter.lua

Please make sure that you use version 2.05.2, since previous versions have a bug in the property binding which breaks the script (basically the greyscale check box and texture directory field aren't read out).

I hope it does what you want. I have limited the maximum number of variations to 256 which is the maximum number of input pins that make sense on the gradient node (for the reasons I explained before).

The last settings will be stored in a file in your temp folder and loaded automatically the next time you run the script.



Marcus!
THANK YOU :!: :!: :!: I start playing with it and let you know how it goes.
3090, Titan, Quadro, Xeon Scalable Supermicro, 768GB RAM; Sketchup Pro, Classical Architecture.
Custom alloy powder coated laser cut cases, Autodesk metal-sheet 3D modelling.
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3151
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Random Texture Transforms over Instances

Postby smicha » Mon Aug 04, 2014 9:34 pm

smicha Mon Aug 04, 2014 9:34 pm
YES!!! :D :D :D :D :D :D :D :D :D :D :D :D IT WORKS. I am happy like a kid :)

At the screenshot you see one box, two textures and almost 2000 UVed instances - (almost, up to 256 variations) all look different.

So now it's time for more wishes :)

1. Could you please code extra option to select not only a folder for texture path but also a single image, or holding ctrl more images?
2. Could you please code extra option to lock U and V scaling together?

What is your opinion: is it possible to create just a node that would replace the script and it would have inputs same as inputs from the panel?
Attachments
random.png
one box, two textures and almost 2000 UVed instances
Last edited by smicha on Tue Aug 05, 2014 6:17 am, edited 1 time in total.
3090, Titan, Quadro, Xeon Scalable Supermicro, 768GB RAM; Sketchup Pro, Classical Architecture.
Custom alloy powder coated laser cut cases, Autodesk metal-sheet 3D modelling.
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3151
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Random Texture Transforms over Instances

Postby prehabitat » Mon Aug 04, 2014 9:44 pm

prehabitat Mon Aug 04, 2014 9:44 pm
That awesome guys,

Unbelievable teamwork too bringing together pseudocode & an idea with the expertise to execute it..

Well done all round


P.s. Yoink! :)
Win10/3770/16gb/K600(display)/GTX780(Octane)/GTX590/372.70
Octane 3.x: GH Lands VARQ Rhino5 -Rhino.io- C4D R16 / Revit17
prehabitat
Licensed Customer
Licensed Customer
 
Posts: 495
Joined: Fri Aug 16, 2013 10:30 am
Location: Victoria, Australia

Re: Random Texture Transforms over Instances

Postby abstrax » Mon Aug 04, 2014 9:47 pm

abstrax Mon Aug 04, 2014 9:47 pm
smicha wrote:YES!!! :D :D :D :D :D :D :D :D :D :D :D :D IT WORKS. I am happy like a kid :)

At the screenshot you see one box, two textures and almost 2000 UVed instances - (almost, up to 256 variations) all look different.

So now it's time for more wishes :)

1. Could you please code extra option to select not only a folder for texture path but also a single image, or holding ctrl more images?

That's unfortunately not supported in the current Lua API. We may add this in the future, but I don't have time right now.

2. Could you please code extra option to lock U and V scaling together?

Have been thinking about this myself and will do that when I get to it.

What is your opinion: is it possible to create just a node that would replace the script and it would have inputs same as inputs from the panel?

We won't do that, but we are planning to implement a generic Lua node graph, where you can hook up a Lua script, that gets evaluated every time an input changes, which would allow this and many many other things. The problem is right now we don't have time to do it, but it's definitely planned.
In theory there is no difference between theory and practice. In practice there is. - Yogi Berra
User avatar
abstrax
OctaneRender Team
OctaneRender Team
 
Posts: 5483
Joined: Tue May 18, 2010 11:01 am
Location: Auckland, New Zealand
Next

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 2 guests

Tue Mar 19, 2024 6:15 am [ UTC ]