maya sprites rendertest in rendeman

its a simple render test of maya sprites in arnold and renderman Studio. it uses a simple noise pattern on a 2d ramp with 2d ramp displacement. one simple noise plugged into a ramp can give a really complex shading behaviour. the extreme displacement come from a simple ramp, this give the smoke more depth.

 

maya sprite test from Heribert Raab on Vimeo.

Advertisements

maya tool: get speed from animated object live

i’ve wrote 2 handy tools in maya for getting a speed value from animated Objects.  it works on everything, which have a transform node. Locators, Geo etc…

this script add an extra attribute call Speed. its updates live, even when change keyframes. its very hand if you have to animate your force field based on speed /animation of other Objects. you can simply refer this attribude inside other expression.

this second script is pretty much the same, except it display the speed live in Maya’s HUB display. (inside a viewport)

when you activate the script again it will turn off the HUD display.

link to script

link to script 2

Python script:

import maya.cmds as cmds
import math

Psel = cmds.ls( selection=True )
try:

nodeT = cmds.nodeType( Psel[0] )
print nodeT
if nodeT == ‘transform’:
checkAttr = cmds.objExists(Psel[0]+’.speed’)
print checkAttr
if checkAttr == True:
listexpr = cmds.listConnections(Psel[0]+’.speed’)
if listexpr == None :
ex1 = ‘float $lastPosX = getAttr -t (frame-1) '+Psel[0]+'.tx;’
ex2 = ‘float $lastPosY = getAttr -t (frame-1) '+Psel[0]+'.ty;’
ex3 = ‘float $lastPosZ = getAttr -t (frame-1) '+Psel[0]+'.tz;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)
else:
cmds.delete(listexpr[0])
ex1 = ‘float $lastPosX = getAttr -t (frame-1) '+Psel[0]+'.tx;’
ex2 = ‘float $lastPosY = getAttr -t (frame-1) '+Psel[0]+'.ty;’
ex3 = ‘float $lastPosZ = getAttr -t (frame-1) '+Psel[0]+'.tz;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)

else:
print “test”
cmds.addAttr( Psel[0],longName=’speed’ )
ex1 = ‘float $lastPosX = getAttr -t (frame-1) '+Psel[0]+'.tx;’
ex2 = ‘float $lastPosY = getAttr -t (frame-1) '+Psel[0]+'.ty;’
ex3 = ‘float $lastPosZ = getAttr -t (frame-1) '+Psel[0]+'.tz;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
print exAll
cmds.expression( o=Psel[0], s=exAll)

else:
print ‘—> select transform !’

except TypeError :
print ‘—> select transform !’

 

 

 Script 2:


import maya.cmds as cmds
import math

def getSpeed(*args):

res = 0
Psel = cmds.ls( selection=True )
try:

nodeT = cmds.nodeType( Psel[0] )
print nodeT
if nodeT == ‘transform’:
checkAttr = cmds.objExists(Psel[0]+’.speed’)
print checkAttr
if checkAttr == True:
listexpr = cmds.listConnections(Psel[0]+’.speed’)
if listexpr == None :
ex1 = ‘float $lastPosX = getAttr -t (frame-1) '+Psel[0]+'.tx;’
ex2 = ‘float $lastPosY = getAttr -t (frame-1) '+Psel[0]+'.ty;’
ex3 = ‘float $lastPosZ = getAttr -t (frame-1) '+Psel[0]+'.tz;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateXA,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)
else:
cmds.delete(listexpr[0])
ex1 = ‘float $lastPosX = getAttr -t (frame-1) '+Psel[0]+'.tx;’
ex2 = ‘float $lastPosY = getAttr -t (frame-1) '+Psel[0]+'.ty;’
ex3 = ‘float $lastPosZ = getAttr -t (frame-1) '+Psel[0]+'.tz;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)

else:
print “test”
cmds.addAttr( Psel[0],longName=’speed’ )
ex1 = ‘float $lastPosX = getAttr -t (frame-1) '+Psel[0]+'.tx;’
ex2 = ‘float $lastPosY = getAttr -t (frame-1) '+Psel[0]+'.ty;’
ex3 = ‘float $lastPosZ = getAttr -t (frame-1) '+Psel[0]+'.tz;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
print exAll
cmds.expression( o=Psel[0], s=exAll)

else:
print ‘—> select transform !’

except TypeError :
print ‘—> select transform !’
res = cmds.getAttr(Psel[0]+’.speed’)
return res
try:
cmds.headsUpDisplay( ‘voxelsHUD’, section=1, block=0, blockSize=’small’, label=’Speed’, command=getSpeed, event=’timeChanged’, nodeChanges=’attributeChange’ )
except RuntimeError:
cmds.headsUpDisplay(‘voxelsHUD’, remove=True)

 

