Archive for the ‘R&D’ Category

Environment light in Nuke

Friday, March 6th, 2009

Here’s a python script that translates Lighting Coefficients from the paper by Ravi Ramamoorthi to a expression node. Connect a normal pass to the expression node.

import nuke
import string

def LCoeff2Nuke():
	p = nuke.Panel("Paste Lighting Coefficients")
	p.addMultilineTextInput("Coefficients:", '')
	p.addButton("Cancel")
	p.addButton("OK")
	p.show()

	coeffVal= p.value("Coefficients:")

	#CONSTANTS
	c1 = '0.429043'
	c2 = '0.511664'
	c3 = '0.743125'
	c4 = '0.886227'
	c5 = '0.247708'

	Coefficients =[]

	i=0
	for line in coeffVal.split('\n'):
		if line.startswith('L_'):
			Coefficients.append(line.split()[1:4])
			print line
			i+=1

	expTemplate = 'c1*L22*(pow2(r)-pow2(g)) + (c3*L20*pow2(b)) + c4*L00-(c5*-L20) + 2*c1*((L2m2*r*g)+(L21*r*b)+(L2m1*g*b)) + 2*c2*((L11*r)+(L1m1*g) + (L10*b))'

	expressions = ['','','']
	for i in range(3):
		expressions[i] = expTemplate
		expressions[i] = expressions[i].replace('c1', c1) 	#
		expressions[i] = expressions[i].replace('c2', c2) 	#
		expressions[i] = expressions[i].replace('c3', c3) 	#
		expressions[i] = expressions[i].replace('c4', c4) 	#
		expressions[i] = expressions[i].replace('c5', c5) 	#
		expressions[i] = expressions[i].replace('L00', Coefficients[0][i]) #
		expressions[i] = expressions[i].replace('L1m1', Coefficients[1][i]) #
		expressions[i] = expressions[i].replace('L10', Coefficients[2][i]) #
		expressions[i] = expressions[i].replace('L11', Coefficients[3][i]) #
		expressions[i] = expressions[i].replace('L2m2', Coefficients[4][i])#
		expressions[i] = expressions[i].replace('L2m1', Coefficients[5][i])#
		expressions[i] = expressions[i].replace('L20', Coefficients[6][i]) #
		expressions[i] = expressions[i].replace('L21', Coefficients[7][i]) #
		expressions[i] = expressions[i].replace('L22', Coefficients[8][i]) #

	expNode = nuke.nodes.Expression(expr0=expressions[0],expr1=expressions[1],expr2=expressions[2])

Nuke to Muster

Tuesday, February 24th, 2009

Here’s a python script to submit scripts from Nuke to Muster.
Change: server, username and password to your muster server account.

Usage: If you run the script with nothing selected it renders all Write nodes.
Otherwise it renders the selected Writenodes.

Remember to save your script before submitting.

import re, os
import nuke

server = "address"
username = "username"
password = "password"

def madSubmit():
    a = nuke.knob("first_frame")
    b = nuke.knob("last_frame")
    start = int(a)
    end = int(b)
    incr = 1
    _range = a+","+b
    r = nuke.getInput("Frames to render:", _range)
    if r is not None:
        r = re.sub("[,|-|/]", " ", r)
        t = r.split()
    else:
        return
    if len(t) > 0:
      start = int(t[0])
      end = start
    else:
        return
    if len(t) > 1: end = int(t[1])
    if len(t) > 2: incr = int(t[2])

    cmd = '""%s\\Mrtool.exe" -s %s -u %s -p %s -b -pk 10 -e 28 -n %s -sf %i -ef %i -bf 1 -st 1 -f %s' % (os.getenv("MUSTER", "Failed"), server, username, password, os.path.basename(nuke.value("root.name")).split(".")[0], int(start) ,int(end), nuke.value("root.name"))

    writeNodes = [n for n in nuke.selectedNodes() if n.Class() == "Write"]
    if writeNodes:
        cmd += ' -add "-X '+','.join([node.name() for node in writeNodes])+'"'
    cmd +='"'
    print cmd
    os.system(cmd)

MEL: Padding Function

Tuesday, August 19th, 2008

This is a little function that takes a number and adds padding to it.

global proc string padNumber(int $number, int $length){
	string $paddedString = string($number);
	while(size($paddedString)<$length)
		$paddedString = ("0"+$paddedString);
	return $paddedString;
}

Example:
padNumber 55 4;
// Result: 0055

madSplitToning

Friday, August 15th, 2008

This is a simple Nuke Gizmo that is similar to the Split Toning feature in Adobe Lightroom.

DOWNLOAD:

madsplittoning_v01

.

The MEL that you shouldn’t need

Wednesday, May 28th, 2008

madRecentCrashFile.mel

I wrote this script after a very buggy period of Maya use. After i found myself digging around in the temp directory, searching for the recently crashed file.

I run it at Maya startup so that it’s always there and up to date.

DOWNLOAD:

madRecentCrashFile.mel

.

Photoshop To Map

Thursday, August 23rd, 2007

Here’s two script for exporting textures from Photoshop to Mental Ray .map format.

(more…)

Posten Showroom Breakdown

Sunday, August 12th, 2007

posten.jpg

We have produced some animations for the swedish post office together with the advertising agency Ã…kestam Holst and the production company B-Reel. It is a stylistic 2D animation made in 3D. You can check them out here.
(more…)