crosshatch shading

By Duncan Brinsmead - 17 Dec, 2008

One can construct crosshatch shaders in Maya without needing any special plugins. The key trick is to use a shader in a shading network as if it were a texture. One can use the outColor of a shader(not assigned to any object) to control the linewidth or other attributes of a procedural texture that is in turn assigned to an objects shader. The attached scenefiles demonstrate some hatching techniques and can be loaded into Maya8.5 or later versions.

The example above is the scene which uses a blinn shader to control the thickness of lines for a grid texture. The left version uses a 2D grid texture and the right a projected grid texture using the concentric projection method. To setup such a shader first assign a surface shader to your object( the surface shader is a "do nothing" shader that simply has outColor and outTransparency attributes that can be connected to the shading engine) and connect the outColor of a grid texture to the surfaceShader outColor. Make the grid line color black and the fill color white and increase the texture uv repeats until one has the desired line density on the surface. Now create a blinn shader (it does not need to have a shading network node) and a valueRemap shading utility node. We will use the valueRemap node to both reverse the brightness value from the blinn shader as well as to fine tune how the thickness changes with brightness. Connect the blinn outColorR to the remapValue inputValue. There is no need to turn color into luminance, as we don't really care about the light color or the blinn shader color in this case. Connect the remapValue outputValue to both the grid texture uWidth and vWidth. You should have the following shading network:

The shading will be reversed at this point, with lines thick where it is bright and thin where it is light. To reverse this simply edit the value ramp on the the remapValue node so that it is 1.0 at the left and zero at the right. You can also shape this ramp so that the lines get thinner faster.

At this point you should have a result similar to the image at the top left. The right images used the same basic process but with making the grid texture a concentric projection. Note that increasing the color or diffuse on the blinn shader will also make the shading brighter. As well one can texture the color of the blinn shader if desired and the effect of shadows and reflections will be properly captured in the line thickness. One can make the lines wiggle by smearing the uvs (perhaps with a fractal texture on the uvOffset of the grid placement node). As well one could layer different grid textures and control the mix based on distance to camera. The possible variations are endless.

To get a natural look one can create several hand drawn cross hatch textures, each with thicker and farther apart lines, then control the mix based on the surface brightness. For example the texture outColor might go to a remapValue node and then the outColor.R could control the position of a ramp indice to threshold the shaded value. The original crosshatch texture could be painted with a soft brush so that the lines become skinnier as one thresholds it. Under "Toon: Get Examples" there are examples that use a similar technique: inkCrosshatch, pencilShading, pencilScribble and streaked. These are all designed with animation in mind and animate some parameters to create a natural looking giggle. One generally needs to balance looking too 3D and mechnical with looking too noisy and busy.

For very specific cross hatch lines one can actually paint them on a surface with a paint effects brush, either painting each line or possibly creating a brush that paints a bunch of lines for each stroke. The thickness of paint effects lines can be controlled by light intensity: start with a default brush, turn on "illuminated" and "real lights", and make "lighting based width" = 1 then make your object paintable and paint lines on it( the object could simply have a solid white shader ). When you render the lines with be thinner where the surface faces towards the light. If the lines do not thin enough one can increase the light intensity. You will also probably want to select all the strokes and do "share one brush". Here is an example of this setup(attached scene

To speed up the scene refresh one can turn off displayAsMesh on all the stroke nodes, or perhaps also make paint effects interactive in the performance options. Note that if one wanted, one could construct several curves on the surface surface then do pfx: attach brush to curves. This might make it easier to build specific curve shapes. Instead of simply rendering simple strokes we can turn "tubes=ON" on the brush. The resulting tubes initially stick out from the surface, but they can be made to follow it by the following brush settings: tubeCompletion = OFF tubeSegments = 200 (or a relatively large value) pathFollow = 1.0 lengthFlex = 1.0 One can then also set the number of tubesPerStep as well as the startTubes along with the brush width. The tubeWidth1+2 will need to be set based on how close the various tubes are. In general one just wants them to exactly overlap where there is no light. Here is the scene, which has tubes = ON:

The scene has further modifications to make the lines a bit more curvy:

Here is an animation showing simple rotation of the torus with a depthmap shadowed spotlight. The paint effects lines will change width based on depthmap shadows, but not for raytraced shadows, however the grid texture technique does not have this limitation.

One can easily make the lines wiggly using various brush settings. Experiment with some of the parameters in the displacement block. It can be fun to play with the parameters and see what happens.
Posted By
Published In
To post a comment please login or register
alanter | 1 year ago
Hey! thanks a lot for this tutorial it was really easy to follow and incredibly helpful! I am just finishing up my 3d program at school, and have used Maya for the past 4 years, but recently started playing around with toon shading in cinema 4d and loved it, but it can be intimidating how much there is in maya technically to dive into. One of the biggest helps on the c4d side are the well documented free tutorials and blogs. Excited to start playing around more in my native program! I posted my first test replication of it up on vimeo and mentioned you down below, when I end up doing something else with it I will have to send it your way! Thanks again!
Edited by alanter 1 year ago
Faeyth | 3 years ago
Hi there. I'm looking for something like this but I primarily use 3ds Max. Is there any way to recreate this in max, without needing your base zip file? Or if you have a Max version kicking about that'd be handy too. Here's hoping you're still active on this blog =] Cheers.
Edited by Faeyth 3 years ago
John D Ebner | 3 years ago
ReVolotion option I am looking for a loop loft tool the creates a nurb curve from the centroid origin on a model, but the spline slides over top of a surface and has extra features to it seen one in any app yet? seen a mel script in maya of one yet? essentially it functions similarly in display to a cross section tool or how camera can be used to dolly image plane clipping plane in and out of a view ONLY that the clipping plane is the shell boundary of the polygon sub D or nurb curve surface.. the tool itself harnesses and has extra tools to it that uses the centroid origin of a model and it can automatically create a centroid origin SPLINE much like the time line points in animation only that if you imagine the origin to be the nerve center for how a spline is traced directionally over a surface then this will allow for much more robust resurfacing controls over a surface within maya Second if the model has limbs etc it can slide the centroid accordingly to any of the limb centroids. The tool then has the ability to create a loop spline which allows any artist to re-loft from a new set of clean isoparm splines that are NOT directionally dependent. to slide along a centroid which you can slide along its circumference the loop of a spline that is closed or OPEN and then tweak as you grow additional splines draping over top allows a modeler to resurface a model in mere seconds manually rather than hours.
Edited by John D Ebner 3 years ago
ileste | 4 years ago
Hello, I try to apply this technique to sketch. I have CAD Nurbs curve sketch and I want to look like a hand drawn like this, only the outlines I attached marker brush on curve make more start tubes, and make the tubes follow the curve, but I missing the randomness, scribble look. The all lines begin from same place and end on same place and they are very uniform I try curl, but they all curl in same direction, I want them to intersect. I want some tube do not follow non stop the curve, on some place yes on some place no Thanks in advance for all
Edited by ileste 4 years ago
duncan-brinsmead | 4 years ago
I think the ramp shader should be able to do what you are after. Look on the Maya Toon menu under fill:shaded brightness 2 tone. You can set the input to color on the ramp shader to light angle, or surface brightness. The surface brightness setting will handle cast shadows and such. There is also a separate control for shadows (under Shadow Control on the ramp shader node). In the visor (Toon:get example) you will find scenes with a variety of toon looks you can examine. Also read the Maya doc under "toon".
Edited by duncan-brinsmead 4 years ago
Pallino3d | 4 years ago
Hello Duncan, sorry if I open this discussion, but through the forum, unfortunately I had no luck, so I hope in you. I found this example of a shader made ??for Softimage I was wondering if it was possible to recreate the exact same thing in maya. To realize a toon shader, with the possibility of controlling the shadow through the paint's surface. If all this is possible, could you make a tutorial or explain which nodes use? Thanks in advance for all see you soon Paolo Ciao
Edited by Pallino3d 4 years ago
ReeverRayne | 5 years ago
Hi! The is dead. Can you help to re up so i can see the connection that you do for the paint shader. i am veritable curious on how you do it so beautifully. Please and thank you.
Edited by ReeverRayne 5 years ago
duncan-brinsmead | 6 years ago
The shading networks can get a bit involved but you can generally create networks that do anything you want in terms of the hatching. You could first define a texture defining the way you want the lines to appear... either a file texture or a procedural network of some sort( you might even start with photos of real etchings ). Then to control line width and such with lighting first blur the texture so you have a gradient of white to black. Then use the outColor brightness from any shader to threshold the texture( in a similar fashion to this tutorial ). For more subtle effects, like dropout of odd hatch lines at mid brightness you might need to use multiple textures and more complicated thresholding. For the fill colors you might use ramp shaders. There are a variety of ways the ramp shader can be textured and it is very flexible with how lighting affects its shading. Note that the color indices on the ramp shader can be textured and as well the position of the indices can also be textured. You might also find some of the MayaToon examples useful (Toon:GetToonExample).,,, and could give you some ideas.
Edited by duncan-brinsmead 6 years ago
John D Ebner | 6 years ago
hi duncan,... i need this in simple mels, or / & but also.... maybe the standards you will see in these links below is what I need on the model itself then baked?!!!??? Certainly,... have a close close look at whats going on - this could be a huge time saver inside maya as a bit more robust shader then to - paint to - template tool like etch and stamp n bake. I am going after a Nuremburg Chronicles Look - & Now this is a 500 Year Old Book! the First off the First Press Ever! So essential requirement: maya 3D engraved stippled halftone tutorial on this link shows the quality I need to achieve day to day for current work but I also want to achieve hand etched quality you see inside the Chronicle btw - this book was Latin then German and now is being moved into english
duncan-brinsmead | 8 years ago
Looks great! Duncan
danjay | 8 years ago
Check out this illustration I did using this technique:
Longboarder1 | 8 years ago
Awesome! I've been looking every day for an update.
duncan-brinsmead | 8 years ago
Yeah I know... I've been rather busy, as lame as that sounds. I'll try to post some more examples in the following week. Duncan
pixelmonk | 8 years ago
Wake up Duncan... you haven't posted anything new in your blog for awhile. ;)
milowerx | 8 years ago
Wow! That's amazing! I wonder what it would look like on a character?
Jozvex | 8 years ago
Very very cool! The amount of possibilties in Maya with regards to shading connections etc is so vast. It's good to have specific examples to remind you of it.
johnjoe | 8 years ago
wow, this is fantastic. Thanks Duncan
Longboarder1 | 8 years ago
Amazing what you can do! Thanks a lot!
jtk77 | 8 years ago
Wow, never knew. This is pretty ingenious working with whats already there.
Mohamed Almonajed | 8 years ago
Mr. Duncan you're my hero (I really mean it).
wow_anders | 8 years ago
He he, I really liked the idea of this. Paint effects rules!