在GLSL中,我将简单地使用out vec3 array[10];,将一个数组从顶点着色器传递到片段着色器。但是,在Metal中,我想这样做:
struct FragmentIn {
float4 position [[position]];
float3 array[10];
};
Run Code Online (Sandbox Code Playgroud)
这将产生以下错误:
Type 'FragmentIn' is not valid for attribute 'stage_in' because field 'array' has invalid type 'float3 [10]'
我该如何解决这个问题?我需要使用片段着色器将使用的每个顶点数据进行某些计算。
您需要“展开”数组:
struct FragmentIn {
float4 position [[position]];
float3 thing0;
float3 thing1;
float3 thing2;
float3 thing3;
float3 thing4;
float3 thing5;
float3 thing6;
float3 thing7;
float3 thing8;
float3 thing9;
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
456 次 |
| 最近记录: |