0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Autodesk Arnold Renderer でUSDを触る

0
Last updated at Posted at 2026-05-31

1. Arnold USDを検証する

testsuitesの0016を試してみました。
PixarのKitchen_set.usdを読み込みます。

test.ass
### exported: Mon Dec 17 21:54:24 2018
### from:     Arnold 5.2.2.0 [30b8ba14] windows icc-17.0.2 oiio-2.0.1 osl-1.10.1 vdb-4.0.0 clm-1.0.3.513 rlm-12.4.2 2018/12/04 22:02:04
### host app: MtoA 3.1.3.wip 7d48f6c4 (develop) Maya 2018
### bounds: -1 -8.268288 -1 1 -6.268287 1
### user: blaines
### render_layer: defaultRenderLayer
### scene: D:/arnold/scenes/usd.ma



options
{
 AA_samples 16
 outputs "RGBA RGBA myfilter mydriver"
 xres 640
 yres 480
 pixel_aspect_ratio 1.33333325
 camera "perspShape"
 frame 1
}

gaussian_filter
{
 name myfilter
}

driver_tiff
{
 name mydriver
 filename "testrender.tif"
 color_space "sRGB"
}

persp_camera
{
 name perspShape
 matrix
 0.999945164 8.67361738e-19 0.0104717845 0
 -0.0104540139 0.0582322851 0.998248339 0
 -0.000609795912 -0.998303056 0.0582290925 0
 53.1155281 -643.779846 144.040329 1
 near_clip 0.100000001
 far_clip 10000
 shutter_start 0
 shutter_end 0
 shutter_type "box"
 rolling_shutter "off"
 rolling_shutter_duration 0
 motion_start 0
 motion_end 0
 exposure 0
 fov 54.4322243
 uv_remap 0 0 0 1
 declare dcc_name constant STRING
 dcc_name "perspShape"
}

skydome_light
{
 name |aiSkyDomeLight1|aiSkyDomeLightShape1
 exposure 0
 cast_shadows on
 cast_volumetric_shadows on
 shadow_density 1
 shadow_color 0 0 0
 samples 1
 normalize on
 camera 0
 transmission 1
 diffuse 1
 specular 1
 sss 1
 indirect 1
 max_bounces 999
 volume_samples 2
 volume 1
 aov "default"
 resolution 1000
 format "latlong"
 portal_mode "interior_only"
 aov_indirect off
 declare dcc_name constant STRING
 dcc_name "aiSkyDomeLightShape1"
}


usd
{
 name aiUsdShape2
 visibility 255
 matrix
 1 0 0 0
 0 1 0 0
 0 0 1 0
 0 -7.26828718 0 1
 use_light_group off
 override_nodes off
 filename "Kitchen_set.usd"
 operator disableCube
}

disable
{
	name disableCube
	selection "/Kitchen_set/Arch_grp/Kitchen_1/Geom/Cabinets/Doors/pCube5"
}

ありがとうございます。
サンプル数を3から16に変更しました。

testrender.png


2. Arnold 7 Python API 用のコードに変換

Antigravity CLIを使って、変換してみました。
サンプル数を4に変更しました。

変換内容の概要

  1. 初期化と終了処理: AiBegin() および AiEnd() を使用した Arnold
    セッションのセットアップ。
  2. ノードの生成と設定:
    • options の設定と出力バッファ ( outputs ) の配列割り当て。
    • カメラ perspShape のパラメータ設定 ( uv_remap は AI_TYPE_RGBA であるため
    AiNodeSetRGBA を使用し、メタデータ dcc_name は AiNodeDeclare で宣言)。
    • skydome_light ノードの設定。
    • usd ノード ( aiUsdShape2 )
    の設定。相対パスの解決機能を追加しており、実行場所に合わせて適切な USD
    ファイルパスを参照します。
    • disable オペレータノード ( disableCube ) の設定と、 usd ノードの operator
    パラメータへの関連付け。
  3. シーンの書き出しとレンダリング: アスキー形式での .ass
    書き出しと、レンダリング実行処理の追加。

動作確認

変換後のスクリプトを実行し、以下の出力が正常に生成されることを確認しました:

• レンダリング画像: testrender.tif
• アスキー形式 ASS: kitchen_usd_ascii.ass (元の test.ass
と同様のノード構造でエクスポートされることを確認済み)

# kitchen_usd.py
# Arnold 7 Python API
# Translated from kitchen_usd/test.ass

import os
from arnold import *

def make_matrix(vals):
  return AtMatrix(*vals)

universe = AiBegin()
AiMsgSetConsoleFlags(universe, AI_LOG_ALL)

# filter
filt = AiNode(universe, "gaussian_filter", "myfilter")

# driver
driver = AiNode(universe, "driver_tiff", "mydriver")
AiNodeSetStr(driver, "filename", "testrender.tif")
AiNodeSetStr(driver, "color_space", "sRGB")

# options
options = AiUniverseGetOptions(universe)
AiNodeSetInt(options, "AA_samples", 4)
AiNodeSetInt(options, "xres", 640)
AiNodeSetInt(options, "yres", 480)
AiNodeSetFlt(options, "pixel_aspect_ratio", 1.33333325)
AiNodeSetFlt(options, "frame", 1.0)

