Search - User list
Full Version: How to input an attribute in an HDA parameter?
Root » Houdini Indie and Apprentice » How to input an attribute in an HDA parameter?
probiner
Scene file attached with a example case(Normal Displacement)where the problem is presented in 3 columns:
left: Just HDA with single input value driving all points.
center: Attempt to use a random value attribute @foo to drive each point. Failing.
right: HDA exploded with @foo driving each point. Working as intended.

I inputing @foo and `point(0, “foo”, @ptnum)` in the HDA parameter but it didn't work.

So what's the best way to set up HDA parameters to also be driven by a per point attribute?

Thanks



should look like this with the random value point attribute.

goldleaf
I think parameters can do that only via HDK (but I'd love to be proven wrong!), but you can use a string parm to pass in an attribute name:

vector norm = point(1, "N", @ptnum) ;
@P += norm * point(0, chs("myattr"), @ptnum);

This would let you specify an incoming point attribute to use; you could modify your HDA to allow the user to use a parameter value, an attribute, or even multiply them together.

Hope that helps!
tamte
just use Bindings tab on wrangle to bind your specified attrib to any VEX @ variable name
that way you don't need to use any code insertions
probiner
Thanks for the hints guys. I wasn't aware about the Bindings!
But both solutions seem to require duplication of parameters (one for single values, one to be name the attribute) and my mindset about this is more like what we do in VOPs, where we set an exposed parameter which can then be overridden by wiring something to it, so at SOP level I was expecting to do the same with an expression instead.
Let me know if having 2 parameters per actual parameter is the only way to go about it. Thanks.

[streamable.com]
probiner
Well then two/tree parameters per parameter it is then…

1 - Slider
2 - Attribute name
3 - How they are mixed

I wouldn't mind just a replacement like one connects something to a VOP nodes but with vex import functions…
probiner
Ok, here's the how I went about it to avoid burdening the UI. In a wrangle inside the Asset I check if the attribute exists with the same name as the parameter in the UI, and if not I create it with the UI value:

float attrib = ch(“attrib”) ; // UI value variable from a spare input in the wrangle SOP.

if(! hasprimattrib(0, “hda_attrib”)) f@hda_attrib = attrib ; // If the attribute doesn't exist, it's created and the UI value assigned to it.

or if I just need the variable:

float attrib = ch(“attrib”) ;

if( hasprimattrib(0, “hda_attrib”)) attrib = prim(0, “hda_attrib”, @primnum ) ;


Might not be very pretty to create/rename/copy attributes before the HDA, but since they share the UI parameter name it's straight forward enough, while allowing neat extra control.

Cheers
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB