| View previous topic :: View next topic |
| Author |
Message |
Dean_19 Houdini Adept
Joined: 02 Aug 2005 Posts: 242 Location: London town

|
Posted: Mon Oct 03, 2011 4:21 am GMT Post subject: Basic vops question |
|
|
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 |
|
 |
arctor Houdini Guru

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

|
Posted: Mon Oct 03, 2011 5:21 am GMT Post subject: |
|
|
have you tried the normalize VOP?
_________________ Michael Goldfarb | CG Supervisor | Mr. X | www.odforce.net |
|
| Back to top |
|
 |
Dean_19 Houdini Adept
Joined: 02 Aug 2005 Posts: 242 Location: London town

|
Posted: Mon Oct 03, 2011 5:37 am GMT Post subject: |
|
|
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 |
|
 |
eetu Houdini Expert
Joined: 15 May 2007 Posts: 316

|
Posted: Mon Oct 03, 2011 5:45 am GMT Post subject: |
|
|
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 |
|
 |
Dean_19 Houdini Adept
Joined: 02 Aug 2005 Posts: 242 Location: London town

|
Posted: Mon Oct 03, 2011 5:54 am GMT Post subject: |
|
|
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 |
|
 |
axebeak Talkative
Joined: 03 Oct 2006 Posts: 45

|
|
| Back to top |
|
 |
axebeak Talkative
Joined: 03 Oct 2006 Posts: 45

|
Posted: Mon Oct 03, 2011 6:09 am GMT Post subject: |
|
|
| 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 |
|
 |
Dean_19 Houdini Adept
Joined: 02 Aug 2005 Posts: 242 Location: London town

|
Posted: Mon Oct 03, 2011 6:15 am GMT Post subject: |
|
|
| Ah I see. Thanks for the explanation.
|
|
| Back to top |
|
 |
Dean_19 Houdini Adept
Joined: 02 Aug 2005 Posts: 242 Location: London town

|
Posted: Mon Oct 03, 2011 6:16 am GMT Post subject: |
|
|
...but this thread raises another question for me...
Why doesn't the normalize vop work for this?!
|
|
| Back to top |
|
 |
Erik_JE Houdini Expert

Joined: 27 Jan 2010 Posts: 292 Location: Stockholm

|
Posted: Mon Oct 03, 2011 6:38 am GMT Post subject: |
|
|
| 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 |
|
 |
Dean_19 Houdini Adept
Joined: 02 Aug 2005 Posts: 242 Location: London town

|
Posted: Mon Oct 03, 2011 6:42 am GMT Post subject: |
|
|
| Aha, of course. Thanks.
|
|
| Back to top |
|
 |
jkim7979 Lurker
Joined: 27 Mar 2009 Posts: 10

|
Posted: Sun Mar 25, 2012 8:35 pm GMT Post subject: for loop inside for loop |
|
|
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!
| Description: |
|
 Download |
| Filename: |
smooth_for_loop_test.hipnc |
| Filesize: |
4.57 MB |
| Downloaded: |
83 Time(s) |
|
|
| Back to top |
|
 |
|