Studio Light HDR images

Posted by on Jun 8, 2010 in code, lighting, MEL, photography, rendering | 14 Comments

Studio Light HDR images, photographed from real studio lights. Download the images below – and PyMEL scripts to automatically attach them to a lighting rig.

These HDRIs can be used as image based lights and reflection cards.

Soft Box

Get the soft box HDR. 1 MB

Umbrella Light

Get the umbrella light HDR. 8 MB

 

Newly revised PyMEL Scripts


Recently updated the light rig scripts here with PyMEL. These should work better for people using later versions of Maya. Please comment or contact me if you have any problems with these scripts. You can locate the old MEL scripts here.

Get a PyMEL(Python) script that will rig the Soft Box HDR to a reflection card with spotlight, shadows, and other controls. Note: for this script to work properly, you will need to download the soft box HDR folder and place it in your Maya project’s sourceimages directory. XPM icon for shelf item.

Get a PyMEL(Python) script that will rig the Umbrella HDR to a reflection card with spotlight, shadows, and other controls. Note: for this script to work properly, you will need to download the umbrella HDR folder and place it in your Maya project’s sourceimages directory. XPM icon for shelf item.

Installation tip: Make sure that the HDR images are placed in the currently set Maya project. These images should also be within their respective folder just as they are when you download them. The folder containing the HDR images should therefore be named either “softBox” or “umbrellaLight”, depending on which one you downloaded.

Usage tip: Select the locator on the rig, called “softBoxLightControl”, to find attributes to control Color, Shadows, and light Intensity.

note: The easiest way to position the light, without affecting the “roll” orientation of the reflector card, is to position (translate) the locator in one plane (ex: the X Y plane) to set the distance from the subject and light angle, then rotate the top node (pick-walk up once) in the Y axis to set the “horizontal” orientation.

If you are using another 3D animation package, download an OBJ, with UVs set up to use with the Umbrella HDR.

Also see my procedural softbox MEL script here. My most useful script, IMO.

Many thanks to Daniel Vasquez of heylight.com for translating the MEL script into PyMEL.

Also please check out my iOS apps.

Softbox Light MEL Script

Posted by on Jun 7, 2010 in code, lighting, MEL, rendering | One Comment

This PyMEL (Python) script creates a rigged light and procedurally textured reflector card, simulating a studio style soft box light. The rig is intended to be used for reflection or IBL when rendering using Mental Ray in Maya.

Usage tip: Select the locator on the rig, called “softBoxLightControl”, to find attributes to control Color, Shadows, and light Intensity.

note: The easiest way to position the light, without affecting the “roll” orientation of the reflector card, is to position (translate) the locator in one plane (ex: the X Y plane) to set the distance from the subject and light angle, then rotate the top node (pick-walk up once) in the Y axis to set the “horizontal” orientation.

XPM icon for shelf item.

If you prefer, you can download the older MEL version of this script here.

Maya duplicate and move by frame

Posted by on May 23, 2010 in code, Maya, MEL | No Comments

Duplicate and move based on the frame number. This MEL script will duplicate your object once per frame (set up to be 0 – 30 in this script) and move it to a position based on the frame number (this script: 0 – 30, 0, 0).

Usage: select your object and run script.

string $myObj[] = `ls -sl`; for( $index = 0; $index <= 30; $index++ ) { currentTime $index; select $myObj[0]; duplicate; move -a $index 0 0 ; }

Possible uses: This can help if you have an animated object and you want to save the position at each frame as a separate piece of geometry.

using Maya setRange to control incandescence

Posted by on May 20, 2010 in code, Maya, MEL, rendering | No Comments

setRange is a utility node that allows you to take values in one range, and map them into another range. Here is an example of setRange being used to remap the value of the translateY attribute to new values that control the incandescence of a shader.

This MEL script will create and attach a shader to selected objects, which links the translateY value of a Maya object to the incandescence of the shader.

The setRange utility is placed in between to control the output value range going into the shader. In this case, if the object’s translateY value is 10 the output will be 2, 1.25, 2, which produces a bright magenta color, if used as RGB values.

Using Maya hsvToRgb to cycle through the color spectrum

Posted by on May 20, 2010 in code, Maya, MEL, rendering, tips | No Comments

