返回介绍

Graphics.Blit 位块传送

发布于 2019-12-18 15:37:44 字数 4734 浏览 1186 评论 0 收藏 0

JavaScript => public static function Blit(source: Texture, dest: RenderTexture): void;
JavaScript =>public static function Blit(source: Texture, dest: RenderTexture, mat: Material, pass: int = -1): void;
JavaScript =>public static function Blit(source: Texture, mat: Material, pass: int = -1): void;
C# => public static void Blit(Texture source, RenderTexture dest);
C# =>public static void Blit(Texture source, RenderTexture dest, Material mat, int pass = -1);
C# =>public static void Blit(Texture source, Material mat, int pass = -1);

Parameters 参数

sourceSource texture.
destDestination RenderTexture, or null to blit directly to screen.
matMaterial to use. Material's shader could do some post-processing effect, for example.
passIf -1 (default), draws all passes in the material. Otherwise, draws given pass only.

Description 描述

Copies source texture into destination render texture with a shader.

拷贝资源纹理到目的渲染纹理的主色器中。

This is mostly used for implementing image effects.

这主要是用于实现图像效果。

Blit sets dest as the render target, sets source _MainTex property on the material, and draws a full-screen quad.

Blit设置dest到渲染目标,在材质上设置source作为_MainTex属性,并且绘制一个全屏方块。

Note that if you want to use depth or stencil buffer that is part of the source (Render)texture, you'll have to do equivalent of Blit functionality manually - i.e. Graphics.SetRenderTarget with destination color buffer and source depth buffer, setup orthographic projection (GL.LoadOrtho), setup material pass (Material.SetPass) and draw a quad (GL.Begin).

注意如果你想使用资源(渲染)纹理部分的深度或模版缓存区,你必须手动做相当于位块传输功能-即,与目的颜色缓存区和资源颜色缓存区一起的Graphics.SetRenderTarget,设置正射投影(GL.LoadOrtho),安装材料(Material.SetPass)和画一个方块(GL.Begin)。

Note that in Linear color space, it is important to have the correct sRGBLinear color conversion state set. Depending on what was rendered previously, the current state might not be the one you expect. You should consider setting GL.sRGBWrite as you need it before doing Blit or any other manual rendering.

注意在线性颜色空间中,要有正确的 sRGB 线性颜色转换状态设置是很重要。当前状态可能不是你期望的那种,而是取决于预先渲染什么。在做位块传送或者其他手动渲染之前你应该考虑设置GL.sRGBWrite 作为你需要的。

JavaScript:

// Copies aTexture to rTex and displays it in all cameras.
 
	var aTexture : Texture;
	var rTex : RenderTexture;
 
	function Start() {
		if(!aTexture || !rTex)
			Debug.LogError("A texture or a render texture are missing, assign them.");
	}
 
	function Update () {
		Graphics.Blit (aTexture, rTex);
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public Texture aTexture;
    public RenderTexture rTex;
    void Start() {
        if (!aTexture || !rTex)
            Debug.LogError("A texture or a render texture are missing, assign them.");
 
    }
    void Update() {
        Graphics.Blit(aTexture, rTex);
    }
}

graphics

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文