I was wondering if there is a Maya and/or V-Ray node that allows you to randomize your texture color in a defined space for each object that has the material. I couldn’t find anything on the internet - so maybe some power user could help me with that. Would be awesome if there is something deep hidden inside in Maya or V-Ray that allows you to do that.
No, we don’t have such thing on a texture/color basis.
But you could use some MEL scripting to do that, where you give a range out of which you pick your colors and assign it afterwards.
Here’s an example, along with a scene:
string $objects[]=`ls -sl`;
string $o;
for ($o in $objects) {
vray addAttributesFromGroup $o vray_user_attributes 1; // adds vray user attributes to the selected nodes
vector $v=`rand <<0,0,0>> <<1,1,1>>`; // random range from 0 to 1 for the 3 color components
evalDeferred("setAttr -type \"string\" "+$o+".vrayUserAttributes \"random="+$v.x+","+$v.y+","+$v.z+";\""); // sets the attribute and value for each node
}
Just select your objects and run this. Then assign one shader to all of them, in the diffuse add a vrayUserColor texture and just type in “random” in the attribute field. randomColor.zip (11.8 KB)
Actually, the V-Ray implementation of the samplerInfo node can produce a random floating-point number of each object in the scene, which could then be used to drive f.e. a Ramp node or something), we just have to expose this.
I was thinking of something like the hairSamplers randombyStrand, and plug it into a ramp would be so great for vray (and maybe not that hard?). Maybe have a few different options like random by object, random by shell(element?, for example for tons of leafs all combined into one object, to save on the transform node count).
But that sounds already like what you are talking about Vlado. Would be VEERY powerful.
The same idea, but to randomize shaders would also be equally great (but in a different way).
Yay! That would be awesome. How does one get access to Nightly builds? I’ve sent requests before to support@chaosgroup.com but that hasn’t seemed to work. Should I be contacting a different address?
You can email me to vlado@chaosgroup.com and I’ll pass it along. Our support guys are specifically instructed not to give out nightly builds indiscriminately
Wow, superb!
This works on a per Object base or per face? Or maybe even per shell? Per shell would be amazing, because on trees, grass etc. you don’t have single objects but a lot of combined shells.
There is a per-object option right now; Vlado Nedev recently coded something for Modo that works based on mesh elements, I guess we could use that too at some point.
This is already implemented in the nightlies and will be included in the next SP.
Here’s a quick example of how it works, along with a scene that I’m attaching:
- add extra vray attributes to a samplerInfo node (this will expose additional outputs to the samplerInfo)
- connect the samplerInfo.vrayRndomByID to a ramp’s vCoord (if you’re using a vRamp) OR uCoord (for a uRamp) | or both, if you intend to switch between ramp modes
--> the ramp’s position and color values will be the range of colors to be distributed to the objects
--> plug the ramp into a shader and use the same shader on lots of objects random_by_render_id.zip (9.37 KB)
Thats really awesome! Gonna try it out.
We’ve needed a good way to do this for ages. (singleSwitch really isnt optimal, and its a hassle to add more objects).
Would it be possible to get this sampleInfo fix working for shell/elements too in the future?
If we add 1 color to the ramp, connect a texture to this color, an connect the vrayRndomByID to the V ramp, obviously, it will pick a random color from the texture, true ?
Yes, but if there’s only one color in the ramp, chances are all the random colors will equal this color.
The setup is similar to the one for hair/fur randomByStrand.