Tuesday morning ICE brain-fart/brain-teaser...

29 views
Skip to first unread message

Dan Yargici

unread,
Jan 3, 2012, 3:49:12 AM1/3/12
to soft...@listproc.autodesk.com
Morning all.  It seems all the coffee in the world isn't going to help me today...

*In ICE*

If I have an Array like this:

111113366666666688889999999999999

What's the quickest, non-loopiest way to make it like this?

111112233333333344445555555555555

Thanks.

DAN

Jens Lindgren

unread,
Jan 3, 2012, 4:02:33 AM1/3/12
to soft...@listproc.autodesk.com
Make sure it's a scalar value, Divide by Scalar followed by a Round or Ceiling.
 
/Jens
--
Jens Lindgren
--------------------------
Lead Technical Director

Dan Yargici

unread,
Jan 3, 2012, 4:21:31 AM1/3/12
to soft...@listproc.autodesk.com
Sorry Jens, my brain's completely fried this morning.... what Scalar would I be dividing by?

I can fix this with a loop but I had hoped there might be a non-loopy way as I have a veeeery heavy mesh to use this on.

I've learnt a lot about using arrays in ICE over the last couple of days but this has me stumped, even though it seems so trivial  :/

DAN

Jens Lindgren

unread,
Jan 3, 2012, 4:28:15 AM1/3/12
to soft...@listproc.autodesk.com
Hehe divide by 2 :)
 
/Jens

Dan Yargici

unread,
Jan 3, 2012, 4:42:45 AM1/3/12
to soft...@listproc.autodesk.com
At the risk of embarrassing myself even further......
sortarray.jpg

Jens Lindgren

unread,
Jan 3, 2012, 4:54:41 AM1/3/12
to soft...@listproc.autodesk.com
Yes that looks correct. Or isn't it the result that you were after?
 
/Jens

Dan Yargici

unread,
Jan 3, 2012, 5:01:46 AM1/3/12
to soft...@listproc.autodesk.com
In that example I want a result like this:

0,0,3,3,3,7,7,12,12,90

into

0,0,1,1,1,2,2,3,3,4

Jens Lindgren

unread,
Jan 3, 2012, 5:29:43 AM1/3/12
to soft...@listproc.autodesk.com
Ok then it's more tricky :)
I'm afraid I don't have the time to help you right now but you probably need a repeat node...
 
/Jens

Dan Yargici

unread,
Jan 3, 2012, 5:36:45 AM1/3/12
to soft...@listproc.autodesk.com
OK, yes, sorry, it seems my first example contained an alternative pattern!

I was beginning to think as much regarding the repeat node... oh well, I guess I'll just have to suck it up... :/

Thanks for all your time Jens.

DAN

Brent McPherson

unread,
Jan 3, 2012, 5:40:05 AM1/3/12
to soft...@listproc.autodesk.com
Dan,

Since your results are dependent on neighbouring values you would need to loop over elements to do this.

If performance is a issue then your best bet would be a custom C++ node.
--
Brent

From: softimag...@listproc.autodesk.com [mailto:softimag...@listproc.autodesk.com] On Behalf Of Dan Yargici
Sent: 03 January 2012 10:37
To: soft...@listproc.autodesk.com
Subject: Re: Tuesday morning ICE brain-fart/brain-teaser...

OK, yes, sorry, it seems my first example contained an alternative pattern!

I was beginning to think as much regarding the repeat node... oh well, I guess I'll just have to suck it up... :/

Thanks for all your time Jens.

DAN


On Tue, Jan 3, 2012 at 12:29 PM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>> wrote:
Ok then it's more tricky :)
I'm afraid I don't have the time to help you right now but you probably need a repeat node...

/Jens


On Tue, Jan 3, 2012 at 11:01 AM, Dan Yargici <danya...@gmail.com<mailto:danya...@gmail.com>> wrote:
In that example I want a result like this:

0,0,3,3,3,7,7,12,12,90

into

0,0,1,1,1,2,2,3,3,4


On Tue, Jan 3, 2012 at 11:54 AM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>> wrote:
Yes that looks correct. Or isn't it the result that you were after?

/Jens

On Tue, Jan 3, 2012 at 10:42 AM, Dan Yargici <danya...@gmail.com<mailto:danya...@gmail.com>> wrote:
At the risk of embarrassing myself even further......

On Tue, Jan 3, 2012 at 11:28 AM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>> wrote:
Hehe divide by 2 :)

/Jens


--
Jens Lindgren
--------------------------
Lead Technical Director

Magoo 3D Studios<http://www.magoo3dstudios.com/>

--
Jens Lindgren
--------------------------
Lead Technical Director

Magoo 3D Studios<http://www.magoo3dstudios.com/>


winmail.dat

Martin Chatterjee

unread,
Jan 3, 2012, 8:32:47 AM1/3/12
to soft...@listproc.autodesk.com
Dan,

long time no see - hope you're well!  

I just played around with this a bit and came up with this: (screenshot and compound is attached) 

