Itoo Software Forum

Author Topic: Random Materials probability along a spline  (Read 1862 times)

Anthony Lester

  • Newbie
  • *
  • Posts: 34
Random Materials probability along a spline
« on: February 11, 2016, 03:15:21 PM »
I am hoping that someone might be able to help as I have been trying to resolve this problem for some time with no success.

I have created a facade using several elements; a window, and three different width solid panels. Alternate floors are similar in layout but there is no regular pattern and the client has been very prescriptive in how he wants it laid out. To this end I have used a 'Compose' and manually entered each element for each floor. Very boring but it is done now!

The client would like to have the materials of the panels be 'random' but with more darker panels at the end of the spline, more light panels at the beginning of the spline and more mid grey panels in the middle.

Each element that I want to apply this material effect has the appropriate faces assigned with a material ID (2) 
My thinking was that this would be possible with an expression that uses the X position to adjust the probability of a randomize operator that had three material operator inputs. - When I right it like this it sounds quite simple but I am getting stuck every way I try.

I have attached an extract of the scene so you can see what I am starting with.

Many thanks in advance
Anthony

Paul Roberts

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2991
Re: Random Materials probability along a spline
« Reply #1 on: February 11, 2016, 07:28:41 PM »
Hi,

I'm afraid the probability values of the Random operator can't be edited on the fly. They're are evaluated only once at the start. However you can do this using a selector operator, two random number generators and an expression to get a result similar to this:



To do this:

- Create a new Selector node and wire the Light segment to input1, the Mid segment to input2, and the dark segment to input3.
- Export the Selector node's Index property.
- Attach a new  Arithmetic node to the Index property.
- Create a new Random number node and set the min value to 0.0 and the max to 0.5, wire this to the Arithmetic node's first input.
- Create a second Random number node and set the min value to 0.5 and the max to 1.0, wire this to the Arithmetic node's second input.
- Change the Arithmetic node's mode to Expression and enter the following-

if(Input1>XSplinePosition,1,
if(Input2<XSplinePosition,3,
2))


This is testing the current position on the spline against a randomly generated number. As the position of the spline increases the probability of it selecting the first segment decreases. The same applies for the second If statement except this time it is checking to see if the segment it near the end of the spline.

The final graph should look like this:



I've attached a sample file for you to check out but if you have any further questions please let me know.

Many thanks!

Paul
« Last Edit: February 11, 2016, 07:31:44 PM by Paul Roberts »
Paul Roberts
iToo Software

Anthony Lester

  • Newbie
  • *
  • Posts: 34
Re: Random Materials probability along a spline
« Reply #2 on: February 15, 2016, 10:27:05 AM »
Thanks will look at it now.
A

Anthony Lester

  • Newbie
  • *
  • Posts: 34
Re: Random Materials probability along a spline
« Reply #3 on: February 15, 2016, 11:22:13 AM »
So I have got this to work however, I have come across another problem, because the sequence of windows/panels are specific and not random I had originally used a compose operator to specify the order. Using the method that has been suggested above does not work as the selector is based upon the x position of the compose operator and not the individual elements. I now realise that instead of using a compose operator I should have used an sequence operator (which seems to work with the tests I have done). My question therefore is there anyway of transferring all the inputs of a compose operator to a sequence operator without hahing to do each one individually?

Paul Roberts

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2991
Re: Random Materials probability along a spline
« Reply #4 on: February 15, 2016, 12:18:18 PM »
Hi,

I'm sorry because I can see that it'll be a lot of work, but there's not a way to easily convert a Compose operator to a Sequence operator without reconnecting all the nodes again.

Thanks,

Paul.
Paul Roberts
iToo Software

Anthony Lester

  • Newbie
  • *
  • Posts: 34
Re: Random Materials probability along a spline
« Reply #5 on: February 15, 2016, 02:15:37 PM »
That's a shame, no worries all done now :)