Quantcast
Viewing all articles
Browse latest Browse all 40524

Is it possible to pass a list of arrays to a shader Frag

Hi,

Not 100% sure I'm following, but you can pass ofShader an array of vec2 using setUniform2fv

In your shader you would have something like

#define MAX_ITEMS 5
uniform vec2 myData[MAX_ITEMS ]

And in your c++

ofVec2f someStuff[5];
...
myShader.setUniform2fv("myData", &someStuff[0].x, 5 );

Or alternatively myShader.setUniform2fv("myData[0]", &someStuff[0].x, 5 ); if that doesn't work. (I'm on a mongrel OF version )

There will be a limit to the size of what you can send over this way though. If you need to send large amounts of data you want OpenGL 4.5 and ofBufferObject, with this combo you can send up large buffers to the GPU that you can read and write to from shaders and it's fucking amazing.


Viewing all articles
Browse latest Browse all 40524

Trending Articles