MonoGameで遅延レンダリングをする
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にアップする。