User Attributes

Are user attributes animatable? Or can I connect an user attribute via script to an attribute on the object?

Thanks

Most V-Ray attributes can be animated.
Please advise what exactly you are trying to achieve?

I have a couple objects (spheres) traveling along a path. All objects have the same shader. At the end of the path I would like to transparent fade out the objects.
It would be great to be able to do this without giving each object a different shader, because there are a lot of them.

For this I would like to add an additional attribute to each object that can control its opacity.

But it seems that V-Ray user attributes, which are required to use in shaders, on objects can’t be animated, so I’d like to connect them to a Maya attribute.

This conclusion is not correct starting with the current nightly build (rev>=20095). :grin:
Now the user attributes can be animated.

Like Theodor mentioned, since revision 20095 and later of the nightly builds you can actually add your own V-Ray user attributes which can be animated. For example, you could add a color attribute to your mesh like this:```
addAttr -at float3 -usedAsColor -longName vrayUserColor_opacityColor;
addAttr -at “float” -parent vrayUserColor_opacityColor -longName vrayUserColor_opacityColorR;
addAttr -at “float” -parent vrayUserColor_opacityColor -longName vrayUserColor_opacityColorG;
addAttr -at “float” -parent vrayUserColor_opacityColor -longName vrayUserColor_opacityColorB;


Best regards,
Vlado

Cool stuff.

Are those color attributes only accessible via script? I was trying it via the Attributes drop down on the object. That is why I did not find it.

Custom boolean attribute work with user scalar ?
Or we must to use float attribute ?

Technically you could also do it with Attribute > Add… but it doesn’t seem to work for colors or at least I could not make it work for color values.

Best regards,
Vlado

I’m not sure about that one, I have to check.

Best regards,
Vlado

Strange. Today it does not seem to work anymore, or I am doing something wrong. Here is the scene (Maya 2012)

V-Ray: V-Ray for Maya version 2.25.01, revision 20116 from Mar 21 2012, 08:44:37
usercolor.zip (21.6 KB)

Does it have to be on the shape? Was sure that I did it on the transform yesterday. On the shape node it seems to work

Yes, for the moment this works for shapes only (unlike the normal V-Ray user attributes). There was fear that it would take too much time to look up the attributes through the whole hierarchy.

Best regards,
Vlado

Would it be possible to have a Vray User String node? With the intention of it connecting to a file node (not quite sure how that would work)

I’ve got the VrayUserColour working nicely but it would be nice to be able to have one shader using different textures per object.

You can do this using condition node and VrayUserScalar. No need Vray User String.
Connect the VrayUserScalar to the condition node and connect your textures on the color is True, color is False.

After, just choose an number for the texture.

There is no need for that, it is built into the File node as implemented by V-Ray; just enclose the attribute with <> brackets in the texture file name, f.e. “textures/<diffuse>.png”. You might also want to use the latest stable build for that, as the official release has some issues with this.

Best regards,
Vlado

Thanks Vlado!

Using the condition nodes would have worked but I can see us having lots and lots of similar but varied textures for this job and it’d be nice to store the file name string with the geo.

Are User Attributes working in the 2.20.01 official release?

Trying to swap out the diffuse colour of a shader and can’t seem to get it working…

I’m using the same script I used before (see below) then creating a vrayUserColor node and using diffuseColor as the string.

On a separate note, is it possible to do this over instances? Maybe putting the colour attribute on the transform node?

//random diffuse colour
string $sel[] = `ls -sl`;
for($current in $sel)
{
string $shape[] = `listRelatives -s -path $current`;
    print ($shape[0] + "\n");
        if(!`attributeExists vrayUserColor_diffuseColor $shape[0]`)
        {
        addAttr -at float3 -usedAsColor -longName vrayUserColor_diffuseColor $shape[0];
        addAttr -at "float" -parent vrayUserColor_diffuseColor -longName vrayUserColor_diffuseColorR $shape[0];
        addAttr -at "float" -parent vrayUserColor_diffuseColor -longName vrayUserColor_diffuseColorG $shape[0];
        addAttr -at "float" -parent vrayUserColor_diffuseColor -longName vrayUserColor_diffuseColorB $shape[0];
        setAttr -e -keyable true ($shape[0] + ".vrayUserColor_diffuseColor");
        setAttr -e -keyable true ($shape[0] + ".vrayUserColor_diffuseColorR");
        setAttr -e -keyable true ($shape[0] + ".vrayUserColor_diffuseColorG");
        setAttr -e -keyable true ($shape[0] + ".vrayUserColor_diffuseColorB");
        }
    vector $color = <<rand(0,0.3),rand(0,0.2),rand(0,0.2)>>;
    print ($color + "\n");
setAttr -type double3 ($shape[0] + ".vrayUserColor_diffuseColor") ($color.x) ($color.y) ($color.z);
}

Yes, however they work in their original form, as described in the current documentation on spot3d (i.e. you have just a single string attribute that contains all attributes).

Trying to swap out the diffuse colour of a shader and can’t seem to get it working… I’m using the same script I used before (see below) then creating a vrayUserColor node and using diffuseColor as the string.This will not work in the official builds, but should work in the nightly/stable builds.

On a separate note, is it possible to do this over instances? Maybe putting the colour attribute on the transform node?In their original form (the single string attribute) you can put user attributes anywhere in a hierarchy of objects and this will affect all objects below. The separate attributes (ones that start with vrayUserColor_ or vrayUserScalar_) only work for shapes.

Best regards,
Vlado

Thanks for the prompt response Vlado