FAQ FAQ      Search Search      Memberlist Memberlist      Usergroups Usergroups      Register Register      Profile Profile      Check private messages Check private messages      Log in Log in     

Basic vops question

 
Post new topic   Reply to topic    Houdini Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Dean_19
Houdini Adept


Joined: 02 Aug 2005
Posts: 242
Location: London town

uk.gif
PostPosted: Mon Oct 03, 2011 4:21 am GMT    Post subject: Basic vops question Reply with quote

Hello,

Can someone point me the right way to normalizing a custom attribute in vops? Usually I do this is sops, by getting the oldmin, oldmax values using attrib promotes and then fitting the original attribute between these and then specifying 0 and 1 for the newmin, newmax values.

I want to do this in vops as its quicker (I've been told). I tried to do it by looping through each point in my geometry, pulling in the attribute value for each point and the ptnum + 1 and doing min and max on that and so forth, but I can't work out how to use the for loop vop properly! It seems sort of non-nonsensical to me.

A simple example would be great. Thanks!
Back to top
View user's profile Send private message Send e-mail
arctor
Houdini Guru


Joined: 22 Jul 2002
Posts: 1441
Location: Toronto, Ontario

canada.gif
PostPosted: Mon Oct 03, 2011 5:21 am GMT    Post subject: Reply with quote

have you tried the normalize VOP?
_________________
Michael Goldfarb | CG Supervisor | Mr. X | www.odforce.net
Back to top
View user's profile Send private message Send e-mail
Dean_19
Houdini Adept


Joined: 02 Aug 2005
Posts: 242
Location: London town

uk.gif
PostPosted: Mon Oct 03, 2011 5:37 am GMT    Post subject: Reply with quote

Yes, this was the first thing I tried. But it didn't seem to output what I expected. Say for example I create a random $CR value on a sphere using a point sop with rand($PT) in the first component of 'add colour', then I multiply it by something random, say 56. This gives me $CR values ranging between around 55.9 and 0.1.

Taking that into vops and plugging it into the normalize vop then outputting it back to Cd simply gives me 1 for every $CR value.

I messed about with it a little by converting Cd into a 'proper' vector (as its a 3 component float) but still the same output.
Back to top
View user's profile Send private message Send e-mail
eetu
Houdini Expert


Joined: 15 May 2007
Posts: 316

finland.gif
PostPosted: Mon Oct 03, 2011 5:45 am GMT    Post subject: Reply with quote

I would think that getting the min and max with attrib promotes is the way to go.
You could then read that value in as a parameter in VOPs and do your per-point math there.

Doing a loop for finding min and max in VOPs is a bad idea. the VOP code is run separately for each point (in a simd/vector -friendly way), so you would end up running the loop for each and every point.
Back to top
View user's profile Send private message
Dean_19
Houdini Adept


Joined: 02 Aug 2005
Posts: 242
Location: London town

uk.gif
PostPosted: Mon Oct 03, 2011 5:54 am GMT    Post subject: Reply with quote

But surely attrib promote has to do some per-point attribute comparing of its own to determine the min and max values too? Although attrib promote does seem to be very quick whenever I use it, so it must do something pretty clever...

Regardless of the 'best' way though, how would this be done in vops using the for loop vop? Does a vops savvy person out there have any ideas?

I'm looking to kill two birds with one stone, getting an example of using the for-loop vop for my own knowledge and a vops method of normalizing attributes.

Thanks!
Back to top
View user's profile Send private message Send e-mail
axebeak
Talkative


Joined: 03 Oct 2006
Posts: 45

ukraine.gif
PostPosted: Mon Oct 03, 2011 5:56 am GMT    Post subject: Reply with quote

This thread has some examples of both approaches, attrPromote->fit to range and loop over points in VOP:
http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=23294
Back to top
View user's profile Send private message
axebeak
Talkative


Joined: 03 Oct 2006
Posts: 45

ukraine.gif
PostPosted: Mon Oct 03, 2011 6:09 am GMT    Post subject: Reply with quote

Quote:
But surely attrib promote has to do some per-point attribute comparing of its own to determine the min and max values too?

Attr promote iterates over points just once (N iterations). In VOP you will iterate over all the points for each point (N^2 iterations). That is assuming you're trying to iterate over the same points you're applying the VOP to.
You can connect a single point to the first input and loop over points in the second input, this will be probably comparable in speed to attr promote, the single point in this case is just a container for computed values.
Back to top
View user's profile Send private message
Dean_19
Houdini Adept


Joined: 02 Aug 2005
Posts: 242
Location: London town

uk.gif
PostPosted: Mon Oct 03, 2011 6:15 am GMT    Post subject: Reply with quote

Ah I see. Thanks for the explanation.
Back to top
View user's profile Send private message Send e-mail
Dean_19
Houdini Adept


Joined: 02 Aug 2005
Posts: 242
Location: London town

uk.gif
PostPosted: Mon Oct 03, 2011 6:16 am GMT    Post subject: Reply with quote

...but this thread raises another question for me...

Why doesn't the normalize vop work for this?!
Back to top
View user's profile Send private message Send e-mail
Erik_JE
Houdini Expert


Joined: 27 Jan 2010
Posts: 292
Location: Stockholm

sweden.gif
PostPosted: Mon Oct 03, 2011 6:38 am GMT    Post subject: Reply with quote

Dean_19 wrote:
...but this thread raises another question for me...

Why doesn't the normalize vop work for this?!


The normalize vop is not for this type of use. It normalizes a vector into 1 unit length.

_________________
Drive, monkey, drive!
Back to top
View user's profile Send private message Visit poster's website
Dean_19
Houdini Adept


Joined: 02 Aug 2005
Posts: 242
Location: London town

uk.gif
PostPosted: Mon Oct 03, 2011 6:42 am GMT    Post subject: Reply with quote

Aha, of course. Thanks.
Back to top
View user's profile Send private message Send e-mail
jkim7979
Lurker


Joined: 27 Mar 2009
Posts: 10

blank.gif
PostPosted: Sun Mar 25, 2012 8:35 pm GMT    Post subject: for loop inside for loop Reply with quote

Hello!
I have a simple vop for loop question. I am trying to use vop for loop to smooth a mesh multiple times by embedding for loop inside of another for loop, but it seems like final global point position value doesn't update. Can someone take a look at my file and see what I am missing? Thanks so much!



smooth_for_loop_test.hipnc
 Description:

Download
 Filename:  smooth_for_loop_test.hipnc
 Filesize:  4.57 MB
 Downloaded:  82 Time(s)

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Houdini Forum Index -> General Discussion All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


phpBB component v1.2.4 RC3 by Adam van Dongen. Based on phpBB © 2001, 2002 phpBB Group