random particle ID matte

Hello all,

I have a particle system set up in Maya using instanced vray proxies to create a swarm of ants each carrying a different piece of a clock. The proxy system is working a treat and making render times a pleasure!

The guy who will be comping it has (rightly) requested random mattes for the instances so we can create a bit of variation in colour without having to set up multiple shaders/instances etc.

Any ideas how I could do this using the v-ray multimatte renderpass and particle ids?

I’m aware this is a bit of a general dynamics question but hope someone will have come across it in the past. Couldn’t find anything similar in the forum.

Any advice would be greatly appreciated.

Cheers!

Liam

not sure what is particle ID, you however may want to explore render id and object id passes in the render elements tab.

- Create the pp attr UserVector1PP or any other PP attr you’re not using.
- Create creation exp: particleShape1.userVector1PP = <<rand(0,1),rand(0,1),rand(0,1)>>; //assign random matte colors to particles
- Enable export of UserVector1PP from vrayexport attr
- Create particleSamplerInfo
- Create Ramp and delete all extra slots so you’re left with one color slot
- Connect particleSamplerInfo1.userVector1PP to ramp1.colorEntryList[0].color
- Create “extraTex” vrayrenderelement
- Connect ramp1.outColor vrayRE_Extra_Tex.vray_texture_extratex

This gives you the following:

or if you only want RGB mattes use the following exp:
float $rand = rand(0,1);
if ($rand > .66)
    particleShape1.userVector1PP = <<1,0,0>>;
else if ($rand > .33)
    particleShape1.userVector1PP = <<0,1,0>>;
else
    particleShape1.userVector1PP = <<0,0,1>>;

which gives you:


Or, you could pass on the rgbPP directly to your shader to create color variation, without the need for multiple shaders/models or any matte pass.

He asked for a way to setup a matte renderelement, so I think he wants to do the color variation in comp.

Thanks jbvfx, that looks like exactly what i need.

It’s being comped in Nuke So I assume the RGB pass will do fine. It’s really just to break things up a bit as it is looking a bit regular.

Tobbe, that’s also a nice idea, think I’ll leave the compositor with a bit more scope, but cheers anyway.

I’ll give it a go and get back to you with the results.

Thanks again

Just to let you know, that system worked, but it didn’t seem to affect the instanced geometry, so I just duplicated the instances then added each of them to different object properties and multimatted those suckers.

Works well enough but would love to know how your script could be used to affect the instances, would save on set-up time, or did I miss something?

It does work with instances.. as you can in my renders, I use instanced toruses.

What version of Vray are you using? Support for passing PP attributes to the instancer is a rather new feature in 2.0.