This is what you're after, right?  It doesn't use any loops - however I did not test performance on huge data sets. Hope this helps - and if you find the time please let me know how well of bad it performs in comparison to your looped solution.

Cheers, Martin

--
        Martin Chatterjee

[ Freelance Technical Director ]
[    http://www.chatterjee.de    ]
UniqueItemsToIndex.png
mch_UniqueItemsToIndex.xsicompound

Brent McPherson

unread,
Jan 3, 2012, 9:58:11 AM1/3/12
to soft...@listproc.autodesk.com
I knew as soon as I posted that someone would prove me wrong. ;-)

That is a pretty neat solution Martin. The ICE tree is constructing some big intermediate arrays and probably doesn't scale well for multiple-threads. Therefore I would still wager that a single-threaded custom node would be the fastest solution. Or maybe I have just opened myself up to be proven wrong again... ;-)
--
Brent

From: softimag...@listproc.autodesk.com [mailto:softimag...@listproc.autodesk.com] On Behalf Of Martin Chatterjee
Sent: 03 January 2012 13:33
To: soft...@listproc.autodesk.com
Subject: Re: Tuesday morning ICE brain-fart/brain-teaser...

Dan,

long time no see - hope you're well!

I just played around with this a bit and came up with this: (screenshot and compound is attached)

This is what you're after, right? It doesn't use any loops - however I did not test performance on huge data sets. Hope this helps - and if you find the time please let me know how well of bad it performs in comparison to your looped solution.

Cheers, Martin

--
Martin Chatterjee

[ Freelance Technical Director ]
[ http://www.chatterjee.de ]


On Tue, Jan 3, 2012 at 11:40 AM, Brent McPherson <Brent.M...@autodesk.com<mailto:Brent.M...@autodesk.com>> wrote:
Dan,

Since your results are dependent on neighbouring values you would need to loop over elements to do this.

If performance is a issue then your best bet would be a custom C++ node.
--
Brent

From: softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com> [mailto:softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com>] On Behalf Of Dan Yargici
Sent: 03 January 2012 10:37
To: soft...@listproc.autodesk.com<mailto:soft...@listproc.autodesk.com>
Subject: Re: Tuesday morning ICE brain-fart/brain-teaser...

OK, yes, sorry, it seems my first example contained an alternative pattern!

I was beginning to think as much regarding the repeat node... oh well, I guess I'll just have to suck it up... :/

Thanks for all your time Jens.

DAN


On Tue, Jan 3, 2012 at 12:29 PM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>>> wrote:
Ok then it's more tricky :)
I'm afraid I don't have the time to help you right now but you probably need a repeat node...

/Jens


On Tue, Jan 3, 2012 at 11:01 AM, Dan Yargici <danya...@gmail.com<mailto:danya...@gmail.com><mailto:danya...@gmail.com<mailto:danya...@gmail.com>>> wrote:
In that example I want a result like this:

0,0,3,3,3,7,7,12,12,90

into

0,0,1,1,1,2,2,3,3,4

On Tue, Jan 3, 2012 at 11:54 AM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>>> wrote:
Yes that looks correct. Or isn't it the result that you were after?

/Jens


On Tue, Jan 3, 2012 at 10:42 AM, Dan Yargici <danya...@gmail.com<mailto:danya...@gmail.com><mailto:danya...@gmail.com<mailto:danya...@gmail.com>>> wrote:
At the risk of embarrassing myself even further......

winmail.dat

Dan Yargici

unread,
Jan 3, 2012, 10:08:39 AM1/3/12
to soft...@listproc.autodesk.com
Thanks Martin!

That seems to do the job pretty neatly!  At least in my quick tests.  I've since discovered other reasons that have changed the direction of my setup so I'm not sure I'll have time to shoe-horn it in for a while (everything's evolved so much today that I'm not even sure I'd know where to start!) but I'll try to at some stage in the coming days/weeks.

Thanks again man.  Hope life's treating you well also!

DAN

Martin Chatterjee

unread,
Jan 3, 2012, 10:11:15 AM1/3/12
to soft...@listproc.autodesk.com
Hi Brent,

I knew as soon as I posted that someone would prove me wrong. ;-)
That is a pretty neat solution Martin. The ICE tree is constructing some big intermediate arrays and probably doesn't scale well for multiple-threads.

Yeah, that's why I'm not too sure if this scales/multi-threads well. I don't have the time to test this - but hopefully Dan can comment on this some time. 
 
Therefore I would still wager that a single-threaded custom node would be the fastest solution. Or maybe I have just opened myself up to be proven wrong again... ;-)
 
I think most probably you're absolutely right with this assumption. However I've seen ICE to multi-thread so freakingly well in some scenarios where I'd have sworn beforehand that compiled C++ would definitely win...

Guillaume Laforge

unread,
Jan 3, 2012, 11:40:48 AM1/3/12
to soft...@listproc.autodesk.com
Hi and Happy New Year everyone !

Martin solution is very good as it doesn't need any custom nodes :). It is always nice as the compound will always work on the farm or on any Softimage version for example.

But...

