简体   繁体   English

金属着色器中的数组声明

[英]Array declaration in metal shader

It is possible to use array in GLSL like this:可以像这样在 GLSL 中使用数组:

float[4](.5, .5, .5, .5)

Is it possible to use arrays in metal shader, if yes how can I declare it?是否可以在金属着色器中使用 arrays,如果可以,我该如何声明它? Thanks!谢谢!

It works almost like in c++:它的工作方式几乎与 c++ 中的一样:

float array[3] = float[3](0.5,0.5,0.5);
float array[3] = float[3](0.5);// also works, but you can't initialize the entire array with that number, it's going to be (0.5,0.0,0.0)

see: https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Arrays参见: https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Arrays

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM