RenderTexture
ProjectウィンドウでCreateできる
Camera の output のところに渡すと、カメラのレンダリング結果がtextureに出力されるので、マテリアルとかに使うといい。
ColorFormat がとても大事で、HDRの情報(例えばブルームとかで使う)をきちんと渡したい場合は
R16B16B16A16SFLOAT にするといける
https://answers.unity.com/questions/1702912/hdr-data-is-not-rendered-into-render-texture.html
スクリプトで動的にセットする場合は
code:foo.cs
camera.targetTexture = renderTexture;
でセットできる。
すでに他のカメラのターゲットになっているやつを別のカメラのターゲットにすると、前のやつが外れてしまうので注意する。
temporaryにつくる方法もあるが、使い分けとかは謎
https://github.com/keijiro/UnityMrtTest/blob/master/Assets/MrtTest.cs
Texture2DArray をRenderTextureにする方法が一応あるらしいけど、よくわかってない
https://docs.unity3d.com/2020.2/Documentation/Manual/class-Texture2DArray.html
Texture array elements may also be used as render targets. Use RenderTexture.dimension to specify in advance whether the render target is to be a 2D texture array. The depthSlice argument to Graphics.SetRenderTarget specifies which mipmap level or cube map face to render to. On platforms that support “layered rendering” (i.e. geometry shaders), you can set the depthSlice argument to –1 to set the whole texture array as a render target. You can also use a geometry shader to render into individual elements.