Graphics.Blit

    xiaoxiao2021-03-25  210

    参考:官方文档

    https://docs.unity3d.com/ScriptReference/Graphics.Blit.html

    public static void Blit(Texturesource,RenderTexture dest);

    public static function Blit( source: Texture, dest: RenderTexture, mat: Material, pass: int = -1): void; public static void Blit( Texture source, RenderTexture dest, Material mat, int pass = -1); public static function Blit( source: Texture, mat: Material, pass: int = -1): void; public static void Blit( Texture source, Material mat, int pass = -1); 需求注意第4个参数,用4个参数pass用于指定使用哪一个pass。默认值为-1,即使用所有的pass。

    Description

    Copies source texture into destination render texture with a shader.

    This is mostly used for implementing image effects.  主要用于做后期特效(post-effect) Blit sets dest as the render target, sets source _MainTex property on the material, and draws a full-screen quad.

    用Render Texture实现画面特效的核心过程:

    在脚本中检查当前平台对特效的支持;通过OnRenderImage()函数抓取render texture,再通过Graphics.Blit()函数传递给虚拟材质中的Shader进行后处理;Shader的_MainTex即为接收到的render texture,在frag函数里对图像进行逐像素处理后再返回给OnRenderImage函数,得到最后的屏幕画面。

     
    转载请注明原文地址: https://ju.6miu.com/read-2018.html

    最新回复(0)