Randomizing an attribute from another one

91 views
Skip to first unread message

Lucas Layeul

unread,
Sep 26, 2024, 9:09:53 AM9/26/24
to gaffer-dev
Hello there,

I'm looking for some way to quickly isolate curve primitives.
For that purpose I noticed the deleteCurves node which deletes curves based on an input attribute.

I'd like, within gaffer to generate a temporary attribute based on the id of the curves so that the user could select a percentage of the curves to display.

In Houdini, this is pretty straightforward by randomizing a new attribute based on the id attribute and then using a threshold to split the curves between the ones to keep and the ones to get rid of. But I'm still quite new to Gaffer and can't yet understand how I could replicate a similar behavior (possibly using the Random/RandomChoice node and querying the existing attribute).

I found some information about how to have that kind of behavior in shaders, but not directly in the geometry's primvars/gaffer attributes.

Do you have any ideas about how this could be achieved ?

Thanks in advance and have a good day.
Lucas.

John Haddon

unread,
Sep 26, 2024, 9:32:05 AM9/26/24
to gaffe...@googlegroups.com
Hi Lucas,
You can do this fairly easily in Gaffer by using the OSLObject node to create a new primitive variable to control what is deleted. I've attached an example which is hopefully fairly self-explanatory - on the OSLCode node you'll find a `percentage` setting that controls how many of the curves to keep.
Cheers...
John

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gaffer-dev/28cf8332-f5c5-4957-8a86-acdeae835201n%40googlegroups.com.
decimateExample.gfr

Lucas Layeul

unread,
Sep 26, 2024, 10:40:46 AM9/26/24
to gaffe...@googlegroups.com
Hey John,

Thanks a lot for your quick answer, that's actually what I found out while digging more into it, glad to see I got it the right way!
Also very nice to see the getattribute() function, I couldn't find something like that in the documentation and used a InInt instead pointing to the shading:index, though I didn't manage to get my custom "hairid" primvar this way, this really helps!

Is there anywhere I can find more information about those context variables like the shading one ? In the documentation about Context Vars I could find information about the scene context to get the current frame or path for example, as well as some but nothing related to this "shading:" one.

Anyway, thanks again for the help, I really appreciate it. Have a good one.
Lucas.

You received this message because you are subscribed to a topic in the Google Groups "gaffer-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gaffer-dev/pesJB-8AXzY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gaffer-dev/CAB8pVgKfH5TSip8BZMfjgpL_z8gd1DmvrBaRzLDZvyXTUnLbLg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages