Announcement

Collapse
No announcement yet.

VRay Plugin: How to retrieve user defined attribute & object's transform info ?

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

  • VRay Plugin: How to retrieve user defined attribute & object's transform info ?

    Hi,

    Is it possible to get these geometry(or let's say object) related data in texture(or material\brdf) plugin ? I've traced the infomation contained in VUtils::RayResult, VUtils::IntersectionData, VUtils::GenericPrimitive and VUtils::GeometryGenerator but still got nothing usful. Which class equipped with these functionaliy ?

    Thanks.

  • #2
    Yo want to do something similar to the sampler info texture?

    VR::ObjectShadeInstance *si=(VR::ObjectShadeInstance*) GET_INTERFACE(rc.rayresult.si, EXT_OBJECT_SHADE_INSTANCE);
    V-Ray/PhoenixFD for Maya developer

    Comment


    • #3
      The sampler info texture example helps to solve the problem object id retrieving, but i still struggle with how to get user attribute
      I found the tex_mult.cpp provide some hint: The user attribute seems could be retrieved by using getUserProperty() of VUtils:: DefaultVRayShadeData. However the document not provide any detail ablut this function so i don't know exactly how it works. The return data of getUserProperty() is of type tchar*, how it works if my user attribute is float, vector, matrix rather than string ?

      An extra question is in tex_mult.cpp i see two statement about query VRayShadeData object's interface:
      queryInterface<VR::VRaySurfaceUserAttributes>(rc.r ayresult.sd, EXT_SURFACE_USER_ATTRIBUTES);
      queryInterface<VR:: DefaultVRayShadeData>(rc.rayresult.sd, EXT_DEFAULT_SHADE_DATA);
      How can i know all the possible interface that can be queried for VRayShadeData object ? (These information seems not detailed in document)

      Comment


      • #4
        Originally posted by Seila View Post
        The return data of getUserProperty() is of type tchar*, how it works if my user attribute is float, vector, matrix rather than string?
        The user attributes are generally strings and V-Ray itself makes no attempt to convert them to any specific values; how they are interpreted depends entirely on the plugin that reads them. The user color and user scalar textures interpret them in a specific way, but you may want to do something different. I'm attaching the code that we use for those textures. Note that it would be slow to do the conversion at every single shading hit; some kind of hash table to look up the computed value might be more appropriate. If you think this is useful, we can probably fold the code into V-Ray itself.

        How can i know all the possible interface that can be queried for VRayShadeData object ? (These information seems not detailed in document)
        That's an unfortunate disadvantage of using interfaces - it is not clear which interfaces can be queried for a given object type just by looking; nor is it possible to list the interfaces that a given object supports. With that said, the ones that I find by searching through the V-Ray plugins for rc.rayresult.sd are:

        EXT_SURFACE_USER_ATTRIBUTES
        EXT_DEFAULT_SHADE_DATA
        EXT_MAPPED_SURFACE
        EXT_MAPPED_SURFACE_2
        EXT_MAPPED_SURFACE_3
        EXT_VRAY_VERTEX_COLORS_INTERFACE
        EXT_VRAY_COMMON_HAIR_SHADE_DATA
        EXT_LIGHT_LIST
        EXT_CHAMFERED_EDGES
        EXT_SURFACE_INFO
        EXT_VRAY_INSTANCE_DATA

        Additional interfaces available from rc.rayresult.si are:
        EXT_OBJECT_SHADE_INSTANCE
        EXT_DEFAULT_SHADE_INSTANCE
        EXT_GEOMETRY_SAMPLER_INTERFACE
        EXT_REFERENCED_SURFACE
        EXT_REFERENCED_SURFACE2
        EXT_GEOM_PARTICLE_DATA
        EXT_VRAY_PER_PARTICLE_DATA

        Let me know if you have other questions.

        Best regards,
        Vlado
        Attached Files
        I only act like I know everything, Rogers.

        Comment


        • #5
          I still got stuck with retrieving the user attribute. The snippet of my code is as following:

          VR:: DefaultVRayShadeData* def_shade_data = queryInterface<VR:: DefaultVRayShadeData>(rc.rayresult.sd, EXT_DEFAULT_SHADE_DATA);

          if(!def_shade_data)
          {
          printf("[WARNING] No DefaultVRayShadeData interface available ...\n");
          }
          else
          {
          tchar* result = NULL;
          result = def_shade_data->getUserProperty("add");
          printf("Result = %s\n", result);
          ...
          }

          I actually get the DefaultVRayShadeData object and objects in the scene also attached with a user attribute (I fill in the "user attributes" field in object's shape node with add=1.0; ). However the shown messages are all (null) when rendering. How do i fix this problem ?
          Last edited by Seila; 29-09-2015, 01:02 AM.

          Comment


          • #6
            This is the exact code that we are using:

            Code:
            const tchar* result = NULL;
            		VR::VRaySurfaceUserAttributes *surfAttr=queryInterface<VR::VRaySurfaceUserAttributes>(rc.rayresult.sd, EXT_SURFACE_USER_ATTRIBUTES);
            		if (!surfAttr) {
            			VR::DefaultVRayShadeData *sd=queryInterface<VR::DefaultVRayShadeData>(rc.rayresult.sd, EXT_DEFAULT_SHADE_DATA);
            			if (sd)
            				result = sd->getUserProperty(propName);
            		}
            		else
            			result = surfAttr->getUserProperty(rc, propName);
            You can also check if VRayUserColor is working as expected.
            V-Ray/PhoenixFD for Maya developer

            Comment


            • #7
              Thanks ivaylo, it works perfectly now !

              Comment

              Working...
              X