""" //////////////////////////////////////////////////////// // //Softbox HDR Light. v Alpha B //Written in MEL By Oliver Wolfson // //email oliverwolfson@gmail.com // //http://oliverwolfson.com/studio-light-hdr-images/ // //This script creates a rigged light and a HDR textured reflector card, simulating a studio style Softbox light. //The rig is intended to be used for reflection or IBL when rendering using Mental Ray in Maya. // // // //////////////////////////////////////////////////////// Translated to PyMEL by Daniel Vasquez (heylight.com) """ if 'pm' not in dir(): import pymel.core as pm #//Create softbox mySoftboxTMP = pm.polyPlane(ch=True, o=True, sw=1, sh=1, cuv=2)[0] mySoftboxTMP.scaleBy([5,5,5]) mySoftboxTMP.setRotation([90,0,0]) mySoftboxTMP.setTranslation([0,10,0]) pm.makeIdentity(apply=True, t=1, r=1, s=1, n=0) mySoftboxTMP.castsShadows.set(False) mySoftboxTMP.primaryVisibility.set(False) mySoftboxTMP.receiveShadows.set(False) mySoftboxTMP.motionBlur.set(False) mySoftboxTMP.smoothShading.set(False) #//Create and assign shader myLambert = pm.shadingNode('lambert', asShader = True, name='softboxShader') myShader = pm.sets(renderable=True, noSurfaceShader=True, empty=True, name='sofboxLambert2SG') myLambert.outColor >> myShader.surfaceShader myLambert.color.set([0,0,0]) myTex = pm.shadingNode('file', asTexture=True, name = 'softboxColor') myTex.outColor >> myLambert.incandescence #// Make sure that the path below matches path to your HDR image. myTex.fileTextureName.set('sourceimages/softBox/softBoxImage01.hdr') myTex2 = pm.shadingNode('file', asTexture=True, name= 'softboxTransp') myTex2.outTransparency >> myLambert.transparency #// Make sure that the path below matches path to your mask image. myTex2.fileTextureName.set('sourceimages/softBox/softBoxMask01.tif') pm.select(mySoftboxTMP) pm.hyperShade(assign = myLambert) #//create intensity ramp fileNode2 = pm.shadingNode('ramp', asTexture = True, name = 'softboxGain') fileNode2.outColor >> myTex.colorGain pm.removeMultiInstance(fileNode2.colorEntryList[1],b=True) pm.removeMultiInstance(fileNode2.colorEntryList[2],b=True) fileNode2.colorEntryList[0].color.set([1,1,1]) #// create Mult Divide multDivide2 = pm.shadingNode('multiplyDivide', asUtility = True, name = 'softboxOutColor2Input') fileNode2.outColor >> multDivide2.input1 #setAttr ($myMultDevide2 + ".input2X") 100; multDivide2.input2X.set(100) #setAttr ($myMultDevide2 + ".input2Y") 100; multDivide2.input2Y.set(100) #setAttr ($myMultDevide2 + ".input2Z") 100; multDivide2.input2Z.set(100) #//Create Spot Light mySoftboxSpotLight = pm.spotLight() mySoftboxSpotLight.getParent().setTranslation([0,10,0]) mySoftboxSpotLight.getParent().setRotation([180,0,0]) mySoftboxSpotLight.emitSpecular.set(0) mySoftboxSpotLight.coneAngle.set(105) mySoftboxSpotLight.penumbraAngle.set(10) mySoftboxSpotLight.dropoff.set(6) mySoftboxSpotLight.useRayTraceShadows.set(1) mySoftboxSpotLight.lightRadius.set(3) mySoftboxSpotLight.shadowRays.set(20) mySoftboxSpotLight.intensity.set(1) mySoftboxSpotLight.decayRate.set(2) multDivide2.outputX >> mySoftboxSpotLight.intensity mySoftboxSpotLight.areaLight.set(1) mySoftboxSpotLight.getParent().setParent(mySoftboxTMP) mySoftboxTMP.rotateBy([90,0,0], space='world') pm.makeIdentity(apply=True, t=1, r=1, s=1, n=0) #//create Arrow pointer and Locator arrw = pm.curve(d=1, p= [(0, 9, -1),(0, 9, 1),(0, 2, 1),(0, 2, 2),(0, 0, 0),(0, 2, -2),(0, 2, -1),(0, 9, -1)], k = range(8), name = 'softboxARROW' ) arrw.setScale([0.3,0.3,0.3]) LocatorTMP = pm.spaceLocator(p=[0,0,0]) LocatorTMP.translateY.set(10) LocatorTMP.setScale([4,4,4]) LocatorTMP.scaleX.setKeyable(False) LocatorTMP.scaleY.setKeyable(False) LocatorTMP.scaleZ.setKeyable(False) #//Aim and orient constrain pm.select(arrw) pm.select(LocatorTMP, tgl=True) pm.aimConstraint (offset=(0, 0, 0), weight=1, aimVector=(0, -1, 0), upVector=(0, 1, 0), worldUpType="vector", worldUpVector=(0, 1, 0)) pm.select(LocatorTMP) pm.select(arrw, tgl=True) pm.orientConstraint(offset=(0,0,0), weight=1) #//create color attributes for the locator LocatorTMP.addAttr('color', uac=True, at='float3') LocatorTMP.addAttr('red', at='float', parent='color',dv=1) LocatorTMP.addAttr('green', at='float', parent='color',dv=1) LocatorTMP.addAttr('blue', at='float', parent='color',dv=1) LocatorTMP.addAttr('rayTracedShadows', at='bool') LocatorTMP.rayTracedShadows.setKeyable(True) LocatorTMP.addAttr('intensity', at='double', min=0, dv=1) LocatorTMP.intensity.setKeyable(True) LocatorTMP.color >> fileNode2.colorEntryList[0].color LocatorTMP.color >> mySoftboxSpotLight.color LocatorTMP.blue.setKeyable(True) LocatorTMP.green.setKeyable(True) LocatorTMP.red.setKeyable(True) multDiv = pm.shadingNode('multiplyDivide', asUtility = True, name = 'softboxIntensity2Input') LocatorTMP.intensity >> multDiv.input1X LocatorTMP.intensity >> multDiv.input1Y LocatorTMP.intensity >> multDiv.input1Z multDiv.output >> fileNode2.colorGain #//connect Shadow attributes LocatorTMP.rayTracedShadows.set(0) LocatorTMP.rayTracedShadows >> mySoftboxSpotLight.useRayTraceShadows #//Rename and group mySoftboxTMP.setParent(LocatorTMP) mySoftboxTMP.rename('softBox') LocatorTMP.rename('softBoxControl') arrw.rename('softboxARROW') mySoftboxSpotLight.rename('sofBoxSpot') softboxLightGRP = pm.group(LocatorTMP, arrw, name = "softboxLightGroup") softboxLightGRP.setPivots((0,0,0), os=True)