Can you pass a fixed-size array as a parameter to the GLSL function?

In the GLSL shader, I want to create a function that looks something like this:

void MyFunction(out float results[9]) { float value0 = 3.1546; float value1 = 42; // whatever value /* ... long, complicated code ... */ results[0] = value0; results[1] = value1; results[2] = value2; ... } 

Is it possible to use and compile such a function signature in GLSL?
If not, are there any alternatives?

+6
source share
1 answer

Yes, this is legal GLSL code.

This does not mean that it will compile, but it is a legal code. In this case, it is probably better to simply return the array (which you can also do), and not pass it as an output parameter.

+5
source

Source: https://habr.com/ru/post/945556/


All Articles