It is currently 18 May 2013, 12:20

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 01:33 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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.


Attachments:
Stephen_Blair_dup_vertexarray.png
Stephen_Blair_dup_vertexarray.png [ 132.18 KiB | Viewed 2112 times ]
point-gridvruu.jpg
point-gridvruu.jpg [ 121.75 KiB | Viewed 2112 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif


Last edited by Daniel Brassard on 17 Oct 2011, 18:00, edited 1 time in total.
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 01:44 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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.


Attachments:
Modulo_basic1.jpg
Modulo_basic1.jpg [ 25.27 KiB | Viewed 2207 times ]
Modulo_basic3.jpg
Modulo_basic3.jpg [ 26.96 KiB | Viewed 2207 times ]
Modulo_basic2.jpg
Modulo_basic2.jpg [ 20.29 KiB | Viewed 2207 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 01:55 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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).


Attachments:
Modulo_basic5.jpg
Modulo_basic5.jpg [ 62.87 KiB | Viewed 2207 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif


Last edited by Daniel Brassard on 17 Oct 2011, 18:50, edited 5 times in total.
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 01:59 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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.


Attachments:
Chris_TC.jpg
Chris_TC.jpg [ 79.58 KiB | Viewed 2112 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif


Last edited by Daniel Brassard on 17 Oct 2011, 18:01, edited 1 time in total.
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 02:04 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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.


Attachments:
Chris_TC_variant.jpg
Chris_TC_variant.jpg [ 80.29 KiB | Viewed 2206 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 02:20 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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.


Attachments:
UVW_Counter2.jpg
UVW_Counter2.jpg [ 71.37 KiB | Viewed 2206 times ]
UVW_Counter.jpg
UVW_Counter.jpg [ 67.16 KiB | Viewed 2206 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif


Last edited by Daniel Brassard on 17 Oct 2011, 18:12, edited 5 times in total.
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 02:25 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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.


Attachments:
UV_Counter.jpg
UV_Counter.jpg [ 56.13 KiB | Viewed 2205 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 02:28 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
And the UVW version of the ICE tree (with output between 0 and 1 in x, y and z).


Attachments:
UVW_Counter3.jpg
UVW_Counter3.jpg [ 64.03 KiB | Viewed 2205 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif
Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 02:30 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 441
Location: St. Thomas, Ontario
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

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif


Last edited by Daniel Brassard on 17 Oct 2011, 18:18, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: ICE - Modulo trick and variants
PostPosted: 17 Oct 2011, 12:06 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3203
Interesting, thanks... ;)
This being a tutorial (of sorts) I took the liberty to move it to the "ICE Tutorials" forum

_________________
currently sporting a broken arm - response time decreased


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group