Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

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

$
0
0

Hi!

Like @hahakid said, if you want to pass a lot of values, you should work with ofBufferObject. You can check an example in examples/gl/textureBufferInstancedExample.

If you want to set an array as an uniform, you should keep it low in terms of length. I usually don't go higher than 16.

I do it like this, ofApp.h:

static const int arrayLength = 16;
float yourArray[arrayLength];

You assign whatever values you want, and then:

shader.setUniform1fv("uniArray", yourArray, arrayLength);

And on your fragment shader, you declare it like so:

uniform float uniArray[16];

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>