... as Brent said it would be (MUCH) faster and memory efficient to use a single custom ICE node, as you will be able to use just one very simple loop (and also it will dramatically reduce the number of function calls).
It all depends on your needs. If you are going to do this array operation on millions of particles for each frames, the compound is not really a good option.
A custom node would just loop through the array and increment a variable if array[i] != array[i-1]. So it would be extremely fast.

For the multithreading question, Martin compound is already multithreaded by ICE as array nodes can be used per components. That means that several threads will be used if the context is not singleton ;).
But as the custom node would also be multithreaded by default, it would still be a big winner.

Cheers,

Guillaume Laforge

From: softimag...@listproc.autodesk.com [mailto:softimag...@listproc.autodesk.com] On Behalf Of Martin Chatterjee
Sent: Tuesday, January 03, 2012 10:11 AM
To: soft...@listproc.autodesk.com
Subject: Re: Tuesday morning ICE brain-fart/brain-teaser...

Hi Brent,

I knew as soon as I posted that someone would prove me wrong. ;-)
That is a pretty neat solution Martin. The ICE tree is constructing some big intermediate arrays and probably doesn't scale well for multiple-threads.

Yeah, that's why I'm not too sure if this scales/multi-threads well. I don't have the time to test this - but hopefully Dan can comment on this some time.

Therefore I would still wager that a single-threaded custom node would be the fastest solution. Or maybe I have just opened myself up to be proven wrong again... ;-)

I think most probably you're absolutely right with this assumption. However I've seen ICE to multi-thread so freakingly well in some scenarios where I'd have sworn beforehand that compiled C++ would definitely win...

Cheers, Martin
--
Martin Chatterjee

[ Freelance Technical Director ]
[ http://www.chatterjee.de ]


From: softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com> [mailto:softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com>] On Behalf Of Martin Chatterjee
Sent: 03 January 2012 13:33
To: soft...@listproc.autodesk.com<mailto:soft...@listproc.autodesk.com>
Subject: Re: Tuesday morning ICE brain-fart/brain-teaser...
Dan,

long time no see - hope you're well!

I just played around with this a bit and came up with this: (screenshot and compound is attached)

This is what you're after, right? It doesn't use any loops - however I did not test performance on huge data sets. Hope this helps - and if you find the time please let me know how well of bad it performs in comparison to your looped solution.

Cheers, Martin

--
Martin Chatterjee

[ Freelance Technical Director ]
[ http://www.chatterjee.de ]

On Tue, Jan 3, 2012 at 11:40 AM, Brent McPherson <Brent.M...@autodesk.com<mailto:Brent.M...@autodesk.com><mailto:Brent.M...@autodesk.com<mailto:Brent.M...@autodesk.com>>> wrote:
Dan,

Since your results are dependent on neighbouring values you would need to loop over elements to do this.

If performance is a issue then your best bet would be a custom C++ node.
--
Brent

From: softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com><mailto:softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com>> [mailto:softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com><mailto:softimag...@listproc.autodesk.com<mailto:softimag...@listproc.autodesk.com>>] On Behalf Of Dan Yargici


Sent: 03 January 2012 10:37

To: soft...@listproc.autodesk.com<mailto:soft...@listproc.autodesk.com><mailto:soft...@listproc.autodesk.com<mailto:soft...@listproc.autodesk.com>>


Subject: Re: Tuesday morning ICE brain-fart/brain-teaser...

OK, yes, sorry, it seems my first example contained an alternative pattern!

I was beginning to think as much regarding the repeat node... oh well, I guess I'll just have to suck it up... :/

Thanks for all your time Jens.

DAN


On Tue, Jan 3, 2012 at 12:29 PM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>>>> wrote:
Ok then it's more tricky :)
I'm afraid I don't have the time to help you right now but you probably need a repeat node...

/Jens


On Tue, Jan 3, 2012 at 11:01 AM, Dan Yargici <danya...@gmail.com<mailto:danya...@gmail.com><mailto:danya...@gmail.com<mailto:danya...@gmail.com>><mailto:danya...@gmail.com<mailto:danya...@gmail.com><mailto:danya...@gmail.com<mailto:danya...@gmail.com>>>> wrote:
In that example I want a result like this:

0,0,3,3,3,7,7,12,12,90

into

0,0,1,1,1,2,2,3,3,4


On Tue, Jan 3, 2012 at 11:54 AM, Jens Lindgren <jens.lin...@gmail.com<mailto:jens.lin...@gmail.com><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com><mailto:jens.lin...@gmail.com<mailto:jens.lin...@gmail.com>>>> wrote:
Yes that looks correct. Or isn't it the result that you were after?

/Jens

On Tue, Jan 3, 2012 at 10:42 AM, Dan Yargici <danya...@gmail.com<mailto:danya...@gmail.com><mailto:danya...@gmail.com<mailto:danya...@gmail.com>><mailto:danya...@gmail.com<mailto:danya...@gmail.com><mailto:danya...@gmail.com<mailto:danya...@gmail.com>>>> wrote:
At the risk of embarrassing myself even further......

winmail.dat
Reply all
Reply to author
Forward
0 new messages