Basic vops question

   7922   11   2
User Avatar
Member
319 posts
Joined:
Offline
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!
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
have you tried the normalize VOP?
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
319 posts
Joined:
Offline
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.
User Avatar
Member
606 posts
Joined: May 2007
Offline
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.
User Avatar
Member
319 posts
Joined:
Offline
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!
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
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 [sidefx.com]
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
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.
User Avatar
Member
319 posts
Joined:
Offline
Ah I see. Thanks for the explanation.
User Avatar
Member
319 posts
Joined:
Offline
…but this thread raises another question for me…

Why doesn't the normalize vop work for this?!
User Avatar
Member
299 posts
Joined: Jan. 2010
Offline
Dean_19
…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!
User Avatar
Member
319 posts
Joined:
Offline
Aha, of course. Thanks.
User Avatar
Member
10 posts
Joined: March 2009
Offline
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!

Attachments:
smooth_for_loop_test.hipnc (4.6 MB)

  • Quick Links