Yep, perhaps a bug.
Vlado will say us.
Here you go:
http://www.treyharrell.com/downloads/th_ShaveMultimatter.zip
It’s quick & hacky, but gets the job done. I’ve used a similar technique in production… the mattes are quite good, but depending on how picky your comp artists are, nothing short of a premulted & isolated alpha may be good enough for them ![]()
Unzip the .mel into your maya/<version>/scripts directory and restart Maya.
From there, make sure VRay is set as your render engine and you’ve got a shave node in your scene.
Then you alter the pre-render MEL command in your VRay common tab to look like this:
shaveVrayPreRender;th_ShaveMultimatter(200);
This will give you a separate multimatte for every Shave node in your scene automatically, starting with ObjectID 200 in this case. Change the number in the command if you’d like the change your starting ID.
You can hack the script if you don’t like the pass/element naming conventions.
It uses the ugly/hacky old-style render element creation code, so it should work with VRay 1.5+ (2.0 introduced much, much cleaner ways to create passes… using old-style for compatibility with both).
--T
I’ve got this working fine here…
http://www.treyharrell.com/downloads/hair3UVs.ma.zip
For whatever reason, the hairSystem doesn’t pick up the correct UV’s color if piped through a gamma node first. Bizarre.
Anyhow…
- Create a hair system on a sphere or something
- Map a ramp or other procedural to a mat on the surface (gamma corrected, of course)
- Go to the hair system’s shading rollout and assign your procedural to the color value there
- Add hair shader attrs to the hair system
- Create a hair3 node, assign it to the hair system’s extra attr
- create a vray hairsampler node and a gammacorrect node
- pipe hairsampler.hairColor into the gamma node (at .4545,.4545,.4545 gamma)
- pipe the gamma node into your desired slot on the hair3 mat
--T
Hmm I did some more tests today. It seems it works with a ramp but not with a checkboard. But I get the same problem with mentalray. And even if you bake the texture you still get the same result. But this seems like a maya bug and not vray since it looks wrong in the viewport as well and in mentalray.
Actually Trey almost got there, but there is still some tinkering left - once you get the nice red/green gradient on the hair colors, you can use them as UV coordinates for your checker texture.
Best regards,
Vlado
Awesome, thanks Trey! I’ll give this a try ![]()
Hey Vlado,
I almost let this one slide… are you suggesting to use a red/green UV ramp then use the hairsampler’s color attr to drive uv placement (instead of a place2d etc) on maps attached to the hair3 shader?
That…just…might…work!
--T
Heh… maybe not. SamplerInfo UV out onto hairsystem color breaks, as do two ramps added. They break on the pfx preview/mental ray too so I’m assuming this is a Maya bug, like the gamma issue. A manually painted UV file ramp *sort of* works.
But really, just plugging a file texture into haircolor then using the hairsampler color out seems to be the best approach at the moment. You can still use blend color on each follicle clump if you want to add streaks and the like.
I’m not too concerned about some procedurals breaking, as long as texture maps are coming through ok, although hopefully with the rumored nHair in 2013, more dev time has been spent on the shading parameters of hairsystems ![]()
--T
Trey, would it be possible to modify the MEL script you posted to generate mattes for the native Shave material, or would it only work with vrayHairMtl3?
That MEL script I created only works with ShaveNodes… it’s been testing with native Shave shading.
I haven’t tested it with a Hair3 override on Shave, but in that case, I assume you could just do a material ID on the Hair3 mat, yeah?
--T
Doh! Yes, you’re exactly right. Cool, thanks.
Can you elaborate on how to set this up? In particular I’m confused about how to hook up “hairsampler” here. Thanks!
Is there a way to have hair not be part of the GI calculation? (I am aware of the “opaque GI” option)
Yes, and there are several options. One is to apply V-Ray object properties to the hair system and turn off either the “Generate GI” option, or the “Visible to GI” option. The other is to wrap the hair shader in a VRayWrapperMtl material and turn off the “Generate GI” option.
Best regards,
Vlado
Thanks. Is it also possible to have different render settings for the hair? For example rendering everything else with DMC max samples set to 25 and primary GI set to brute force, but the hair set to 4 max samples and GI set to photon map?
The vrayMtlHair3 shader does not have an option for adding a material ID (or any other vray attributes). Is there any way to get it to work with a multi-matte pass?
The way I’ve been doing this is by adding an object property to the hairsystem & pfx preview, and giving that an object ID for a multimatte.
We are using Shave for the hair, so that unfortunately will not work.
Yeah, you’re right. Have you tried my shave multimatte generator script from the other hair thread? I haven’t tested it with hair3, but it should still work.
I would like official materialID support in hair3, though. It doesn’t even work if you pass it through a bumpmtl and add the materialID there (my usual workaround).
--T
For regular Maya hair, you can add the V-Ray object properties to the hair system and use the object ID along with the multimatte element. Of course we still have to fix the material ID for the hair 3 material.
I see it’s already been posted ![]()
Best regards,
Vlado

