MonoBehaviour.OnRenderImage(RenderTexture,RenderTexture)

切换到手册

描述

OnRenderImage 在图像的所有渲染操作全部完成后调用。

后期处理效果。

该函数让您能够使用基于着色器的过滤器对最终图像进行处理,从而修改最终图像。 传入的图像为 source 渲染纹理。结果应以 destination 渲染纹理结束。如果您重写该方法,则必须始终发出 Graphics.Blit 或渲染一个全屏四边形。

当摄像机附加了多个图像过滤器时, 它们按顺序依照下述方法对图像进行处理:将第一个过滤器的目标作为源传递给下一个过滤器,依此类推。

该消息将发送到附加到摄像机的所有脚本。

另请参阅:编写后期处理效果

using UnityEngine;

public class ExampleClass : MonoBehaviour { public Material mat;

void OnRenderImage(RenderTexture src, RenderTexture dest) { // Copy the source Render Texture to the destination, // applying the material along the way. Graphics.Blit(src, dest, mat); } }