Dynamic number of uniform blocks

Running openGL 3.1, the question is simple.

From the GLSL site, here's how to define an array of single buffer blocks:

uniform BlockName
{
  vec3 blockMember1, blockMember2;
  float blockMember3;
} multiBlocks[3];

Now, is it possible to have a dynamic number of these multiblocks? There are no pointers in GLSL, so no "new" statements, etc.

If not, is there another approach for sending a dynamic number of elements? My block currently packs four floats and one vec2.

I haven’t written shaders yet, so you can offer something, thanks;)

+3
source share
2 answers

Ok, that's why I wrote also on the openGL forum and it worked out

, 3 : .

OneSadCookie .

+1

, . , , , .

:

#define BLOCK_COUNT %d

uniform BlockName
{
    vec3 blockMember1[BLOCK_COUNT];
    vec3 blockMember2[BLOCK_COUNT];
    float blockMember3[BLOCK_COUNT];
}
multiBlocks;

BLOCK_COUNT, , :

multiBlocks.blockMember2[i];

- .

+1

Source: https://habr.com/ru/post/1785802/


All Articles