Version: 2023.2

Shader.SetGlobalConstantBuffer

切换到手册
public static void SetGlobalConstantBuffer (string name, ComputeBuffer value, int offset, int size);
public static void SetGlobalConstantBuffer (int nameID, ComputeBuffer value, int offset, int size);
public static void SetGlobalConstantBuffer (string name, GraphicsBuffer value, int offset, int size);
public static void SetGlobalConstantBuffer (int nameID, GraphicsBuffer value, int offset, int size);

参数

nameID The name ID of the constant buffer retrieved by Shader.PropertyToID.
name 要覆盖的常量缓冲区的名称。
value The buffer to override the constant buffer values with, or null to remove binding.
offset Offset in bytes from the beginning of the buffer to bind. Must be a multiple of SystemInfo.constantBufferOffsetAlignment, or 0 if that value is 0.
size 要绑定的字节数。

描述

Sets a ComputeBuffer or GraphicsBuffer as a named constant buffer for all shader types.

请参阅 Material.SetConstantBuffer 以了解用法。如果常量缓冲区同时进行了全局绑定和每材质绑定,则使用每材质缓冲区。但如果常量缓冲区进行了全局绑定,它将覆盖驻留在具有给定名称的任何常量缓冲区内的所有材质中的所有着色器参数。使用此函数时需十分谨慎,尤其是在使用常用的常量缓冲区名称时,因为可能会产生意外效果。