3dsmax與Nuke好朋友一起完成3D立體成像吧
要試的東西太多,總是容易做過之後要在做一次就要回想半天,
不管是快門式、偏光鏡、紅藍眼鏡,
首先就是一定要先有讓左眼看的影像與給右眼看的影像,
讓我們打開馬克斯先生。
我先建立一個攝影機,設定好焦距,當左眼,
在複製(shift按著) 建立出相同的攝影機,當右眼,
註:攝影機距離最好是6~8公分為什麼呢,人的雙眼距離約6~8公分,安定值6.5
接下來打開 扭克先生
並把四張圖讀入
按下s到project setting 設定左右眼通道
再使用shuffle把深度圖層導入給disparity
可是要注意,越深的地方要越白,
但是我們的圖是越靠近攝影機越白,
所以黑白是相反的,
這時後使用invet node就好了
注意使用的通道
左眼的作好了在來換右眼的,
應該會像醬子
使用 split and join node 分別把左右兩眼接上 接下來使用expression node 上打1/disparityL.x 這時後disparity應該會變成一片曝白,但是調節曝光值其實數值都有保留
最麻煩的來囉~
要使用add node ,在這之前,先切換left、right兩眼的圖,找到圖片中有一個焦點是不大會變動的,
為了找到中間點
我範例中是握把處下兩張圖比較不會有變動
有沒有看到一個小紅點是ctrl + lmb 選取 回到這一層,會看到底下rgb值
把這個數值填到add node的value上並改成負數 這時後就會變醬子,以那點為基準點螢幕前凸的會有白色漸變 接下來要找到最深的那點先到左眼rgba最深的點是牆角
記下x軸
換到disparity圖層記下rgb值
切換到右眼rgba一樣找到最深的那點
接下來就是算數圖辣,把左眼的x減去右眼的x就是兩眼看過去的相差的距離,
408-378 = 30
再把算出來的值除去剛剛記錄下的disparity的rgb值約-0.5XXXX
30/-.05XXXX
算出來的值記下來,
使用multiply node,
把剛剛的數值下到value上 這時後disparity就會變成醬子 但是我把光圈值調小還是看的到變化 再使用一次split and join node配合shuffle copy 把左右兩眼合在一起
注意shufflecopy 給的通道位置左右眼不一樣
終於,最後在使用reconverge node 跟 anaglyph node 就快完成了mode 要選兩個both
使用reconverge時會出一個convergepoint 結合點,
這是控制你的影像哪裡是深入哪裡要凸出,
最後結果圖
補充:
其實在做3d影片時,會凸螢幕的效果,看的效果會很好,
但是會比較傷眼睛,所以最好是除非有特別需要,不然,
3d的效果最好是做成往螢幕裡面延深比較不會傷害眼睛....
3dsmax rendering world space(point pass、point position) work with nuke
首先開啟3dsmax 建立模形
nuke&python init.ty&menu.ty相關設定
再執行其它資料夾的init、menu,
NUKE 使用相對路徑
用DC+PS 製作假HDR...
[ 1 ] We'll call the original layer "ORIGINAL", now duplicate ORIGINAL and place it above that layer. (We'll call this "BLACKWHITE")
ctrl+j 複製一個圖層 取一個你喜歡的名子
[ 2 ] Change the Blending option of BLACKWHITE to "Overlay"
疊加模式改成overlay
[ 3 ] Go to Image > Adjustements > Desaturate (SHIFT + CTRL + U)
直接用快速鍵 shift+ctrl+u 按一下,降低飽合度
[ 4 ] Now invert BLACKWHITE: Image > Adjustements > Invert (CTRL + I)
ctrl+i 按一下反轉黑白
[ 5 ] And add a gaussian Blur to it (Filter > Blur > Gaussian Blur) around 40 pixels (This causes the so called 'bleeding' of the edges, tweak the amount to personal likings)
加入高斯模糊值約40
這時後效果是醬子
[ 6 ] Now duplicate ORIGINAL and place it above BLACKWHITE, name this layer "LINEAR_LAYER"
再從原圖複製一個圖層在最上面
[ 7 ] Change the blending type of LINEAR_LAYER to "Linear Light"
[ 8 ] Give LINEAR_LAYER an opacity around 62%. And you're done (For better results, tweak this percentage)
改它的透明度覺得好看就好,當然不是每張圖都很美所以就在另外自己調調色吧
Komodo IDE + python ....入門章
nuke 中的 python (轉)
1. 通過py創建節點。
先說一下python for nuke的大概情況。Nuke 6.1 版本比 之前的版本,增加了幾個包和模塊。首先說一下大致的概況
模塊:
(1)_geo:該模塊為nuke 3d 核心模塊。
(2)_nukemath:該模塊提供了在nuke中矢量以及矩陣的算法。
(3)ntpath:類似於py中的os.path,直接用,不需導入os.path。
(4)nuke:該模塊為最重要的並且是最核心的模塊,提供了所有nuke特有的方法和類。
(5)nukescript:該模塊為nuke腳本的功能增加模塊,例如可以支持pyqt和wxpython等等,有一些集成好的方法。
創建節點:
創建節點我們使用nuke模塊下的createNode方法。
使用方法如下:
nuke. createNode(node, args, inpanel)
node:這裡為我們想要的節點類型,比如 Read,Blur,Merge等。
Args:這裡為創建節點時,設置節點的參數數值,注意它是以成對的方式出現,例如「size 50」,它是一個可選參數。
Inpanel:這裡是用來是否在節點生成後自動打開節點的控制板,True或者False。
給節點添加用戶自定義的屬性:
因為我們創建的節點都屬於nuke模塊下node類的實例,所以我們有時需要給創建的節點一個變量。
例如myNode = nuke.createNode(『Read')
這樣myNode就成為了node類的一個實例。
在nude類中有一個方法叫做addKnob,它的用法如下:
addKnob(self, k)
self:實例本身
k:用戶想添加的屬性名稱
例如:
myNode.addKnob(『myKnob')
設定屬性值的默認值:
設定屬性的默認值,我們市針對於某一類型的節點,比如我想在Blur節點的sizet屬性通道中設置默認值為20,我可以使用nuke模塊下的knobDefault方法,用法如下:
knobDefault(classknob, value)
例如:nuke.knobDefault(「Blur.size」, 「20〞)
這樣,我們之後每次生成Blur節點,size都會為20。
2. 在nuke中自定義菜單和工具欄。
(1)
在nuke中默認的工具欄,是通過nuke模塊下的toolbar類的實例來實現的。
我們可以實例化一個自定義的toolbar,並且給它添加一些相應的菜單和命令,並且可以制定出快捷鍵。
Nuke.toolbar這個類是object的子類,除了繼承了object類的
__delattr__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__等這些屬性和方法,它還有
__new__,addCommand(),addMenu(),addSeparator(),findItem()五個方法。
我們實例化一個toolbar後,可以通過addMenu,addCommand來添加功能。
下面就以一個具體的實例來說明:
功能:我們添加一個自己的toolbar,名字定義為「mine」,為該工具架添加一個帶圖標的菜單(color),在該菜單下添加創建Ramp節點的命令,並且指定快捷鍵「alt + r」
代碼實現:
myToolBar = nuke.toolbar(『mine')
myMenu = myToolBar.addMenu(『myMenu','calvin.png')#其實這一步實例化了nuke的menu
myMenu.addCommand(『color/Ramp','nuke.createNode(「Ramp」)』,'alt + r')
通過切換菜單 我們可以找到自己定義的東西了。
(2)
在nuke中實現對話框。
我們可以使用nuke模塊下的message方法。
比如我想再nuke裡顯示一個對話框,顯示內容:「I like nuke」
我們可以通過代碼:
nuke.meaasge(『I like nuke')
我們想顯示現在選擇的節點數量,我們可以通過幾個組合的函數實現:
selNodes = nuke.selectedNodes()
num = len(selNodes)
numStr = str(num)
nuke.meaasge(numStr + 『 nodes are selected')
具體解釋:
我們可以使用方法nuke.selectedNodes()將當前選擇的節點的實例存放在 selNodes 這個變量中,它返回的是一個列表。
我們使用len方法,可以獲得列表裡德元素的數量
因為nuke.message的參數隻能包含字符串,而不能是int float型的數據,所以我們要把 num 這個int型的數據,轉換為字符串,使用工廠函數str()
((3)
添加菜單。
給nuke添加菜單,我們需要瞭解nuke模塊下的menu方法。
它的用法如下:
nuke.menu(name)
該命令返回名字為name的menu的類的實例。
通過nuke的UI,我們可以將化為幾類,
1. 『nuke' 這就是我們需要用到的程序菜單。
2. 『pane' 這就是UI panes
3. 『Nodes' 這就是我們常提到的創建節點的工具欄
4. 『animation' 動畫菜單以及編輯器
5. 『viwer' 觀察視窗
6. 『node graph' 節點網絡圖
給nuke添加菜單,我們需要使用menu的方法,返回『Nuke'的實例。
如上面講到的,再次使用addMenu和addCommand的方法進行添加。
例如我想添加一個菜單如下架構:
myMenu > Transform > Reformat
這樣來創建節點,並且自定義快捷鍵為 alt + r
我們可以將代碼寫為:
m = menubar.addMenu("&myMenu")
m.addCommand("Transform/Reformat", "nuke.createNode('Reformat')", "^r")
3. 實例應用,我們將編寫一個清除nuke文件中沒有用的節點,優化文件。
我們的想法是選擇我們想保留的最終節點,可以選擇幾個,這樣在該節點的上游節點會全部保留,其他與這些節點無關的節點會自動刪除,並且在刪除後,彈出信息,說明刪除了多少節點並且說出這些節點的名字。
為了我們的想法,我們需要對python有一定的瞭解。
最後,我們將該功能添加到菜單裡,
菜單的結構如下:
myMenu > func> clear Rubbish Node
把該命令定義一個快捷鍵 alt + c
代碼如下:
selNode = nuke.selectedNodes()
allNode = nuke.allNodes()
connecedNode = []
def returnInputs(node):
inputNum = 0
conNodes = []
if node != None:
inputNum = node.inputs()
if inputNum != 0:
for i in range(inputNum):
if (node.input(i) not in connecedNode) and (node.input(i) != None):
connecedNode.append(node.input(i))
conNodes.append(node.input(i))
return [inputNum,conNodes]
def combineNode(conList):
if len(conList)>0:
for conNode in conList:
conN = returnInputs(conNode)
if conN[0] > 0:
combineNode(conN[1])
def caculRelatedNode(selNodes):
for sel in selNodes:
conNs = returnInputs(sel)[1]
combineNode(conNs)
connecedNode.extend(selNode)
def returnRubbishNode():
for usefulNode in connecedNode:
allNode.remove(usefulNode)
messages = str(len(allNode)) + ' nodes were deleted,they are:\n'
for singleNode in allNode:
messages += singleNode.name() + '\n'
nuke.delete(singleNode)
nuke.message(messages)
def clearRubbish():
caculRelatedNode(selNode)
returnRubbishNode()
menubar = nuke.menu("Nuke");
m = menubar.addMenu("&myMenu")
m.addCommand("func/clear Rubbish Node", "clearRubbish()", "^c")
在nuke中,將這段代碼運行,找到菜單可以嘗試。
python note 之 3
def 定義function
varalex()
# Result:
hello beauty
def varalex(usealex):
print 'hello beauty %s' %usealex
varalex('u look so beauty')
# Result:
hello beauty u look so beauty
def varalex(usealex):
for i in usealex:
print 'hello beauty %s' %i
varalex(['funny', 'ball', 'child', 'car', 'girl'])
# Result:
hello beauty funny
hello beauty ball
hello beauty child
hello beauty car
hello beauty girl
def varalex(usealex):
chralex = ''
for i in usealex:
chralex += 'hello beauty %s\n' %i
return chralex
alexvar = varalex(['funny', 'ball', 'child', 'car', 'girl'])
print alexvar
# Result:
hello beauty funny
hello beauty ball
hello beauty child
hello beauty car
hello beauty girl
nuke去背小技巧
之前去背都是用keylight吸一吸色之後,在去調色,把其他帶有看起來綠綠的部份調過,
python note 之 2
varalex = {'name' : 'alex', 'age' : 25, 'workhistor' : ['god','rice bug','dreamwork'], 'demensition' : {'height' : 176, 'weight' : 66}}
print varalex
print varalex.keys()
print varalex.values()
print varalex.items()
# Result:
{'demensition': {'weight': 66, 'height': 176}, 'age': 25, 'name': 'alex', 'workhistor': ['god', 'rice bug', 'dreamwork']}
['demensition', 'age', 'name', 'workhistor']
[{'weight': 66, 'height': 176}, 25, 'alex', ['god', 'rice bug', 'dreamwork']]
[('demensition', {'weight': 66, 'height': 176}), ('age', 25), ('name', 'alex'), ('workhistor', ['god', 'rice bug', 'dreamwork'])]
{}更多的使用 #是單行註解
varalex = {'name' : 'alex', 'age' : 25, 'workhistory' : ['god','rice bug','dreamwork'], 'demensition' : {'height' : 176, 'weight' : 66}}
print varalex.keys()
print varalex.values()
print varalex.items()
varalex['favoritecolor'] = 'green' #add another keys
print varalex.keys()
varalex.pop('favoritecolor') # remove key
print varalex.keys()
print varalex['name'] in ['alex','wong','wu'] #check
varalex['name'] = 'awesome' #change name
print varalex['name']
varalex['workhistory'][0] = 'animation designer' #change job
print varalex['workhistory']
varalex['workhistory'].append('buesiness man') #add job
print varalex['workhistory']
# Result:
['demensition', 'age', 'name', 'workhistory']
[{'weight': 66, 'height': 176}, 25, 'alex', ['god', 'rice bug', 'dreamwork']]
[('demensition', {'weight': 66, 'height': 176}), ('age', 25), ('name', 'alex'), ('workhistory', ['god', 'rice bug', 'dreamwork'])]
['demensition', 'age', 'favoritecolor', 'name', 'workhistory']
['demensition', 'age', 'name', 'workhistory']
True
awesome
['animation designer', 'rice bug', 'dreamwork']
['animation designer', 'rice bug', 'dreamwork', 'buesiness man']
多行註解'''的使用
varalex = {'name' : 'alex', 'age' : 25, 'workhistory' : ['god','rice bug','dreamwork'], 'demensition' : {'height' : 176, 'weight' : 66}}
varalex['favoritecolor'] = 'green' #add another keys
varalex.pop('favoritecolor') # remove key
varalex['name'] = 'awesome' #change name
varalex['workhistory'][0] = 'animation designer' #change job
varalex['workhistory'].append('buesiness man') #add job
'''
print varalex ['name']
print varalex ['age']
'''
# Result:
變化 兩個功能之間運用#作切換
varalex = {'name' : 'alex', 'age' : 25, 'workhistory' : ['god','rice bug','dreamwork'], 'demensition' : {'height' : 176, 'weight' : 66}}
#'''
print varalex ['name'] #function one
'''
print varalex ['age'] #function two
#'''
# Result:
alex
varalex = {'name' : 'alex', 'age' : 25, 'workhistory' : ['god','rice bug','dreamwork'], 'demensition' : {'height' : 176, 'weight' : 66}}
'''
print varalex ['name'] #function one
'''
print varalex ['age'] #function two
#'''
# Result:
25
if 判斷
varalex = 'green'
varalexlist = ['green','blue','white','red']
varalexcolors =['black','green','white','red','orange']
if varalex in varalexlist:
print 'found %s' % varalex #add tab
# Result:
found green
else 應用
varalex = 'green'
varalexlist = ['green','blue','white','red']
varalexcolors =['black','green','white','red','orange']
varalex = 'alex'
if varalex in varalexlist:
print 'found %s' % varalex #add tab
else:
print 'the %s not a valid color' %varalex #add tab
# Result:
the alex not a valid color
elif 應用
varalex = 'green'
varalexlist = ['green','blue','white','red']
varalexcolors =['black','green','white','red','orange']
varalex = 'black'
if varalex in varalexlist:
print 'found %s' % varalex
elif varalex in varalexcolors:
varalexlist.append(varalex)
print 'adding %s to varalexlist' %varalex
print varalexlist
else:
print 'the %s not a valid color' %varalex
# Result:
adding black to varalexlist
['green', 'blue', 'white', 'red', 'black']
IF IF 應用
varalexlist = ['green','blue','white','red']
varalexcolors =['black','green','white','red','orange']
varalex = 'black'
if varalex in varalexcolors:
if varalex in varalexlist:
print 'OK, %s is work' %varalex
else:
print 'woops, %s is not a volid color' %varalex
else:
print 'the %s can not work' %varalex
# Result:
woops, black is not a volid color
for in應用
for item in range(0,10):
print item
# Result:
0
1
2
3
4
5
6
7
8
9
varalex = 'floccinaucinihilipilification'
for charalex in varalex:
print charalex
# Result:
f
l
o
c
c
i
n
a
u
c...太長跳過
varalex = 'floccinaucinihilipilification'
for charalex in varalex:
print charalex *3
# Result:
fff
lll
ooo
ccc
ccc
iii ...太長跳過
for in + if in 應用
alexlist = ['even','today','is','very','hot','but',"i'm",'still','have','fun']
varnumfor = 0
varnumif = 0
print ' '.join(alexlist)
alexcommon = []
for varalex in alexlist:
varnumfor += 1
if varalex in ['i','would','like','to','go','with','u','guys','because','we','will','have','fun']:
alexcommon.append(varalex)
varnumif += 1
print str(alexcommon) +' ifin runs %s times' %varnumif
print ' ifin runs %s times' %varnumif + ' and forin runs %s times' %varnumfor
if varnumif !=0:
print ' ifin totally runs %s times' %varnumif
print ' forin totally runs %s times' %varnumfor
# Result:
even today is very hot but i'm still have fun
ifin runs 0 times and forin runs 1 times
ifin runs 0 times and forin runs 2 times
ifin runs 0 times and forin runs 3 times
ifin runs 0 times and forin runs 4 times
ifin runs 0 times and forin runs 5 times
ifin runs 0 times and forin runs 6 times
ifin runs 0 times and forin runs 7 times
ifin runs 0 times and forin runs 8 times
['have'] ifin runs 1 times
ifin runs 1 times and forin runs 9 times
['have', 'fun'] ifin runs 2 times
ifin runs 2 times and forin runs 10 times
ifin totally runs 2 times
forin totally runs 10 times
數質計算
varalex = []
for alexitem in range(0,20):
if alexitem % 2 == 1:
varalex.append(alexitem)
print varalex
# Result:
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
alexdict = {'x' : 100, 'y' : 200, 'z' : 300}
for wu in alexdict.keys():
alexdict[wu] += 500
print wu
print alexdict
# Result:
y
x
z
{'y': 700, 'x': 600, 'z': 800}
數質計算兩種寫法
簡單的
alexlist =[]
for alexitem in range(0,5):
alexlist.append(alexitem)
print alexlist
比較難的
varalex = [alexitem for alexitem in range(0,5)]
print varalex
# Result:
[0, 1, 2, 3, 4]
[0, 1, 2, 3, 4]
例2
較好理解,寫比較多
alexlist =[]
for alexitem in range(0,10):
if alexitem % 2 ==1:
alexlist.append(alexitem)
print alexlist
寫比較短,不好理解
varalex = [alexitem for alexitem in range(0,10) if alexitem % 2 == 1]
print varalex
# Result:
[1, 3, 5, 7, 9]
[1, 3, 5, 7, 9]
例3
alexlist =[]
for alexitem in range(0,10):
if alexitem % 2 ==1:
alexlist.append((alexitem + 21) //7)
print alexlist
varalex = [(alexitem+21) //7 for alexitem in range(0,10) if alexitem % 2 == 1]
print varalex
# Result:
[3, 3, 3, 4, 4]
[3, 3, 3, 4, 4]
while 迴圈判斷式
while 的用法只要注意條件式,成立的條件即可否則會造成無窮迴圈
upalex = 10
numbers = range(2, upalex)
varalexs = []
print numbers
while numbers:
varalex =numbers.pop(0)
varalexs.append(varalex)
numbers = [n for n in numbers if n % varalex]
print '1numbers '+str(numbers)
print '2varalex '+str(varalex)
print '3varalexs '+str(varalexs)
print varalexs
# Result:
[2, 3, 4, 5, 6, 7, 8, 9]
1numbers [3, 5, 7, 9]
2varalex 2
3varalexs [2]
1numbers [5, 7]
2varalex 3
3varalexs [2, 3]
1numbers [7]
2varalex 5
3varalexs [2, 3, 5]
1numbers []
2varalex 7
3varalexs [2, 3, 5, 7]
[2, 3, 5, 7] <---結果




















