processing4
processing4 copied to clipboard
Can't pass a 3D integer array into a GLSL shader
I have been working on a shader project, and I need to be able to use PShader.set() to pass a 3D array of integers into my GLSL shader, however I can't do it because Processing PShader.set() does not allow me to send multidimensional arrays of any kind
I tried all of the present set() methods that they have, and none work. It seems you only allow sending 1D arrays. I cannot find any way of sending a 3D int array as a uniform into my GLSL shader.
Any help?
I don't think the OpenGL specification allows this. Can you tell what the 3D int array represents?
It represents a 3d lightmap for my voxel game.
Maybe it's possible to pass with PVector ? and after cast each value like highp int index = int(indexf);
Lightmaps are usually sent as a textures to a shader.
With regards to multidimensional uniforms, you can, at maximum send two dimensional data in a flattened format to the shader. I.e. if you want to send [[x1 y1][x2 y2] to the shader, you'd have to send it as [x1 y1 x2 y2]. In the shader, you'd reference this data with uniform vec2 pts[2]. Note that the size of the data must be known at compile time.