Jump to content

Particle attributes to SOPs


Recommended Posts

Hi guys. I'm working on a previs and thought it would be a great opportunity to learn more about houdini. I'm drawing a bunch of curves from particle trails via the Split POP and then Sweeping a profile and Skinning them to create a bunch of tubes. I can't seem to control the scale of the Swept profiles using the $AGE of the particles. Any help would be greatly appreciated!! Thanks!!

.xX

tubes_06c.hip

Link to comment
Share on other sites

If you want to use a particle attribute in SOPs you have to create an attribute in POPs. If you want to use a group from POPs in SOPs, you have to preserve the group.

The $AGE attribute creation can be done a couple ways:

-Lay down an Attribute node in POPs, and make the value $AGE.

-Use a VOP POP and connect Age into an Add Attribute or Parameter VOP.

Link to comment
Share on other sites

The problem is that the Sweep SOP doesn't have much support for local variables other than $PT coming from your backbone geometry. To use the age of the particles you'll want to use a point expression instead of attempting to use a local variable. Since the age is the first component of the Life attribute you can use something like this:

point(opinputpath(".", 1), $PT, "life", 0)

Link to comment
Share on other sites

The problem is that the Sweep SOP doesn't have much support for local variables other than $PT coming from your backbone geometry. To use the age of the particles you'll want to use a point expression instead of attempting to use a local variable. Since the age is the first component of the Life attribute you can use something like this:

point(opinputpath(".", 1), $PT, "life", 0)

this wouldn't work since you have more than one curve as a backbone

because $PT in sweep SOP is vertex number of each primitive and not point number

if you've had "age" as vertex attribute you can use

vertex(opinputpath(".", 1), $PATH, $PT, "age", 0)

but this gives me segmentation error

so you need to move this to foreach SOP to sweep per backbone primitive and then you can use point() expression

here is the working example

tubes_06c_fix.hip

Link to comment
Share on other sites

Thanks guys!! I had noticed that my attributes were disappearing in the Sweep SOP via the details view, but that's where it ended for me. Any pointers on where to learn more about expressions?

I noticed that the Foreach SOP was changed from Group to Number. I tried switching it back and setting the Group Mask to group*, but didn't have any luck. Does this have something to do with the type of object in the groups?

Also, this is the first time I've seen VOPs in action and I'm blown away. Thanks again for your help!! On to shading each object with a different shader.

.xX

Link to comment
Share on other sites

Yeah. Actually looking at the file now it definitely crashes. I'll submit a bug for that.

Your attributes are disappearing because the attributes from the backbone geometry aren't transferred to your new skinned geometry.

You are right in that your groups are Point groups and currently the ForEach only supports Primitive groups. You would have to convert them to prim groups in order for the group mask to work. As anim did, just using the nprims() expression is probably the better way to do it and it's what I'd use.

VOPs are definitely great at a lot of things. Also as anim also showed, I especially like using Ramps to drive widths of curves. You can get some cool shapes and effects with them. Also useful for building an Extrude by Curve tool.

Link to comment
Share on other sites

Submitted the bug: #39601. I'll post back here whenever more information is available. Creating an example from scratch using the same expression and basic setup works fine so it's most likely some random issue which are always my favorite.

Link to comment
Share on other sites

I was able to texture each tube independently by referencing a different SHOP per tube, but what I'd really like to do is reference the same SHOP and push a different value into the diffmap field. Is this possible?

I've attached an example to illustrate which takes anim's example and references a different SHOP per tube. I also changed the life expectancy of the Split POP's birthed particles to be longer and adjusted the width attrib VOP to avoid all tubes shifting SHOPs after a tube "dies". Any further help or insight would be greatly appreciated!!

Link to comment
Share on other sites

you've forgotten to attach the file

but you can very easily create primitive or point attribute with the path to the texture and if the name would be same as texture parameter in shop, then this attribute value will be used instead(it will not be visible in viewport however)

and you've already had attribute(parent) which is unique per tube to avoid shifting textures when they are appearing/dying

you just need to recreate that attribute in for each and use first point from delete1 SOP which will contain correct parent value for each iteration

then after foreach you can use that attribute to generate your texture names

if you upload the file i can make those changes

Link to comment
Share on other sites

Here's another question. I'd like each tube to have a unique and sequential identifier so that I could easily map to a fixed set of resources (textures or SHOPS). I thought I could use "PARENT" as suggested, but it seems to be the $ID of the parent particle when birthed also includes all of the particles from the Split POP so the parent id's are spread out. For example, my "PARENT" = [1,1,13,1,13,1...] and I'd like it to equal [1,1,2,1,2,1,...]. In the meantime I'll just modulo, but I'd love to understand how to control this. BTW I'm getting the feeling that I should just do it all in the foreach, but that sounds like trouble. I wouldn't be able to always see what was happening and i doubt it's super efficient. Thanks again for all of your help!! Attached is the simplified version of the file.

parent_00.hip

Link to comment
Share on other sites

that can be problematic to do in single popnet since the ids are really working the way you described

i've attached an example of using one popnet for parent particles

then create attribute from particle ids called parent_id

then in second popnet every new sourced particle inherits this attribute

then create curves with add SOP

and attribute promote parent_id to primitive attribute to have just one attribute per curve

i attach two files, above described parent id example

and some example for using that id in your scene for generating texture names

different textures can be seen in render, in viewport there is only default material texture

i've used standard butterfly images, which are part of houdini and there is only 7 of them so don't expect texture for parent_id>7

there is also only basic mapping, it depends on your needs

parent_id_example.hip

tubes_07_shops_fix.hip

Link to comment
Share on other sites

Awesome!! The Impulse Birth rate of $NPT in the second POPnet was a nice trick!

I'm not sure the texturing example is working properly for me. It looks like the diffmap primitive attribute is being created properly, but it's not being used by the SHOP. I noticed that the SHOPs diffmap is set to butterfly1.pic and if I remove that the tubes are no longer textured. Are you seeing different butterfly textures per tube? Thanks again!!

Link to comment
Share on other sites

as I said you will not see different textures in viewport

the butterfly1.pic is there to see at least something, it'll work without it too because the main thing is that the geometry has now diffmap string attribute which contains path to the texture and this is different per tube

the SHOP applied to this object will use that attribute instead of current value which is now butterfly1.pic

but to see this you need to render the frame with mantra

but as i also said if the tube wants texture butterfly8.pic and higher you'll get warning during render that butterfly8.pic was not found, but if you make enough textures for all tubes it'll be fine

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...