一段时间以来,Unity一直支持多个显示输出(最多8个)。
使用此ReadPixels
功能,您可以指定要读取的区域以及原点坐标。但是我无法指定显示号来执行读取操作。
我需要能够从具有特定区域和原点的特定显示器(1-8)读取像素。
请问我该怎么做?
您可以为特定的屏幕/显示实现ReadPixels。您必须执行以下操作:
在开始之前,我假设您有许多摄像机,每个摄像机都渲染到不同的显示器。摄像机必须没有附加RenderTexture才能输出到显示器。
定义一个执行以下操作的函数:
RenderTexture.active = *temporary render texture*
使当前活动的渲染纹理等于您刚才创建的一个临时ReadPixels
像素读入临时图像。这将从当前处于活动状态的读取texture2d
Rect
RenderTexture
Apply()
的texture2d
RenderTexture.active
和相机设置RenderTexture
为null
这个想法是ReadPixels可以在当前的Active RenderTexture上运行。
该代码应如下所示:
outputCam.targetTexture = outputCamRenderTexture;
RenderTexture.active = outputCamRenderTexture;
outputCam.Render ();
tempResidualTex.ReadPixels (screenRect, 0, 0);
tempResidualTex.Apply ();
RenderTexture.active = null;
outputCam.targetTexture = null;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句