Graphics.Blit

参考:官方文档

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实现画面特效的核心过程:

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




  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值