Announcement

Collapse
No announcement yet.

Randomizing vray proxies...

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

  • Randomizing vray proxies...

    Is there any way to randomize vray proxies or the textures on vray proxies?

    Lets say we have a hypothetical crowd scene. It'll be a still frame so the characters in the scene don't even need to move. Is there any way to import a row of a proxy and then say either:
    A. Swap this proxy out for one of twenty random vrmeshs in a specific folder
    or
    B. Swap out the texture on the proxy for one of 20 random textures in the sourceimages folder.

    Is this possible? And if not what alternative methods could you recommend to accomplish something similar?

    Please advise.
    Thanks!

  • #2
    Originally posted by evanerichards View Post
    A. Swap this proxy out for one of twenty random vrmeshs in a specific folder
    Hmm, you could do something like:

    Code:
    string $proxies[] = {"<path>/<filename1>.vrmesh", "<path>/<filename1>.vrmesh", "<path>/<filename2>.vrmesh"};
    int $randomNum = `floor ( rand(0, size($proxies) - 1) + 0.5)`;
    setAttr -type "string" mesh_vraymesh.fileName2 ($proxies[$randomNum]);
    Given that mesh_vraymesh is the name of the proxy node inside maya. $proxies[] stores the full paths you've listed for different proxies randomly be loaded.
    Which would basically get a random entry from the list of proxies you have stored in $proxies[] and set it as a file name to the fileName2 of your VRayMesh node.

    Maybe there's a better solution for this, but it's all I can think of at the moment.

    Originally posted by evanerichards View Post
    B. Swap out the texture on the proxy for one of 20 random textures in the sourceimages folder.
    For this you can use the Maya singleSwitch node. I'm attaching an example scene for this. Here's the setup:
    - there are 4 spheres in the scene, all of them with the same vrayMtl
    - a ramp is connected to the diffuse of vrayMtl
    - the ramp has two positions, each is mapped with a different texture
    - interpolation is "none" and the ramp is a VRamp
    - the singleSwitch.output is connected to ramp.vCoord
    - this script:
    Code:
    int $inputs = `getAttr -size singleShadingSwitch1.input`;
    for ($i=0; $i < $inputs; $i++)
        setAttr ("singleShadingSwitch1.input[" + $i + "].inSingle") (rand(0,1));
    adds a random number from 0 to 1 to each input in the single switch, which in turn samples a different position from the ramp and renders the texture found at that position.
    or you can randomize user attributes to the mesh nodes, then use vrayUserScalar to read them and them pass this to the ramp.vCoord
    or you can use a similar approach as for the proxy filenames, only with textures.

    singleSwitch1.zip
    Last edited by yolov; 07-04-2015, 09:17 AM.
    Alex Yolov
    Product Manager
    V-Ray for Maya, Chaos Player
    www.chaos.com

    Comment

    Working...
    X