it only works with "Global" geometry type and doesn't support render layer ("Global" geometry always use the render layer 1, whatever ID is selected)
EDIT: camera mapped feature is now fixed in V3 and last V2 plugin, but the script is still useful for advanced work.
So, here is a python script to project any Image or procedural texture from the current camera:
Edit: v 0.2 added more nodes for Octane scale factor and Maya units.
Edit: v 0.3 updated for recent octane plugin, indice of world space coordinate have changed from 0 to 1.
As usual to use the script, run it from a script editor python tab or from shelf button.
It create this network between current camera and all selected texture nodes:
The resulting projection is the same as the "camera mapped" feature, but works with any geometry types,
if for some reason you need to "bake" the projection,
just delete the decomposeMatrix and the multiplyDivide nodes.
- Code: Select all
# For any selected octane textures, this script creates a node network of the projection from the current camera.
# v 0.2 : added nodes for Octane scale factor and Maya units.
# v 0.3 : updated for recent octane plugin, indice of world space coordinate have changed from 0 to 1.
import maya.cmds as cmd
import maya.OpenMaya as om
import maya.OpenMayaUI as mui
nodes = cmd.ls(sl=True, type=cmd.listNodeTypes(cmd.getClassification("octaneImageTexture")))
if len(nodes)>0:
cmd.loadPlugin("matrixNodes", quiet=True)
view = mui.M3dView.active3dView()
cam = om.MDagPath()
view.getCamera(cam)
camShape = cam.fullPathName()
node_a = cmd.createNode("decomposeMatrix")
node_b = cmd.createNode("multiplyDivide")
node_c = cmd.createNode("multiplyDivide")
node_d = cmd.createNode("multiplyDivide")
node_g = cmd.createNode("multiplyDivide")
node_h = cmd.createNode("unitConversion")
cmd.setAttr(node_b+".operation", 2)
cmd.setAttr(node_c+".input2X", 12.7)
cmd.setAttr(node_d+".operation", 2)
cmd.connectAttr(camShape+".worldMatrix[0]", node_a+".inputMatrix")
cmd.connectAttr(camShape+".horizontalFilmAperture", node_b+".input1X")
cmd.connectAttr(camShape+".focalLength", node_b+".input2X")
cmd.connectAttr(node_b+".outputX", node_c+".input1X")
cmd.connectAttr(node_c+".outputX", node_d+".input1X")
cmd.connectAttr("defaultResolution.deviceAspectRatio", node_d+".input2X")
cmd.connectAttr(node_a+".outputTranslate", node_h+".input")
cmd.connectAttr(node_h+".output", node_g+".input1")
cmd.setAttr(node_h+".conversionFactor", 1, lock=True)
cmd.connectAttr("octaneSettings.ScaleFactor", node_g+".input2X")
cmd.connectAttr("octaneSettings.ScaleFactor", node_g+".input2Y")
cmd.connectAttr("octaneSettings.ScaleFactor", node_g+".input2Z")
for node in nodes:
node_e = cmd.createNode("octanePerspProjection")
node_f = cmd.createNode("octaneTransform3D")
cmd.connectAttr(node_e+".outProj", node+".Projection", f=True)
cmd.connectAttr(node_f+".outTransform", node_e+".Transform")
cmd.connectAttr(node_g+".output", node_f+".Translation")
cmd.connectAttr(node_a+".outputRotate", node_f+".Rotation")
cmd.connectAttr(node_c+".outputX", node_f+".ScaleX")
cmd.connectAttr(node_d+".outputX", node_f+".ScaleY")
cmd.setAttr(node_e+".PosType", 1)
cmd.setAttr(node_f+".ScaleZ", -1)
cmd.setAttr(node_f+".RotationOrder", 5)