Physically Based Rendering のインストール(GitHub の mmp/pbrt-v4 を使用,Windows 上)

【概要】Windows環境においてGitHubのmmp/pbrt-v4リポジトリからPhysically Based Renderingをインストールする手順を解説する。Visual Studio Build Tools、Git、CMakeの準備から、ビルド、環境変数の設定、動作確認までを含む。

【目次】

  1. 前準備(Git、CMake、マイクロソフト C++ ビルドツール等のインストール)
  2. GitHubのmmp/pbrt-v4のインストール
  3. 試しにレンダリングを行ってみる

前準備

Build Tools for Visual Studio 2026 のインストール(Windows 上) [クリックして展開]

Build Tools for Visual Studio は,Visual Studio の IDE を含まない C/C++ コンパイラ,ライブラリ,ビルドツール等のコマンドライン向け開発ツールセットである。インストール済みの場合、この手順は不要である。

管理者権限コマンドプロンプトで以下を実行する。管理者権限のコマンドプロンプトを起動するには、Windows キーまたはスタートメニューから「cmd」と入力し、表示された「コマンドプロンプト」を右クリックして「管理者として実行」を選択する。

REM VC++ ランタイム
winget install --scope machine --id Microsoft.VCRedist.2015+.x64 -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/quiet /norestart"

REM Build Tools + Desktop development with C++(VCTools)+ 追加コンポーネント(一括)
winget list --id Microsoft.VisualStudio.BuildTools 2>nul | findstr /i "BuildTools" >nul 2>&1
if %ERRORLEVEL% EQU 0 (
    for /f "delims=" %P in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -products * -property installationPath') do start /wait "" "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" modify --installPath "%P" --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.Windows11SDK.26100 --includeRecommended --quiet --norestart
) else (
    winget install --scope machine --id Microsoft.VisualStudio.BuildTools -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "--quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.Windows11SDK.26100"
)
REM  何らかの理由で BuildTools の動作がおかしくなった場合は,以下を実行すると,既存のインストールのファイル破損・欠損を修復し正常な状態に復元する効果がある.
REM "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" repair --installPath "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools" --quiet --norestart
REM 以下で正常であることを確認する.パスが表示されれば正常である.
REM "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -products * -requires Microsoft.VisualStudio.Workload.VCTools -property installationPath

--add で追加されるコンポーネント

上記のコマンドでは,まず Build Tools 本体と Visual C++ 再頒布可能パッケージをインストールし,次に setup.exe を用いて以下のコンポーネントを追加している。

インストール完了の確認

winget list Microsoft.VisualStudio.BuildTools

上記以外の追加のコンポーネントが必要になった場合は Visual Studio Installer で個別にインストールできる。

Visual Studio の機能を必要とする場合は、追加インストールできる。

Git のインストール(Windows 上) [クリックして展開]

管理者権限コマンドプロンプトで以下を実行する.管理者権限は,winget の --scope machine オプションでシステム全体にインストールするために必要となる.

REM Git をシステム領域にインストール
winget install --scope machine --id Git.Git -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=""icons,ext\reg\shellhere,assoc,assoc_sh"" /o:PathOption=Cmd /o:CRLFOption=CRLFCommitAsIs /o:BashTerminalOption=MinTTY /o:DefaultBranchOption=main /o:EditorOption=VIM /o:SSHOption=OpenSSH /o:UseCredentialManager=Enabled /o:PerformanceTweaksFSCache=Enabled /o:EnableSymlinks=Disabled /o:EnableFSMonitor=Disabled"

CMake のインストール

CMake の公式ダウンロードページ: https://cmake.org/download/

GitHubのmmp/pbrt-v4のインストール

URL: https://github.com/mmp/pbrt-v4

Windowsでの手順を下に示す。Ubuntuでも同様の手順である。

  1. 以下の手順を管理者権限コマンドプロンプトで実行する (手順:Windowsキーまたはスタートメニュー → cmd と入力 → 右クリック → 「管理者として実行」)。
  2. GitHubのmmp/pbrt-v4のダウンロード

    glog、openexr、ptex、zlibが合わせてダウンロードされる。

    cd /d c:%HOMEPATH%
    rmdir /s /q pbrt-v4
    git clone --recursive https://github.com/mmp/pbrt-v4
    
    pbrt-v4のクローン実行画面
  3. CMakeの実行
    cd /d c:%HOMEPATH%
    cd pbrt-v4
    rmdir /s /q build
    mkdir build
    cd build
    cmake .. -A x64 -T host=x64
    
    CMake実行画面
  4. CMakeの結果の確認

    エラーメッセージが出ていないことを確認する。

    CMake完了画面
  5. ビルド操作、インストール操作
    cmake --build . --config Release --target INSTALL -- /m:4
    
    ビルド実行画面
  6. 結果の確認

    エラーメッセージが出ていないことを確認する。

    ビルド完了画面
  7. Windowsのシステム環境変数PATHに、c:\Program Files\PBRT-V4\binを追加することにより、パスを通す

    Windowsで、管理者権限でコマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー > cmd と入力 > 右クリック > 「管理者として実行」)する。

    次のコマンドを実行する。

    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\PBRT-V4\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    環境変数設定画面

試しにレンダリングを行ってみる

  1. Windowsでは、コマンドプロンプトを管理者として実行する
  2. GitHubのmmp/pbrt-v4-scenesのダウンロード
    cd /d c:%HOMEPATH%
    git clone --recursive https://github.com/mmp/pbrt-v4-scenes
    
    pbrt-v4-scenesのクローン実行画面
  3. レンダリングの実行
    cd /d c:%HOMEPATH%
    cd pbrt-v4
    "c:\Program Files\PBRT-V4\bin\pbrt.exe" --outfile a.png ..\pbrt-v4-scenes\killeroos\killeroo-simple.pbrt
    
    レンダリング実行画面
    レンダリング結果画像