Passing an array as parameter to shader



There is any way to pass an array as a parameter to a shader? I need to pass an array of vec3, but I could not make it work.



Does it work if you specify a matrix type? A matrix should be a set of multiple vec types


I could not, I even tried to pass a float array but all the values are 0 within the shader.


How should I pass the parameters? I tried:

var param:ShaderParameter<Array> = new ShaderParameter<Array>();

How can I set the ShaderParameterType.MATRIX3X3?


Ah, I forgot. We parse your GLSL shader source code, and generate a Shader instance based on that. As a result, it works something like…


attribute vec4 myVec;

Parameter = [ 0, 1, 2, 3 ];

I think it’s possible it would work like this, then, for matrices


attribute mat4 myMat4;

Parameter = [ 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3 ];

Here is where we parse the GLSL source to assign parameter types:


Mmmm I can´t make that work. This feature is avalable for all platforms? I’m porting to HTML5.


To my knowledge, it should work for HTML5 as well as other targets. We use for our core display shader internally.

However, it is possible to define GLSL shaders using shader.glFragmentSource = "(source)"; as well as extending openfl.display.Shader and using @:glFragmentSource in meta-data. Using the meta-data / extended class approach allows this macro to run, so perhaps that is necessary for this to work as intended.


I can not make it work with either of the two approaches :frowning: