__ passing attribute passing

   6751   8   1
User Avatar
Member
16 posts
Joined: 7月 2005
Offline
evening all,

is it true to say that any point attribute (say “life”, “numhit”, “id”) can be passed into a vex shader?

I have manged to pass floats and vectors (having found that once they are named as parameters in the parameter list they are in) but seem to be struggling with other attributes.
In the attribute spread sheet things like “numhit” and “id” look like ints and ive declared them as int parameters, but they dont seem to be bound and i dont seem to get values from them.

should they be passing? or are some attributes nonpassable?????

thanks for any help, much appriciated (one week to my deadline and all, ha)

ben
User Avatar
Member
16 posts
Joined: 7月 2005
Offline
btw

my subject was supposed to be something more sensible, but it wasnt.


ben
User Avatar
Member
639 posts
Joined: 7月 2005
Offline
Hi Ben, you can pass any arbitrary attribute to your shaders depending on how your VEX shader is set up. You just have to ensure your attribute names to matches that declared in your VEX shader.

You can use Attribute SOP to rename your attributes and Attribute Create SOP to create any arbitrary attributes.

I don't believe there are any default shaders shipped with Houdini that will recognize attributes such as “numhit” “id” etc. However, depending on the type casting (vector, float, etc.) of the variable in your shader, you may rename those attributes to that of the shader.
User Avatar
Member
16 posts
Joined: 7月 2005
Offline
cheers alex.
i dont suppose you know whether “humhit” and “id” are ints or not do you? i had ago at passing them using vex parameters declared as ints and with their names but they did not seem to be bound. are they of some other type?

ben
User Avatar
Member
639 posts
Joined: 7月 2005
Offline
Hi Ben,

The numhit and id are integer indeed. Try using the isbound() to test and see if it works.


my_shader(int numhit = 0, id = 0)


int foo, bar;

if(isbound(“numhit”))
foo = numhit;
else
bar = default;



Be ware, tho, the “id” is a global variable defined for SOP/POP context.
User Avatar
Member
16 posts
Joined: 7月 2005
Offline
thanks again alex,
ive had success in using the numhit attr in a pop VEXop, and it work lovely. but
i would really like to work at the shop surface context, switching sprites based on hit ( both time and number). these attributes pass into the sop context and i can see them in the parameter spreadsheet and when i middle mouse on my nodes.
when i have a surface shader that checks (isbound “numhit”) though i get 0, unlike in pops where it is fine.
my solution so far is to set attributes i know i can pass through successfully (ie Cd) based on numhit in the pop context.
is this the best? or am i missing some thing?

ta
ben
User Avatar
Member
639 posts
Joined: 7月 2005
Offline
Hmm… odd…. let me check back with you on this one later. I was very certain that you can pass any arbitrary attributes to VEX… ops:
User Avatar
Member
639 posts
Joined: 7月 2005
Offline
Hey.

I think that it was correct that you can pass any arbitrary variable to VEX. However, you'd have to be careful about certain functions becuase some function won't accept integer input and will thus give you error. Could that have been the problem?


My apology, I am learning VEX as well, so I am eons away from being advanced user…
User Avatar
Member
16 posts
Joined: 7月 2005
Offline
thanks for yur help,

im going with passing attributes via the Cd attr, which works but is a bit messy.
maybe i will find the answer some time in the future.

again, ta

ben
  • Quick Links