ICE - Modulo trick and variants

Here you can find ICE tutorials and learning material
User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 01:33

I was made aware a while ago of the modulo trick to replace loop and counters. The first time was back in May when Stephen Blair poster a screen grab of the modulo trick on XSI Support Blog to generate a better duplicator (screen below).

Then this month Chris_TC posted a variation of the modulo trick on XSI Base to generate an array of points in x and z (screen below as well).

During my experiment with the Bezier surfaces, I used the modulo trick to generate numbers in u and v. The trick was very much similar to Chris_TC.

The modulo trick is still talked about, even on XSI List and I wanted to share some screen of my own to contribute to the conversation about the usefullness of this trick.
You do not have the required permissions to view the files attached to this post.
Last edited by Daniel Brassard on 17 Oct 2011, 18:00, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 01:44

The first thing we notice between Stephen Blair and Chris_TC is Chris is using the build index array node and Stephen is using the build array from constant + get array sub indices combination to feed to the modulo. If you open the build index array compound you will notice that the two nodes that Stephen uses are the build index array. Technically, Chris and Stephen are using the same compounds. Good, to simplify then we will use the build index array.

So, the basic Modulo trick is illustrated as follow.
You do not have the required permissions to view the files attached to this post.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 01:55

So, our first experiment is to generate a simple counter / repeat.

Here is the ICE tree and its result.

What does it do, it count from 0 to n-1 (0,1,2 in this case as the modulo by value n is equal to 3) basically repeating these numbers four time. We can use the output from the modulo to select numbers from an arrays to feed the index input of a select from array node and repeat these numbers n times (see Stephen Blair screen at the start of the thread for an example).
You do not have the required permissions to view the files attached to this post.
Last edited by Daniel Brassard on 17 Oct 2011, 18:50, edited 5 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 01:59

Using this trick can be advantegeous. Chris_TC used a variation of the trick to generate points on a grid like structure.

Basically, he used the Modulo to give him a basic repeat and both integers inputs to calculate the location of the next point on the grid.
You do not have the required permissions to view the files attached to this post.
Last edited by Daniel Brassard on 17 Oct 2011, 18:01, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 02:04

Here is my take of Chris_TC trick. Both (Chris_TC and Mine) will generate the same numbers/points.

My take is to use a combination of Modulo and Sort to generate the first series of numbers in the array (x). The second numbers are the same between Chris and I.
You do not have the required permissions to view the files attached to this post.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 02:20

Expanding in the third dimension is very similar. This time we have to generate the numbers in a certain order to get the effect we want.

Below is the ICE Tree that expand the trick in the third dimension. This can be used to select numbers in three different arrays to generate effects or points.

You will notice that the top and bottom row of nodes are the same as the uv ICE tree above. The trick is the middle row of nodes that include two modulo nodes and one sort node.
You do not have the required permissions to view the files attached to this post.
Last edited by Daniel Brassard on 17 Oct 2011, 18:12, edited 5 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 02:25

Using the Modulo trick, here is the ICE tree of the counter I used to generate the UV numbers (between 0 and 1) for the Bezier surface.
You do not have the required permissions to view the files attached to this post.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 02:28

And the UVW version of the ICE tree (with output between 0 and 1 in x, y and z).
You do not have the required permissions to view the files attached to this post.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 02:30

Here it is, my little contribution to the modulo trick. Hope this information will be useful.

If you have a Modulo trick of your own, feel free to share using this thread.

Cheers!

Dan
Last edited by Daniel Brassard on 17 Oct 2011, 18:18, edited 2 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Hirazi Blue
Administrator
Posts: 4938
Joined: 04 Jun 2009, 12:15

Re: ICE - Modulo trick and variants

Post by Hirazi Blue » 17 Oct 2011, 12:06

Interesting, thanks... ;)
This being a tutorial (of sorts) I took the liberty to move it to the "ICE Tutorials" forum
...

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 17 Oct 2011, 18:04

Thanks Hirazi Blue.
$ifndef "Softimage"
set "Softimage" "true"
$endif

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 17:43

Re: ICE - Modulo trick and variants

Post by Chris_TC » 22 Oct 2011, 11:18

Thank you for the thread. Even though I use the modulo trick, I always have to do trial and error because it requires a somewhat unusual way of thinking.
Is there a specific thread on XSI list that discusses it?

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 23 Oct 2011, 23:02

Thank Chris.

A couple of threads on XSI List are about using the modulo trick to avoid the repeat node and multiple mention of the trick to generate sequential numbers, but I have not stumble yet on a specific thread about the trick itself. That is why I create this thread.

The closest, is probably the one from Steve Blair on XSI Support.

http://xsisupport.wordpress.com/2011/05 ... -compound/
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 864
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario

Re: ICE - Modulo trick and variants

Post by Daniel Brassard » 02 Nov 2011, 03:04

This trick use the modulo to create the quad description for my bezier patch topology.

You can use this trick to create the polygon description of a grid topology of any U and V size!

Simple, effective and quick! No repeat here!
You do not have the required permissions to view the files attached to this post.
$ifndef "Softimage"
set "Softimage" "true"
$endif