Jump to content

Vex signatures and function returns


Recommended Posts

Hi guys,

I am stuck with my vex signature. It is a displacement shader and I want to return the new point coordinates.

First obvious change would be to have my function a return type of GEO_Point but then the VEX_Vexop starts to complain heavily in gcc. That does make a bit of sense since in the vex environment there is no GEO_Point type. Closest thing there is a Vector4 but UT_Vector4 or the VEX_TYPE_VECTOR4 don't work either. So what's the trick here?

static void hh_gnoise(int argc, void *argv[], void *data)
   {
        //...lot of code above...
        UT_Vector4 pos((pt->getPos().x() +f),(pt->getPos().y()+f),(pt->getPos().z()+f));

	GEO_Point *pout;

	pout->setPos(pos,1);

	//return pos;
    }

void newVEXOp(void *)
    {
	new VEX_VexOp("gnoise@*PPVFIFFFFFFFFFFF",hh_gnoise, VEX_DISPLACE_CONTEXT,NULL,NULL,VEX_OPTIMIZE_2,true);
    }

And a 2nd question. After compiling the code, i just can copy the .so file to somewhere on my $HOUDINI_DSO_PATH and it gets picked up in Vex? Or do you also need to "register" it somewhere else? (which i thought you should; i thought i came across some post where you had to edit some file to make it all work but can't find it anymore).

Thanks,

Hans

Link to comment
Share on other sites

  • 3 weeks later...

You need to create a vex/VEXdso file in your houdini directory (i.e., ~/houdini11.0/vex/VEXdso) containing entries like,

vex/my_dso_with_vex_declarations.so

Basically, a relative path pointing to your dso within the dso directory (so, we'd have the dso at ~/houdini11.0/dso/vex/my_dso_with_vex_declarations.so)

GEO_Point, like you said, isn't a vex type, so I wouldn't even bother exploring that avenue. Instead, try something like this:

static void rand_test(
    int argc,
    void** argv,
    void* data)
{
    UT_Vector4* result = reinterpret_cast<UT_Vector4*>(argv[0]);

    int seed = *reinterpret_cast<int*>(argv[1]);

    srand(seed);
    result->assign((rand()%100)/100.0,
                    (rand()%100)/100.0,
                    (rand()%100)/100.0,
                    1);
}
void newVEXOp(void*) {
    new VEX_VexOp(
        "rand_test@&PI",
        rand_test,
        VEX_ALL_CONTEXT);
}

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

It's a pain, but the cool part is that you can query all of configured DSO symbols outside of Houdini:

vcc -X SOP

It's much easier to debug these problems when you don't have to wait for Houdini to load to see if your VEX functions are recognized or not. :)

Edited by Vormav
Link to comment
Share on other sites

It's a pain, but the cool part is that you can query all of configured DSO symbols outside of Houdini:

vcc -X SOP

It's much easier to debug these problems when you don't have to wait for Houdini to load to see if your VEX functions are recognized or not. :)

Tyvm sir, that does indeed save me some time :D

Cheers,

Hans

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...