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 ?
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:
queryInterfaceVR::VRaySurfaceUserAttributes(rc.rayresult.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)
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:
if(!def_shade_data)
{
printf(" 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 ?
const tchar* result = NULL;
VR::VRaySurfaceUserAttributes *surfAttr=queryInterface<VR::VRaySurfaceUserAttributes>(rc.rayresult.sd, EXT_SURFACE_USER_ATTRIBUTES);
if (!surfAttr) {
VR::smile:efaultVRayShadeData *sd=queryInterface<VR::smile:efaultVRayShadeData>(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.