Version: 2020.3
public void SetTexture (int kernelIndex, string name, Texture texture);
public void SetTexture (int kernelIndex, int nameID, Texture texture);
public void SetTexture (int kernelIndex, string name, Texture texture, int mipLevel);
public void SetTexture (int kernelIndex, int nameID, Texture texture, int mipLevel);
public void SetTexture (int kernelIndex, string name, RenderTexture texture, int mipLevel, Rendering.RenderTextureSubElement element);
public void SetTexture (int kernelIndex, int nameID, RenderTexture texture, int mipLevel, Rendering.RenderTextureSubElement element);

参数

kernelIndex 当前为其设置纹理的内核。请参阅 FindKernel
nameID 属性名称 ID,使用 Shader.PropertyToID 获取。
name 着色器代码中的缓冲区变量的名称。
texture 要设置的纹理。
mipLevel 读写纹理的可选 Mipmap 级别。
element Optional parameter that specifies the type of data to set from the RenderTexture.

描述

设置纹理参数。

此函数可设置在 计算着色器中读取的常规纹理,或者设置由该着色器写入到的输出纹理。 对于输出纹理,其必须是启用了随机写入标志的 RenderTexture, 请参阅 RenderTexture.enableRandomWrite

请注意,除非着色器指定了读写(无序访问)纹理,否则将忽略 mipLevel 参数。

缓冲区和纹理按内核逐一设置。可使用 FindKernel 按函数名称查找内核索引。

By specifying a `RenderTextureSubElement`, you can indicate which type of data to set from the RenderTexture. The possible options are: RenderTextureSubElement.Color, RenderTextureSubElement.Depth, and RenderTextureSubElement.Stencil.

另请参阅:FindKernel,另请参阅:SetFloatSetFloatsSetIntSetIntsSetBoolSetBufferSetMatrixSetMatrixArraySetVectorSetVectorArrayRenderTexture.enableRandomWriteRenderTextureSubElement

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961