Maya Fluid alpha issue with Container Scale?

sometimes when you fluids container size is too big and you get wired alpha channel issues in mental ray like this:
container_alpha

there is an easy fix to this. just turn off “pass custom alpha channel” in custom entries option of the rendersettings. in some cases you should only overlapping fluids container in one render layer.

alphachannel

Maya Speed Attribute Python Script

this script add a speed attribute to the selected object and calculates it in realtime. Very handy for setup effects, animating vehicles etc.. github link

import maya.cmds as cmds
import math

Psel = cmds.ls( selection=True )
try:

nodeT = cmds.nodeType( Psel[0] )
print nodeT
if nodeT == ‘transform’:
checkAttr = cmds.objExists(Psel[0]+’.speed’)
print checkAttr
if checkAttr == True:
listexpr = cmds.listConnections(Psel[0]+’.speed’)
if listexpr == None :
ex1 = ‘float $lastPosX = `getAttr -t (frame-1) ‘+Psel[0]+’.tx`;’
ex2 = ‘float $lastPosY = `getAttr -t (frame-1) ‘+Psel[0]+’.ty`;’
ex3 = ‘float $lastPosZ = `getAttr -t (frame-1) ‘+Psel[0]+’.tz`;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)
else:
cmds.delete(listexpr[0])
ex1 = ‘float $lastPosX = `getAttr -t (frame-1) ‘+Psel[0]+’.tx`;’
ex2 = ‘float $lastPosY = `getAttr -t (frame-1) ‘+Psel[0]+’.ty`;’
ex3 = ‘float $lastPosZ = `getAttr -t (frame-1) ‘+Psel[0]+’.tz`;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)

else:
print “test”
cmds.addAttr( Psel[0],longName=’speed’ )
ex1 = ‘float $lastPosX = `getAttr -t (frame-1) ‘+Psel[0]+’.tx`;’
ex2 = ‘float $lastPosY = `getAttr -t (frame-1) ‘+Psel[0]+’.ty`;’
ex3 = ‘float $lastPosZ = `getAttr -t (frame-1) ‘+Psel[0]+’.tz`;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
print exAll
cmds.expression( o=Psel[0], s=exAll)

else:
print ‘—> select transform !’

except TypeError :
print ‘—> select transform !’

this script adds apeed attribute to selected object and display it in maya opengl view. When you select different object you have change the frame to get the update. gitbhub link

import maya.cmds as cmds
import math

def getSpeed(*args):

res = 0
Psel = cmds.ls( selection=True )
try:

nodeT = cmds.nodeType( Psel[0] )
print nodeT
if nodeT == ‘transform’:
checkAttr = cmds.objExists(Psel[0]+’.speed’)
print checkAttr
if checkAttr == True:
listexpr = cmds.listConnections(Psel[0]+’.speed’)
if listexpr == None :
ex1 = ‘float $lastPosX = `getAttr -t (frame-1) ‘+Psel[0]+’.tx`;’
ex2 = ‘float $lastPosY = `getAttr -t (frame-1) ‘+Psel[0]+’.ty`;’
ex3 = ‘float $lastPosZ = `getAttr -t (frame-1) ‘+Psel[0]+’.tz`;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)
else:
cmds.delete(listexpr[0])
ex1 = ‘float $lastPosX = `getAttr -t (frame-1) ‘+Psel[0]+’.tx`;’
ex2 = ‘float $lastPosY = `getAttr -t (frame-1) ‘+Psel[0]+’.ty`;’
ex3 = ‘float $lastPosZ = `getAttr -t (frame-1) ‘+Psel[0]+’.tz`;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
cmds.expression( o=Psel[0], s=exAll)

else:
print “test”
cmds.addAttr( Psel[0],longName=’speed’ )
ex1 = ‘float $lastPosX = `getAttr -t (frame-1) ‘+Psel[0]+’.tx`;’
ex2 = ‘float $lastPosY = `getAttr -t (frame-1) ‘+Psel[0]+’.ty`;’
ex3 = ‘float $lastPosZ = `getAttr -t (frame-1) ‘+Psel[0]+’.tz`;’
ex4 = Psel[0]+’.speed = abs (mag (<<‘+Psel[0]+’.translateX,’+Psel[0]+’.translateY,’+Psel[0]+’.translateZ>>)- mag (<<$lastPosX,$lastPosY,$lastPosZ>>) );’
exAll = ex1+ex2+ex3+ex4
print exAll
cmds.expression( o=Psel[0], s=exAll)

else:
print ‘—> select transform !’

