Saturday, April 14, 2012

p_HairTK, p_HairTK_shadow, p_shader_replacer

These 3 custom mentalray shaders are part of an extensive shader collection written by Pavel Ledin (aka puppet). In this post I will show how you can use a geometry shader, p_shader_replacer, to assign the p_HairTK shader to maya fur when using mentalray with fur mode set to hair primitives. Doing this gives you much more control over the look of the fur and, depending on how you use it, may dramatically improve yoru render times.

First you need to download and install the latest version of "shaders_p" from puppet's web site. Currently its v3.3 beta 9, but it seems to be very stable. You will not see p_HairTK mentioned on puppet's download page, but it is included in the package.
Then you need to create a surface and add some fur. In my example I have used a torus called pTorus1.
Next you must create an instance of the three shaders: p_HairTK (Material), p_HairTK_shadow (Shadow Shader) and p_shader_replacer (Geometry Shader).
Geometry shaders, like p_shader_replacer, are actually less like shaders and more like plugins which enable access to features within mentalray that maya cant normally get to. You don't assign a geometry shader to a surface like you normally would. Instead you hook it onto a piece of geometry using a slot in the transform node. This host geometry can be a simple poly or nurbs surface. It will not be visible in a render. It's only purpose is to be a place to plug in the geometry shader.
If your fur is attached to a poly object, then the geometry shader host needs to be a poly object. And fur growing on a nurbs surface requires a nurbs host for the geometry shader.
So if you follow my example and attach fur to a poly torus then you need to create a poly object to hold the geometry shader. This can be any poly shape, but keep it simple and just use a default cube.
Select the cube (transform node) and open the attribute editor. Drag-and-drop the p_shader_replacer into the geometry shader slot as shown here

Remember, the sole purpose of this cube is to hold the geometry shader. With the geometry shader connected the cube will not be visible in the render, but it must remain visible in the scene or the geometry shader will be ignored at render time.
When you created p_HairTK1, then a shading group called p_HairTK1SG was also created. Select the SG and use the attribute editor to hook up the p_HairTK_shadow as shown here

Now select the p_shader_replacer node and use the attribute editor to enter the names of the p_HairTK1SG and FurFeedback as shown here

Notice that you must enter the name of the shading group, not the material. And the name of the FurFeedback transform node, not the shape node. You can drag-and-drop the SG node, but you will need to actually type the name of the FurFeedback (or copy and paste).
Everything is now connected and ready to adjust the shading attributes and test render.
P_HairTK takes over the job of shading the fur, so it makes all of maya's native fur color attributes redundant. Here is a snapshot of the maya FurDescription attributes (I used the raccoon preset and made it pink)

When p_HairTK is hooked up all of the color and opacity attributes in maya's FurDescription are ignored. Shading is then controlled using the p_HairTK attributes. They are extensive as you can see here.

The p_HairTK attributes shown above are default settings, with colors changed to match the pink raccoon shades and the Use Ambient flag disabled.
I have also left the p_HairTK_shadow attributes as default

As you can see, p_HairTK dramatically increases the control you have over fur shading.
I'll finish off with some render comparisons. I've used a single spot light with a mentalray physicalLight/mib_blackbody. I've enabled finalGather and connected mia_exposure_photographic as a lens shader.
The first image is maya's native FurDescription. It took 2 min 34 sec on my q9550.

Next is p_HairTK/p_HairTK_shadow with Transparency disabled. It took 30 secs.

And then again with Transparency enabled with values matching those in the FurDescription . This took 1 min 4 secs.

Of course I could adjust attributes and make nicer pictures, but the intention of these renders was to quickly compare default settings.
I like the considerable speed up I get with p_HairTK. I also like the extra control it gives me. I've barely scratched the surface in this quick example but I hope I've given you a taste of what's possible with puppet's p_HairTK.

1 comment: