Friday 24 August 2018

UVs for a ribbon/pipe

1) Use the Unitize function to separate each face in the mesh and have them squarely fill the 0-1 UV space. 2) Select the edges where you want your seam. 3) Convert the selection to UV's. 4) Invert the selection. 5) Use the Move and Sew function. 6) Go in the option box for Unfold and select Vertical as your unfold constraint (horizontal if your UV's are oriented that way. 7) Enjoy your nice UV's.


https://www.youtube.com/watch?v=dahgVetfUZg

Saturday 28 July 2018

simple sticky lips

http://www.kimonmatara.com/maya-easy-sticky-lips/
To begin, create two curves that will follow the contours of the upper and lower lips respectively as your rigged geometry deforms. These will be your ‘driver’ curves. There are various ways of doing this; in the example below, I merely drew the curves using snapping, and then wrapped them onto the original rig geometry:
Next, create a dynamic ‘averaged curve’ between them. To do this, follow these steps:
  1. Grab the curves’ shapes and graph them up in the Node Editor (or Hypershade, as you prefer).
  2. Create an ‘avgCurves’ node (in the Node Editor, you can hit tab and start typing ‘avgCurve’; alternatively, you could just issue a ‘createNode avgCurves’ in the MEL command line)
  3. Plug the ‘worldSpace’ output attribute of each curve shape into the inputCurve1 and inputCurve2 inputs of the avgCurve node:
  1. Back in the Outliner, duplicate one of the curves. This will be your ‘sticky’ curve.
  2. Add this curve’s shape to the Node Editor graph.
  3. Plug the ‘outputCurve’ output of the avgCurves node into the ‘create’ input of the curve:
  1. Select the avgCurves node and switch off ‘Automatic Weight’.
The resulting curve should fall right between the two lips, as thus:
Next, make a live, deforming copy of your rigged geometry. To do this, select your rigged geometry and issue ‘polyDuplicateAndConnect’ in the MEL command line. This will be your ‘sticky lips’ mesh. (This step is necessary to prevent dependency graph cycle problems.)
Now set the the averaged curve you created earlier as a wire deformer for this mesh. If in doubt as to how to do this, consult Maya’s documentation on the ‘wire’ deformer.
The wire deformer will have generated a ‘BaseWire’ curve. Select this curve’s shape in the Outliner and graph it in the Node Editor. Add the ‘avgCurve’ node you created originally to the graph.
Once again, plug the ‘outputCurve’ output of the avgCurve into the ‘create’ input of the BaseWire curve. We are doing this to cancel-out the wire deformer’s effects:
Paint-out the wire deformer’s influence to a narrow area along the inner lip edges:
Set ‘scale[0]’ on the wire deformer to 0.0, turn up the ‘dropoffDistance’ attribute, and overdrive ‘envelope’ to 2.0. Play with these settings until you get a good-looking result kicking in at the right range of motion.
You should now have something like the image below. If you turn up the wire dropoff, you’ll be able to zip-up the whole mouth, from the edges inwards.
  • The effect is distance-based, so some modest keying will be required in animation.

Wednesday 18 April 2018

render layers in maya 2018

Render layers in 2018

Use groups in collections, this way you can easily swap out geo without having to update stuff each time someone changes something.

If a sub object needs changing, it could be worth putting that in a sub group too.

Use shader overrides rather than material overrides.

more UV crap

last post is a bit redundant in the age of UV-editing mode of Maya 2018, but with heavy meshes, the uv editor is dog slow.

polyEditUV -u 1 -v0 -scaleU 1.2 -scaleV 1;

Also this.

Monday 16 April 2018

scaling UV code, around the centre of selection instead of 0,0

Original code stolen from
http://polycount.com/discussion/172364/maya-mel-scale-uv-shells-locally-script-for-anyone-that-wants-it


//store uvs into array
float $uvvalues[] =`polyEditUV -q`;
int $selSize = `size ($uvvalues)`;

//split array into U and V
float $Uarray[];
float $Varray[];

//copy U and V arrays with values
for($u = 0; $u < $selSize; $u++) {
          $Uarray[size($Uarray)] = $uvvalues[$u]; 
          $u=$u+1;
}

for($v = 1; $v < $selSize; $v++) {
          $Varray[size($Varray)] = $uvvalues[$v]; 
          $v=$v+1;
}

//sort arrays by coords and get size of array
$Uarray = `sort $Uarray`;
$Varray = `sort $Varray`;
int $UarraySize = `size ($Uarray)`;

//get max values
float $maxNuU = $Uarray[$UarraySize-1];
float $maxNuV = $Varray[$UarraySize-1];

//get min values
float $minNuU = $Uarray[0];
float $minNuV = $Varray[0];

//calculate centre values
float $middleU = ($maxNuU + $minNuU)/2;
float $middleV = ($maxNuV + $minNuV)/2;

polyEditUV -pu $middleU -pv $middleV -su .2 -sv .2;

Monday 9 April 2018

some rapid rig specific scripts..sin waves on the leg/arm micro curves.

//used in Nike jelly legs

//CONTROLLER SETUP
//select controller for attributes to be added to, one by one. eg. left foot ctrl. then right.
string $footCtrl[]=`ls -sl`;

print $footCtrl[0];

//upper controls
addAttr -ln "o"  -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".o");
addAttr -ln "upper_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "upper_sinPhase"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_transY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_transZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoX"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];


//lower controls
addAttr -ln "oo"  -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oo");
addAttr -ln "lower_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "lower_sinPhase"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_transY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_transZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoX"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];

//upper offsets
addAttr -ln "ooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".ooo");
addAttr -ln "upper_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];

//lower offsets
addAttr -ln "oooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oooo");
addAttr -ln "lower_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];


___________________________________________________________________________
//CONNECT CONTROLLER TO THE MICRO CURVES
//select the micro curves, can select them all, set the leftLeg and rightLeg strings!

string $ctrlNameSel[]=`ls -sl`;
print $ctrlNameSel[0];
float $ctrlOffset=0;
float $ctrlAmp=1;
string $leftLeg="abc_lLegSwitchC";
string $rightLeg="abc_rLegSwitchC";
string $ctrlUse="none";
string $region="none";

//looping
for ($ctrl in $ctrlNameSel){
   
    if(`gmatch $ctrl "*1C*"`){
    //top Node, set offsetVal
    $ctrlOffset=0;
    $ctrlAmp=0.55;
   
    }
    else if(`gmatch $ctrl "*2C*"`){
    //middle Node, set offsetVal
    $ctrlOffset=1.65;
    $ctrlAmp=1;
    }
    else if (`gmatch $ctrl "*3C*"`){
    //bottom Node, set offsetVal
    $ctrlOffset=2.2;
    $ctrlAmp=0.4;
    }
   
    //WHICH PART
    if(`gmatch $ctrl "*_rLower*"`){
    $ctrlUse=$rightLeg;
    $region="lower"; 
    }
    else if(`gmatch $ctrl "*_rUpper*"`){
    $ctrlUse=$rightLeg;
    $region="upper";
    }
    if(`gmatch $ctrl "*_lLower*"`){
    $ctrlUse=$leftLeg;
    $region="lower"; 
    }
    else if(`gmatch $ctrl "*_lUpper*"`){
    $ctrlUse=$leftLeg;
    $region="upper";
    }
   
   
    select $ctrl;
   
   
    string $newGroup=`group -name ($ctrl+"_sinGrp")`;

    string $offsetVal="float $offset="+$ctrlOffset+";\n";
    string $ctrlAmpStr="float $amp="+$ctrlAmp+";\n";
    //translate
   
    //string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY;\n";
    string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY * "+$ctrlUse+"."+$region+"_amp;\n";
   
   
    string $sinTZVal=$newGroup+".translateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_z_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transZ * "+$ctrlUse+"."+$region+"_amp;\n";
   
    string $sinRXVal=$newGroup+".rotateX=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_xRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoX * "+$ctrlUse+"."+$region+"_amp;\n";
    string $sinRYVal=$newGroup+".rotateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_yRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoY * "+$ctrlUse+"."+$region+"_amp;\n";
    string $sinRZVal=$newGroup+".rotateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_zRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoZ * "+$ctrlUse+"."+$region+"_amp;\n";
   
    string $expressionVal=$offsetVal + $ctrlAmpStr +$sinTYVal + $sinTZVal + $sinRXVal +$sinRYVal + $sinRZVal;
   
//   lower_xRot_sinOffset
   
    expression -s $expressionVal;
    select -cl;
}

______________________________________________________________________________
//REMOVE ATTRIBUTES FROM CONTROLLER
//select the controller (one by one)
//sets things to zero first, then deletes them

string $footCtrl[]=`ls -sl`;

print $footCtrl[0];

//remove upper controls, set to 0
setAttr -lock false ($footCtrl[0]+".o");
deleteAttr -at "o";


setAttr ($footCtrl[0]+".upper_amp") 0;
deleteAttr -at "upper_amp";

deleteAttr -at "upper_sinPhase";
deleteAttr -at "upper_transY";
deleteAttr -at "upper_transZ"; 
deleteAttr -at "upper_rotoX";
deleteAttr -at "upper_rotoY";  
deleteAttr -at "upper_rotoZ";


//lower controls
setAttr -lock false ($footCtrl[0]+".oo");
deleteAttr -at "oo";

setAttr ($footCtrl[0]+".lower_amp") 0;
deleteAttr -at "lower_amp"; 
deleteAttr -at "lower_sinPhase";
deleteAttr -at "lower_transY"; 
deleteAttr -at "lower_transZ"; 
deleteAttr -at "lower_rotoX";
deleteAttr -at "lower_rotoY";
deleteAttr -at "lower_rotoZ";  

//upper offsets
setAttr -lock false ($footCtrl[0]+".ooo");
deleteAttr -at "ooo";
deleteAttr -at "upper_y_sinOffset";
deleteAttr -at "upper_z_sinOffset";
deleteAttr -at "upper_xRot_sinOffset"; 
deleteAttr -at "upper_yRot_sinOffset";
deleteAttr -at "upper_zRot_sinOffset";

//lower offsets
setAttr -lock false ($footCtrl[0]+".oooo");
deleteAttr -at "oooo";
deleteAttr -at "lower_y_sinOffset";
deleteAttr -at "lower_z_sinOffset"; 
deleteAttr -at "lower_xRot_sinOffset"; 
deleteAttr -at "lower_yRot_sinOffset";
deleteAttr -at "lower_zRot_sinOffset";

__________________________________________________________________________
//DELETE SIN GROUPS FROM THE RIG
//just run it, no need to select (deletes all sin groups though)

string $ctrlSelected[]=`ls  "*_sinGrp*"`;

for($group in $ctrlSelected){
    select $group;
    print ($group+"\n");
    ungroup;
     
}

Tuesday 13 March 2018

zbrush displacement map transfer etc.

Zbrush is still a pain. But a useful pain.
The situation is : Say you have a hi-res piece of geometry. You'd like to use a retopo'd low-res geo as a base mesh for subdivision and displacement. Mudbox doesn't really cut the mustard for this. And Maya's transfer map results are even more useless. Here's what you do.

  • Bring in your low-res UV'd geo to Zbrush. Turn it into a polytool so it sits in Zbrush's memory.
  • Now import your hi-res geo. It should replace everything in the scene
  • Go to the Subtool menu, select append and look for the polytool of the low-res geo you just created. Click it.
  • Hide the hi-res geo for the time being. 
  • In the Geometry menu, hit subdivide a bunch of times, to get enough hi-res detail. You probably don't need to go as high as the unoptimised hi-res geo.
  • Go back to the Subtool menu, show the hi-res geo again.
  • Click on the now-subdivided low-res geo and hit Project All. This is at the bottom of the Subtool menu.
  • Now your subdivided low-res geo should have taken on the detail from your hi-res geo.
  • Lower the subdivision level in the Geometry menu. Do the Project All again. Repeat for every lower level.
Now for the map generation bit

  • Set your low-res geo subdivision level to it's lowest setting. OR to whichever level you want to use as your base in Maya/Houdini/whatever.
  • In Z-Plugins, click Multimap Exporter and select the maps you'd like generating.
  • Make sure Flip V is ticked ON.
  • Make sure Smooth UVs is OFF.
  • Subdiv level should be at 1 or whichever level you've chosen.
  • For final map turn ON Adaptive.
  • Turn on 32bit EXR.
  • The rest is fine to leave as default. Scale should be 1. 
  • Click Export maps.
SHOULD WORK. DON'T HAVE MULTIPLE UV TILES. DON'T HAVE UV's ON THE EDGE OF A TILE. ZBRUSH IS STUPID AND WILL MESS UP YOUR BAKING.


Wednesday 31 January 2018

NUKE - create UV map

Paste this to make a flat UV map, for distortion/undistortion grids etc

set cut_paste_input [stack 0]
Expression {
expr0 (x+0.5)/(width)
expr1 (y+0.5)/(height)
name Expression1
selected true
}