except TypeError :
print ‘—> select transform !’
res = cmds.getAttr(Psel[0]+’.speed’)
return res
try:
cmds.headsUpDisplay( ‘SpeedHUD’, section=1, block=0, blockSize=’small’, label=’Speed’, command=getSpeed, event=’timeChanged’, nodeChanges=’attributeChange’ )
except RuntimeError:
cmds.headsUpDisplay(‘SpeedHUD’, remove=True)

 

maya tip: passing on deformed particle and geomtrie

nonlinear deformers or scuplting on geo/partilces are great to tweak your sims. but it will not written into the cache file. the deformation gets always added on top of the cache. this is little bumpy, example: if wanna use the deformed nParticle to emitt into a fluids container.
in this case, you can use the new node editor to plug the outGeometry of the deformer into you depending geo/nodes like the fluids emitters. easy !

Screenshot-1

Maya playblast tool2

here is an improved version of the playblast script. Jean Denis pointed out the playblasting of more cameras is sequential and parallel. (thanks for that!) which would extreme slow in heavy scene with complex characters or large cache file. the new version of the script capture all cameras on each frame at the same time.  this way, maya have evaluate once on each frame and not do extra evaluation for each camera.  this way you can playblast simulations with different camera without caching.

i am using the active viewport for each camera to keep resolution constant. (and it avoid maya viewport issues).

* just made a little update to free maya after player is showing up

** another update: i added 2 more botton’s for houdini “mplay” tool. if you have houdini installed (even the demo version) it will bring up a mplay app and play until 4 cameras simultaneity in one window. (row or quas view)
tip: with shortcut “s” you link all view together and zoom synchronously

*** you use rv tile option (menu tools–>tile) to view all cameras side by side. i set it to default in the script

**** bugfix with timerange

Screenshot
download it here

// written ny Heribert Raab heribertraab@gmail.com
// the tool create outliner with contain just cameras
// clicking on each camera switches through camera on your active viewport
// playblast botton will playblast all selected camera with aktiv viewport and load them into fcheck or rv

global proc playB(string $player)
{
string $select[] = `ls -sl`;

// setup playblast dir
//string $path = “/tmp/test/”;
string $frames2[] ;
string $fl[] = `renderSettings -firstImageName -fullPathTemp`;
string $f2[] = `renderSettings -firstImageName`;
string $path = substituteAllString($fl[0], $f2[0], “”);
int $min = `playbackOptions -q -minTime`;
int $max = `playbackOptions -q -maxTime`;
int $fr = $max – $min;

int $f;
string $all;
string $play;
string $scene = `file -q -sn -shn`;
string $scname = substituteAllString($scene, “.”, “_”);

for ($f=$min;$f <$max;$f++)
{
// playblast selected Cameras
$numInts = size($select);
$ridNum = $numInts +1;
int $i=0;
string $seq[];

for ($i=0;$i < $numInts; $i++)
{
lookThru ($select[$i]);
$frames2[$i] = $path+$scname+”_”+$select[$i];
//print ($frames2[$i]+”.”+$f+”\n”);
playblast -st $f -et $f -forceOverwrite -format image -fp 4 -compression “jpg” -f($frames2[$i]) -viewer 0 -offScreen -percent 100 -quality 70;
}
}
$all = stringArrayToString($frames2, “.* “);

//image player command
$play = ($player+” “+$all+”*”);

if ($player ==”mplay”) $play= ($player+” -V 2 2 -g “+$all+”* &”);
if ($player ==”mplay2″) $play= (“mplay -V 4 1 -g “+$all+”* &”);
if ($player ==”rv”) $play_rv = ($player+” -tile “+$all+”* &”);
if ($player ==”fcheck”) {$play = ($player+” -S “+$all+”* &”);}

print $play;print “\n”;
system( $play );
}

global proc look(){lookThru `ls -sl`;}

string $filterP = `itemFilter -byType camera `;

window cameras;
frameLayout -labelVisible false ;
string $panel = `outlinerPanel`;
columnLayout -adjustableColumn true;
button -label “Playblast selected Cams with RV” -command “playB rv”;
button -label “Playblast selected Cams with Fcheck” -command “playB fcheck”;
button -label “Playblast selected Cams with mPlay quad” -command “playB mplay”;
button -label “Playblast selected Cams with mPlay row” -command “playB mplay2”;

string $outliner = `outlinerPanel -query -outlinerEditor $panel`;
outlinerEditor -edit
-mainListConnection “worldList”
-selectionConnection “modelList”
-f $filterP
-selectCommand look
-showSetMembers true
-setFilter defaultSetFilter
$outliner;
showWindow;