「MonoGameで遅延レンダリングをする」の版間の差分
ナビゲーションに移動
検索に移動
Administrator (トーク | 投稿記録) (ページの作成:「2020年4月時点のMonoGameではマルチプルレンダーターゲットが正常に動かない。 このためXNA時代に書かれたマルチプル…」) |
Administrator (トーク | 投稿記録) |
||
8行目: | 8行目: | ||
clear(color, normal, depth); | clear(color, normal, depth); | ||
draw(color, normal, depth); | draw(color, normal, depth); | ||
− | + | ||
// 以降は同じ | // 以降は同じ | ||
light = lighting(color, normal, depth); | light = lighting(color, normal, depth); |
2020年4月8日 (水) 04:54時点における最新版
2020年4月時点のMonoGameではマルチプルレンダーターゲットが正常に動かない。
このためXNA時代に書かれたマルチプルレンダーターゲットを使った遅延レンダリングのサンプルプログラムをそのまま動かそうとすると残念なことになる。
概要[編集 | ソースを編集]
XNAの教科書に載っている遅延レンダリングの実装例ではマルチプルレンダーターゲットを利用して2回のドローコールで前半部分を済ませているのが一般的である。
// この2つ clear(color, normal, depth); draw(color, normal, depth); // 以降は同じ light = lighting(color, normal, depth); final = combine(light, color);
一方、MonoGameではこの部分を6回ものドローコールに分割する必要がある。
clear(color); draw(color); clear(normal); draw(normal); clear(depth); draw(depth); // 以降は同じ light = lighting(color, normal, depth); final = combine(light, color);
それでもポイントライトなどが数十から数百も存在するという状況では圧倒的にドローコールを削減できる。
実装例[編集 | ソースを編集]
後ほどgithubにアップする。