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?

pyxel_multirenderer_exporter — Pyxel 3D ビューア + マルチレンダラー シーンエクスポータ

0
Last updated at Posted at 2026-07-03

Pyxel 製のワイヤーフレーム 3D ビューアでカメラをマウス操作し、見たままの構図
3 種類のレンダラー向けシーン記述ファイルとして書き出す教育用ツールです。

  • S キー → Sunflow .sc
  • N キー → 3Delight (NSI) .nsi
  • M キー → mental ray standalone .mi(mia_physicalsun / mia_physicalsky による daylight + 露出制御)

スクリーンショット 2026-07-03 190429.png

DCC ツール(Maya / Blender 等)を使わず、シーン記述をテキストとして直接読める形で
出力するため、レンダラー内部の仕組みを学ぶ教材として使えます。管理者権限のない
教室 PC でも、ポータブル Python 環境があれば動作します。

export_nsi5.jpg

特徴

  • マウスドラッグでタンブル、↑↓キーでズームするシンプルなワイヤーフレームビューア
  • ビューアのカメラ(水平 FOV 60°)と一致する画角で各レンダラーへ出力
    • Sunflow: eye / target / up / fov 指定
    • NSI: 水平→垂直 FOV 変換 + camera-to-world 行列
    • mental ray: aperture 36mm 固定で focal を逆算 + world-to-camera(逆行列) の instance transform
  • ジオメトリは world 座標の頂点 + identity インスタンスで出力(3 形式共通の方針)
  • .mi 出力は物理太陽・物理空・トーンマッピング(mia_exposure_simple)込みの
    デイライトシーンなので、gainhaze などを書き換えて露出・ライティングの
    実験がすぐにできます

動作環境

pip install pyxel numpy

WinPython 等のポータブル環境でも動作します(インストール不要・管理者権限不要)。

使い方

python pyxel_multirenderer_exporter.py
操作 機能
左ドラッグ カメラをタンブル
↑ / ↓ ズームイン / アウト
R カメラをリセット
S Sunflow 形式 export.sc を書き出し
N 3Delight NSI 形式 export.nsi を書き出し
M mental ray 形式 export.mi を書き出し
Q 終了

レンダリング例

ターミナルをもう 1 つ開いて、書き出したファイルをレンダリングします。

# Sunflow
java -jar sunflow.jar export.sc

test01.png

# 3Delight
renderdl export.nsi

export_nsi6.jpg

# mental ray standalone
ray export.mi

mi_out.jpg

構図を変えてはエクスポート → レンダリング、を繰り返すことで、
カメラワークとレンダリング結果の関係を体感的に学べます。

学習ポイント(.mi 出力について)

  • instance transform は world→camera の逆行列です。ビューアの
    カメラ基底(right / up / -forward)を「列」に置いた転置回転と、
    平行移動 (-eye·right, -eye·up, +eye·forward) で構成しています。
    camera→world 行列をそのまま書くと絵が出ません(mental ray の
    transform 規約でつまずきやすいポイントです)。
  • mental ray のカメラは -Z 注視(RenderMan / OpenGL と同じ)です。
  • aperture は水平フィルム幅なので、水平 FOV を合わせるには
    focal = aperture / (2·tan(FOV/2)) で焦点距離を逆算します。

改造のヒント

.mi はただのテキストです。エディタで開いて数行変えるだけで実験できます。

  • mia_exposure_simplegain を 0.05〜0.5 で振る → 露出の意味を体感
  • sunShapedirection を変える → 朝夕の光(redblueshift / haze と併用)
  • red_plasticmia_material_x に差し替える → 反射・IOR の実験
  • 頂点座標を書き換える → ジオメトリとシーン記述の対応を確認

注意事項

  • 本リポジトリはシーン記述ファイル(テキスト)を生成するのみで、
    各レンダラーのバイナリ・シェーダーライブラリは一切含みません
  • mental ray は NVIDIA の製品(商標)であり、既に販売・配布を終了しています。
    .mi のレンダリングには、正規に入手済みの mental ray standalone が必要です。
  • Sunflow はオープンソース(Apache License)、3Delight は無償利用枠があります。

ライセンス

MIT License

教育目的での利用・改変・再配布を歓迎します。レガシーレンダラーの活用や
レンダリングパイプライン自作のヒントになれば幸いです。

githubで公開

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?