forEach stamping

   4428   6   2
User Avatar
Member
53 posts
Joined: July 2005
Offline
Hey guys.

I have a problem.

For the last while I have been making extensive usage out of the copy sop but I think I will have to make use of the for each sop in a way that I havent yet had the chance to.

So I make use of stamping inside the copy sop all the time, and I find it simple because it separates the variable, the function, and the calling of the variable. It makes sense.

However when I want to create a fit01 expression on a subdivide depth on every for each instance using the stamping function I am finding it confusing as to why it is not working out.

What I am trying to do is make a grid of a few divisions( say, 3x3 ) ( polygons ).

use connectivity/partition to split the primitives up, and assign a colour/group. ( I do this because I can separate by colour, which I can paint, or use Vops/textures )

Then inside the for each I split up every poly based on colour.

On every polygon I want a random subdivision depth, and I am guessing I will have to make use of stamping/ some expression to make it random for each piece )

Any thoughts?

EDIT, I got it working using this expression,

opdigits(stamps(“..”, FORVALUE, “”))

But what I am hoping to get is a random 0,1 value for each poly/group in the depth value of the subdivision node.
-m-k-
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
You can use this expression in your For Each SOP :

stamp(“..”, “FORIDXVALUE”, 0)]

then to define random Depth for each prim just use this expression :

fit01(rand(stamp(“..”, “FORIDXVALUE”, 0)),0,7)

Now , For Each SOP subdivide each prim by random depth between 0 to 7 !
https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
And this is a very simple project about this :wink:

Attachments:
JK_Foreach_Subdiv.hip (63.7 KB)

https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
If you like to use Paint SOP (or Color/Textures) for subdividing specify primitives , use this project.
Also you have some other parameters such as Bias for interpolating depth between Random Depth and Simple Depth. 8)

Attachments:
JK_Foreach_Subdiv_Advance.hip (81.1 KB)

https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
53 posts
Joined: July 2005
Offline
Thanks a ton Looks like I wasnt wrong when experimenting with expressions. I just had to use forIDvalue and not forvalue. That was the only thing that made the difference.
-m-k-
User Avatar
Member
4516 posts
Joined: Feb. 2012
Offline
ambient-whisper
Thanks a ton Looks like I wasnt wrong when experimenting with expressions. I just had to use forIDvalue and not forvalue. That was the only thing that made the difference.

Also bear in mind that if you have 2 nested ForEach SOPs, you have to rename them to make sure they are not using the same names for FORIDXVALUE and FORVALUE. Otherwise you will waste a lot of debugging efforts.

I heard that the users should be responsible for this but I think this is a bug. Even if it wasn't, how could you know what a locked 3rd party HDA is using for these parameters when you have to use it inside a ForEach SOP?

Thought I would point this out so you save some time
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
99 posts
Joined: Aug. 2014
Offline
I have a similar issue, that I think a foreach is the way to solve but so far no luck.

I am basically trying to find the closest vert/ ray intersection for each of a number of objects copied along curve. I can find the closest point and copy “one” object to that location, but I can't seem to solve how to find the closest point for each object relative to it.

I think the issue really at the moment is finding the closest point in each rayhitgroup, vs. at the moment I am seeing all the ray hit groups made by all the objects and then culling away all but the smallest value overall, not relative to each object.

Any ideas? different approach?

** Never mind, I sorted it out. I was trying to do too much in the foreach, and broke it down to just the ray hits, plus a group mask.
  • Quick Links