HSV to RGB is a utility node that allows you to convert an HSV (Hue-Saturation-Value) color into an RGB (Red-Green-Blue) color.

.inHsvR ranges from 0 to 360, representing degrees of a circle. We can use this to animate a shader to run through all the rainbow colors.

This MEL script will create and assign this shader network to selected objects.

Create Maya shaders that react to key frames

Posted by on May 16, 2010 in code, how to, Maya, MEL, rendering | No Comments

This MEL script was written specifically to automatically generate shaders for the equalizer in the animation below.

The script is set up to generate and assign shaders and attach the .translateY attribute of selected objects to the incandescence of the newly generated shader. Also creates a network that cycles the colors a bit at the same time.

Here is a snapshot of the network:

Get the script.

Importing keyframe data to Maya

Posted by on May 16, 2010 in code, how to, Maya, MEL, python | One Comment

Use this python script to import keys to a single channel of each node in a group of selected objects. This setup, below, will import properly formatted keys to the .translateY attribute of selected objects.

This script will apply unique keys to each selected node if there is a corresponding number of data files in the source directory.

import os
import maya.cmds as mc
## add path to keyframe data files - just the source directory that contains them.
rootdir='/path/to/keys'
## "ty", in line 13, refers to the Maya attribute channel of the selected objects. Modify this attribute as necessary.
objs= mc.ls(sl=True)
for subdir, dirs, files in os.walk(rootdir):
    for thisFile, o in zip(files, objs):
        file = open((os.path.join(rootdir, thisFile)), 'r')
        lines = file.readlines()
        file.close()
        for i in range(len(lines)):
            mc.setKeyframe(o, at='ty', v=float(lines[i]), t=i, itt='linear', ott='linear')

See a sample of properly formatted keyframe data :
http://oliverwolfson.com/scripts/keyFrameData.txt

Also see http://oliverwolfson.com/extracting-raw-key-frame-data/

NEW! The script below will do the same as the script above, import After Effects Sound Keys keyframes, from .txt files, to Maya, but it will also take care of the formatting, so there is no need to run a shell script on your After Effects keyframes before importing.

This script will apply unique keys to each selected node if there is a corresponding number of data files in the source directory.

##AE Import
import os
import maya.cmds as mc
## add path to keyframe data files - just the source directory that contains them.
rootdir='/Volumes/500GB/Work/Code/python/AEkeysImport/soundkeys'
## below is the attribute that you want to keyframe
theAttribute = 'translateY'
count = 0
objs= mc.ls(sl=True)
for subdir, dirs, files in os.walk(rootdir):
	dataFiles = [each for each in files if each.endswith('.txt')]
	for thisFile, o in zip(dataFiles, objs):
		theName = objs[count]
		count +=1
		dataFile = open((os.path.join(rootdir, thisFile)), 'r')
		lines = dataFile.readlines()
		dataFile.close()
		mylines = lines[10:-4]
		for eachLine in mylines:
			data = eachLine.split('\t')
			theFrame = data[1]
			theValue = data[2]
			mc.setKeyframe( o, v=float(theValue), at=theAttribute, t =float(theFrame))

Note: When pasting the keys from After Effects, be sure to use a code text editor like BB Edit or Text Wrangler. These apps will save your .txt files with UNIX line returns which is necessary to make this script work properly.

Technically the line breaks are invisible, but using the ‘tr’ command, in a UNIX shell, you could display them as any character you like, eg:

cat /path/some/file.txt | tr '\n' 'U'

In the above example, if the input file uses UNIX style line returns, \n ,each line will have a U at the end.

MEL tip: size

Posted by on May 16, 2010 in code, Maya, MEL, tips | No Comments

Print the size of a selection (ie the number of nodes in a selection):

print (size(`ls -sl`));

Maya noise expressions

Posted by on May 13, 2010 in code, Maya, MEL | No Comments
//sin wave between -1 and 1 myObject.translateX = sin(time); //noise returns a random number from -1 to 1 myObject.translateX = noise(time); //faster, stronger noise myObject.translateX = noise(time*10)*10; //noise and sin with double amplitude and time offset. myObject.translateX = 2*noise(time-10); myObject.translateY = 2*noise(time*3 -5); //frame with multiple myObject.translateY = noise(frame * 5); //Return absolute value myObject.translateY = abs(noise(frame * 5));
Load More