# outputs
out_arr = AiArrayAllocate(1, 1, AI_TYPE_STRING)
AiArraySetStr(out_arr, 0, "RGBA RGBA myfilter mydriver")
AiNodeSetArray(options, "outputs", out_arr)

# camera
camera = AiNode(universe, "persp_camera", "perspShape")
camera_matrix = AtMatrix(
  0.999945164, 8.67361738e-19, 0.0104717845, 0.0,
  -0.0104540139, 0.0582322851, 0.998248339, 0.0,
  -0.000609795912, -0.998303056, 0.0582290925, 0.0,
  53.1155281, -643.779846, 144.040329, 1.0
)
AiNodeSetMatrix(camera, "matrix", camera_matrix)
AiNodeSetFlt(camera, "near_clip", 0.100000001)
AiNodeSetFlt(camera, "far_clip", 10000.0)
AiNodeSetFlt(camera, "shutter_start", 0.0)
AiNodeSetFlt(camera, "shutter_end", 0.0)
AiNodeSetStr(camera, "shutter_type", "box")
AiNodeSetStr(camera, "rolling_shutter", "off")
AiNodeSetFlt(camera, "rolling_shutter_duration", 0.0)
AiNodeSetFlt(camera, "motion_start", 0.0)
AiNodeSetFlt(camera, "motion_end", 0.0)
AiNodeSetFlt(camera, "exposure", 0.0)
AiNodeSetFlt(camera, "fov", 54.4322243)
AiNodeSetRGBA(camera, "uv_remap", 0.0, 0.0, 0.0, 1.0)
AiNodeDeclare(camera, "dcc_name", "constant STRING")
AiNodeSetStr(camera, "dcc_name", "perspShape")

AiNodeSetPtr(options, "camera", camera)

# skydome light
skydome = AiNode(universe, "skydome_light", "|aiSkyDomeLight1|aiSkyDomeLightShape1")
AiNodeSetFlt(skydome, "exposure", 0.0)
AiNodeSetBool(skydome, "cast_shadows", True)
AiNodeSetBool(skydome, "cast_volumetric_shadows", True)
AiNodeSetFlt(skydome, "shadow_density", 1.0)
AiNodeSetRGB(skydome, "shadow_color", 0.0, 0.0, 0.0)
AiNodeSetInt(skydome, "samples", 1)
AiNodeSetBool(skydome, "normalize", True)
AiNodeSetFlt(skydome, "camera", 0.0)
AiNodeSetFlt(skydome, "transmission", 1.0)
AiNodeSetFlt(skydome, "diffuse", 1.0)
AiNodeSetFlt(skydome, "specular", 1.0)
AiNodeSetFlt(skydome, "sss", 1.0)
AiNodeSetFlt(skydome, "indirect", 1.0)
AiNodeSetInt(skydome, "max_bounces", 999)
AiNodeSetInt(skydome, "volume_samples", 2)
AiNodeSetFlt(skydome, "volume", 1.0)
AiNodeSetStr(skydome, "aov", "default")
AiNodeSetInt(skydome, "resolution", 1000)
AiNodeSetStr(skydome, "format", "latlong")
AiNodeSetStr(skydome, "portal_mode", "interior_only")
AiNodeSetBool(skydome, "aov_indirect", False)
AiNodeDeclare(skydome, "dcc_name", "constant STRING")
AiNodeSetStr(skydome, "dcc_name", "aiSkyDomeLightShape1")

# operator
disableCube = AiNode(universe, "disable", "disableCube")
AiNodeSetStr(disableCube, "selection", "/Kitchen_set/Arch_grp/Kitchen_1/Geom/Cabinets/Doors/pCube5")

# usd node
usd = AiNode(universe, "usd", "aiUsdShape2")
AiNodeSetByte(usd, "visibility", 255)
usd_matrix = AtMatrix(
  1.0, 0.0, 0.0, 0.0,
  0.0, 1.0, 0.0, 0.0,
  0.0, 0.0, 1.0, 0.0,
  0.0, -7.26828718, 0.0, 1.0
)
AiNodeSetMatrix(usd, "matrix", usd_matrix)
AiNodeSetBool(usd, "use_light_group", False)
AiNodeSetBool(usd, "override_nodes", False)

# Try resolving the USD path
if os.path.exists("kitchen_usd/Kitchen_set.usd"):
  AiNodeSetStr(usd, "filename", "kitchen_usd/Kitchen_set.usd")
elif os.path.exists("Kitchen_set.usd"):
  AiNodeSetStr(usd, "filename", "Kitchen_set.usd")
else:
  AiNodeSetStr(usd, "filename", "Kitchen_set.usd")

AiNodeSetPtr(usd, "operator", disableCube)

# Export scene to ASS file (ASCII format) for inspection
params = AiParamValueMap()
AiParamValueMapSetBool(params, "binary", False)
AiSceneWrite(universe, "kitchen_usd_ascii.ass", params, None)
AiParamValueMapDestroy(params)

# Render the scene
render_session = AiRenderSession(universe)
AiRender(render_session)
AiRenderSessionDestroy(render_session)

AiEnd()

一歩一歩です。ありがとうございます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?