processing4 icon indicating copy to clipboard operation
processing4 copied to clipboard

Can't pass a 3D integer array into a GLSL shader

Open Lightning323 opened this issue 3 years ago • 4 comments

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?

Lightning323 avatar Oct 22 '22 22:10 Lightning323

I don't think the OpenGL specification allows this. Can you tell what the 3D int array represents?

clankill3r avatar Dec 12 '22 08:12 clankill3r

It represents a 3d lightmap for my voxel game.

Lightning323 avatar Dec 12 '22 18:12 Lightning323

Maybe it's possible to pass with PVector ? and after cast each value like highp int index = int(indexf);

knupel avatar Dec 13 '22 07:12 knupel

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.

somecho avatar Apr 24 '23 18:04 somecho