This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from maya import OpenMaya | |
import pymel.core as pm | |
def mdagpath_from_name(name, extend_to_shape=False): | |
if not pm.objExists(name): | |
raise MayaNodeError, name | |
slist = OpenMaya.MSelectionList() | |
slist.add(name) | |
dagpath = OpenMaya.MDagPath() | |
slist.getDagPath(0, dagpath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# render用のdelayed loadオブジェクトとシェーダを作成する | |
# 当然それらにはリンクが設定してある状態になる | |
# SOPで任意のノード(rop_alembic, rop_geometry, filecache)を選んでshelfボタンをポチで完了 | |
import hou | |
type_pairs = {'rop_alembic': 'filename', | |
'rop_geometry': 'sopoutput', | |
'filecache': 'file'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# filecache SOPにボタンを追加して、そのボタンのCallback Scriptに登録して使う | |
# filecacheと同名のropにジャンプする | |
# ジャンプした際、対象のropは選択状態になっている | |
node = hou.pwd() | |
out_node = '/out/{}'.format(node.name()) | |
hou.hscript('panepath -f {}'.format(out_node)) | |
hou.node(out_node).setSelected(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nuke | |
import os.path | |
reads = nuke.allNodes('Read') | |
err_cnt = 0 | |
for i, r in enumerate(reads): | |
raw = r.knob('file').getValue() | |
evaluated = r.knob('file').getEvaluatedValue() | |
full_path = '{}/{}'.format(os.path.dirname(evaluated), os.path.basename(raw)) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mayaで諸事情によりカメラスケール使えなかった時用に調べて書いた | |
# degreeとmmで計算してます | |
import math | |
def focal_to_aov(focal, aperture): | |
''' | |
focal: focal length | |
aperture: horizontal aperture (mm) | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# とりあえず大急ぎで書いてる | |
# あれこれ書き方忘れてたので参考ページもメモ | |
# https://area.autodesk.jp/column/tutorial/maya_atoz/attribute_plug/ | |
# http://ianwaters.co.uk/wp/mash/accessing-mash-point-data-with-the-maya-api/ | |
from maya import OpenMaya | |
import pymel.core as pm | |
def mdg_from_name(name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymel.core import * | |
import math | |
pt0, pt1 = selected(fl=True) | |
p0 = dt.Vector(xform(pt0, q=True, ws=True, t=True, a=True)) | |
p1 = dt.Vector(xform(pt1, q=True, ws=True, t=True, a=True)) | |
diff = p0-p1 | |
axis = dt.Vector(0, 0, 1) | |
print(math.degrees(math.acos(diff.normal().dot(axis)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float bias(float b; float x) { | |
return pow(x, log(b)/log(0.5)); | |
} | |
float gain(float g; float x) { | |
if (x<0.5) | |
return bias(1-g, 2*x)/2; | |
else | |
return 1-bias(1-g, 2-2*x)/2; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float bias(float b; float x) { | |
return pow(x, log(b)/log(0.5)); | |
} | |
float gain(float g; float x) { | |
return (x<0.5) ? bias(1-g, 2*x)*.5 : 1-bias(1-g, 2-2*x)*.5; | |
} | |
// usage example | |
float x = v@P.x; | |
//v@P.y = bias(0.8, x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imageio | |
imgpath = 'myhdri.hdr' | |
# freeimageがインストールされていないシステムでも以下の一行を実行すればHDRが読める | |
imageio.plugins.freeimage.download() | |
img = imageio.imread(imgpath) | |
# 画像サイズも確認可能 | |
print(img.shape) | |