Version: 2021.3
public void SetFloats (string name, params float[] values);
public void SetFloats (int nameID, params float[] values);

参数

name 该着色器代码中的数组变量名称。
nameID 属性名称 ID,使用 Shader.PropertyToID 获取。
values 要设置的值数组。

描述

一次性设置多个连续 float 参数。

This function can be used to set float vector, float array or float vector array values. For example, float4 myArray[4] in the compute shader can be filled by passing 16 floats. See Compute Shaders for information on data layout rules and cross-platform compatibility.

This API feeds raw data to the constant buffer, so the provided data must follow the HLSL constant buffer data layout rules. This means that the the array elements must be aligned on float4; for example, float4 data requires no padding, float3 data needs one float padding for each element, float2 data needs two floats, and so on.

在一个计算着色器资源中,常量缓冲区在所有内核之间共享。因此,此函数会影响该 ComputeShader 中的所有内核。

另请参阅:SetFloatSetIntSetIntsSetBoolSetBufferSetMatrixSetMatrixArraySetTextureSetVectorSetVectorArray