Ideas on speeding up a compound (UV to Location)

Discussions about SOFTIMAGEs© Interactive Creative Environment©
User avatar
gustavoeb
Moderator
Posts: 587
Joined: 20 Jul 2010, 22:33
Skype: gustavoboehs

Ideas on speeding up a compound (UV to Location)

Post by gustavoeb » 07 Dec 2011, 13:17

Hey ICE masters, need some help here.

I'm trying to build something like Helge's Pixel Particle, but instead of using his Custom Nodes I'm building my own Compounds. The thing is that I'm not very good at optimizing this trees and I would like to know if anyone can point me in the right direction to a faster evaluation of such a tree. Here is what it is doing now:

*Creats a bunch of points;
*Creats a custom atribute with theyre positions in UV space;
*Each UV coordinate is converted to Barycentric coordinates FOR EVERY POLYGON ( :-\ ) if the point happens to be inside the polygon we move on, if not keep searching until the last polygon;
*Barycentric coordinates are stored in custom atribute;
*Polygon to which every point pertains is stored in a custom attribute;
*Points without a polygon are deleted;
*Point's barycentric coordinates are converted back to Cartesian (XYZ) regarding the polygons they pertain to.

Important to note that, as is, this only works in triangular meshes.

Here is the file if anyone wants to check it out:
http://gustavoeb.com.br/blog/wp-content/uploads/2011/12/uv2location.scn

Cheers
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/

grahamef
Posts: 281
Joined: 23 Jun 2009, 19:01

Re: Ideas on speeding up a compound (UV to Location)

Post by grahamef » 07 Dec 2011, 22:28

One thing you could try as an optimization is to calculate Get Triangle Vertices in UV Space outside the loop, and store the results in object-context arrays so you can look them up without continuously recalculating them inside the loop.

You also might limit the search to the triangles associated to the N closest vertices in UV space, which would allow you to limit the number of loops to N. You might get some degenerate cases when a UV position is close to the edge of an island with another very dense island nearby -- in that case you'd need to adjust N.

Also, lobby for a Texture UV to Locations node. It would make this a lot easier.

User avatar
Tekano
Posts: 488
Joined: 09 Jun 2009, 12:49
Location: London, UK

Re: Ideas on speeding up a compound (UV to Location)

Post by Tekano » 08 Dec 2011, 11:24

lobby!? as in wine & dine a developer and bung some back hand cash in a brown envelope? sounds like a plan :p
Gossip is what no one claims to like, but everybody enjoys.

User avatar
gustavoeb
Moderator
Posts: 587
Joined: 20 Jul 2010, 22:33
Skype: gustavoboehs

Re: Ideas on speeding up a compound (UV to Location)

Post by gustavoeb » 08 Dec 2011, 11:36

lol
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/

User avatar
gustavoeb
Moderator
Posts: 587
Joined: 20 Jul 2010, 22:33
Skype: gustavoboehs

Re: Ideas on speeding up a compound (UV to Location)

Post by gustavoeb » 08 Dec 2011, 11:38

Now on a serious note your optimization suggestions look solid, I actually asked Helge from pixel particles and he suggested similar stuff. I'm working on it right now... Will post how faster this gets if I can get it to work :D

Thanks
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/

grahamef
Posts: 281
Joined: 23 Jun 2009, 19:01

Re: Ideas on speeding up a compound (UV to Location)

Post by grahamef » 08 Dec 2011, 18:34

Tekano wrote:lobby!? as in wine & dine a developer and bung some back hand cash in a brown envelope? sounds like a plan :p
I've been pushing for this internally, but it seems that paying customers have more clout than tech writers.

User avatar
gustavoeb
Moderator
Posts: 587
Joined: 20 Jul 2010, 22:33
Skype: gustavoboehs

Re: Ideas on speeding up a compound (UV to Location)

Post by gustavoeb » 09 Feb 2012, 12:44

go to make this 18x faster! \:D/
still no fast enough 8-}

instead of generating the Barycentric coordinate in every polygon until it finds the correct one, it now finds a bounding box for each polygon and only deal with the points within that BBox... there is also a lot of data filtering so data from unwanted points wont go up stream, as described in here: viewtopic.php?f=15&t=2105

here it is:
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/