Announcement

Collapse
No announcement yet.

GeomRayserverInstancer User Attributes per instance

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GeomRayserverInstancer User Attributes per instance

    Hi,

    I'm using the GeomRayserverInstancer to generate millions of instances. Everything works except I can't get user attributes to work.
    I want to assign a user attribute to each instance. ie "rand= (random number from 0 to 1)"

    In the documentation there's different functions for setting user attributes, but it looks like "set_user_attributes_bin", is the one to use.
    The argument for this function is an intList, so I guess I need to convert my CharString to a byte int?
    The documentation also says to refer to "BinUserAttributesWriter". Where can I find information about that?
    Jacob Børsting
    Head of Pipeline @ Ghost VFX

  • #2
    If you have access to V-Ray SDK it's defined in user_attributes.h.
    It's basically a simple binary packer.
    Code:
    const char attrRand[] = "rand";
    const int atttrRandLen = COUNT_OF(attrRand)-1;
    
    VUtils::BinUserAttributesWriter userAttrBin;
    
    // Instance 1.
    userAttrBin.add(attrRand, atttrRandLen, 0.5f);
    userAttrBin.close();
    
    // Instance 2 no attributes.
    userAttrBin.close();
    
    // Instance 3.
    userAttrBin.add(attrRand, atttrRandLen, 0.1f);
    userAttrBin.close();
    
    const VUtils::IntRefList uaBin = userAttrBin.toRefList();
    const VRay::VUtils::IntRefList attributes = *reinterpret_cast<const VRay::VUtils::IntRefList*>(&uaBin)
    
    plugin.set_user_attributes_bin(attributes)
    V-Ray For Houdini | V-Ray Hydra Delegate | VRayScene
    andrei.izrantcev@chaos.com
    Support Request

    Comment


    • #3
      Works like a charm.

      Thanks!
      Jacob Børsting
      Head of Pipeline @ Ghost VFX

      Comment


      • #4
        Another question.

        Is it possible to switch geometry source per instance? Similar to the shaders/shader_indexes.
        Last edited by jbvfx; 07-05-2020, 06:33 AM.
        Jacob Børsting
        Head of Pipeline @ Ghost VFX

        Comment


        • #5
          I'm trying to do the same thing in the 5.10.01 SDK and I don't see
          Code:
          VUtils::BinUserAttributesWriter
          anywhere. Is there a new recommended way of packing the binary data into an IntList?

          Comment


          • #6
            Ahhhh, never mind. I didn't catch that it is in the VRay SDK, not the AppSDK. Carry on.

            Comment


            • #7
              BinUserAttributesWriter is available for testing now in V-Ray AppSDK nightly builds (currently in C++ only).

              Comment

              Working...
              X