P5 Material Editor: Irridescent Lizard Scales
                                                                                                              by Bloodsong

   This is for Oneth's Draanig character, Ki-San.  The Draanig are small draconian lizard people, but their skin changes colour with their emotions (yeah, 'mood lizards'!).  Ki-San is normally a forest green with darker stripe pattern on his back and flanks.  However, he shades to different colours depending on his mood.  Currently, Ki-San is in a very depressive environment, so he is mostly black, indicating sadness.  Sometimes when he gets angry, his throat and belly flush crimson.  Also, the Draanig have been hunted for their beautiful irridescent, colour-changing skin.

    Now instead of painting different texture maps for each mood or mood-combo (like the black and red for the ticked-off Draanig), the colours can be controlled in the P5 mixer.  "Now how can we do that?" you say?  Read on....


Step One: Material Analysis

     It may help you to draw a chart for the different effects you want going on.  And breaking down the components will help you figure out what type of nodes you'll need.

Ki-San's skin is...

  1. scaly lizard skin
  2. irridescent
  3. changes colour
  4. has darker stripes
  5. can mix colours in the belly/throat/jaw area

   Ki-San is also made out of the P4 raptor, in case we need some texture maps.  Now the dark stripes and the belly area can be handled by mixing colours with the blender.  The blender type of node uses an alpha channel to mix two colours.  The alpha channel can be a mathematical thing, or a greyscale image.  So, we painted a stripe map: black stripes on white where the stripe colours go on the UV map, and a separate belly map that blacks in the underbelly and creeps up into the main body.  Other than these maps, the whole texture is driven by basically one cellular node.

Step Two: Irridescence

     Out of our brilliant analysis... I rather stumbled upon this by accident.  But here we go.  Irridescence is a sorta rainbow sparkly highlight on things, right?  You can get rainbow dots out of a cellular node.  In the material editor, select Nodes: New Node: 3D Textures: Cellular.  Check the checkbox that says Random Colour.  Ta-da!  A buncha random coloured cells.  You can ignore the colour1/2 settings and all that.  Look at the Mode settings, and try out each mode.  One has dark edges, one has dark centers, etc.  I'm using Mode 4 on my irridescence. (Er, make sure you open the preview picture area on this node!)  The scale is pretty huge, so try a small fractional number.  I'm using .02 to make the colour dots very teeny tiny.  I've also set the jitter to -1.  Why?  I dunno, it looked good that way.  Also, I'm turning on the "Global" texture setting.  What's that do?  With this turned on, the texture stays still, and your model 'swims' through it, basically.  Imagine a stained glass window, casting a coloured pattern on the floor.  If you walk through the light, you get the pattern shining on your skin, but the pattern stays still as you move.  This is unwanted in most cases, but I turned it on for the irridescence, so that every time the figure moves, the shiny bits change and flicker.
     Go ahead and plug this node into the Specular Colour jack of the main node.  If you have the material preview picture open, you can see it updated as you make each change.  You may not see much if the highlight colour is too dim.  Try a 25% or so grey.  I've also cranked the specular value up to 2.  This is basically a strength setting, and I want those sparkly rainbow dots to really shine brightly.  Also, I've made the highlight size .05, because I really want a lot of irridescence.  (See the last illustration below for the main node settings.)

     Once you have the irridescence irradiating (?) the way you want it, you can save your material as an Irridescence base to work with later.  Also, you can close up the preview and data area of the cellular node, since we're done with it.

Step Three: Lizard Skin

     We're going to use another cellular node for the scaly skin.  So do the Node: New Node: 3D Textures: Cellular.  If you recall Mode 1 settings, there's a dark outline around a lighter value ramp.  Or, basically, a bunch of organic-shaped cells that shade from colour 1 in the center to colour 2 at the outer edges.  For a plain lizard scale skin, we could make the center colour green or what-have-you, but for this shader, we're going to leave it greyscale.  We'll be selecting colours for the skin in the blender module, which we'll get to in a bit.

     First, we need to tweak the cells into something lizard-skin looking.  Play with the Jitter and Turbulence settings to make the scales less square.  I've gotten a nice balance with settings of .75 and .4.

     You can see I changed the black colour for a dark grey.  I did this while working, because the colour scales had too dark of an edge.  This greyscale pattern is going to multiply with our scale colour, so this darkness will have an effect.  I made the scale .3, because this size looks good on the raptor model.  Notice that the scale of these scales is at least 10 times that of the irridescent cellular cells.  Remember, the sparkly colours are tiny dots on the scales, so don't make the two cellular nodes the same size.

     Now this one cellular node is going to drive our stripe texture colour, our body colour texture, and the belly scales.  Oh, and since it is a handy greyscale, let's plug it into the bump map, as well.  Dang, we're good!  Keep an eye on how the bump renders, it may be too strong.  If so, turn down the Bump number (that's the strength).  I have this one at .45.

     Remember, you can't see the proceedural materials in the preview window.  You need to do a quick render to check up on them.

Step Four: Mixing it All Together

        Now for the tricky part.  We want to mix three colours: stripe, main skin colour, and belly skin.  But the blender only takes two inputs.  That means we'll have to stack blenders to get things going.  First, we'll mix the main skin and the belly skin into one conglomerate, and then we'll mix that with the stripes.

        The blender has two parts: first, the blender node (duh) and a 2D image map, which plugs into the blending jack.   Blender is under math and Image Map is under 2D Textures.
     Now, the top colour of the blender corresponds to the black areas, and the bottom colour to the white, and we painted the belly area black.  So, obviously, the top colour is for the belly skin and the bottom colour will be the main skin colour.  But, they are not just plain colours, they're going to be lizard scales.  It sounds complicated, but it really isn't.  Just plug the base lizard scale function into each of the colour jacks.  Yes, the same one we used for the bump.  There's just one more item we need to be aware of, and we're done with this segment of the material.  Besides the image map input for the blending, there is a number.  The default is .5, which blends the two colours in an even mix.  Even with the black and white map, this causes both colours to blend across the map and turn muddy.  Change this to 1, and the demarkation between colours will be crisp.

   Now that the first two colours are blended, we can mix them with the stripe colour.  This is just the same as the main/belly mix, it is one blender and one 2D image map that plugs into it.  The top colour corresponds to the black on the image map, so that is the stripe colour.  Remember, these are scales, too, so they also get that Cellular #2 plugged into the colour jack.  The bottom colour of this blend is white.  Why?  Because we don't want a colour there to mix with the incoming blend.  Plug the main/belly blender into this jack.  And yes, the blending for this is set to 1 to delineate the colours more strongly.

     Plug the stripe-main/belly blender into the Diffuse and Ambient colour, and we're all set.  Take a moment to decipher the material diagram, here.

Cellular (yellow wire):
this is the random colour mix, plugged into the highlight jack of the main shader.
Blender (blue wire):
this is the Stripe blend, plugged into the diffuse and ambient jacks.
Image Map (blue wire):
this is the stripe map alpha channel, plugged into the Stripe Blender.
Image Map 2 (purple wire):
this is the belly map alpha channel, plugged into the Main/Belly Blender.
Cellular 2 (green wires):
this is the main greyscale cellular function, plugged into the bump map, the belly colour, the main body colour, and the stripe colour.
Blender 2 (magenta wire)
this is the Main/Belly blend, plugged into the Stripe Blender.

(Note: I over-reduced the colour in the above image, so the shades are not quite accurate.  Experiment with your own mixes.)

Here's the raptor with an tiger-stripe colour scheme.