I am experimenting with how much I can push the GPU with clever optimizations and correct use of hardware, so I know this may lag my computer a lot, that's not the issue.

Currently my goal is as follows:

Define a variable size structure (i.e an array) that contains floats, every 3 floats define a position vector, every 9 define a triangle.

I need to create an array of these structures (the array of all shadow casting objects currently loaded) and pass the array to the GPU (the glsl shader).

If I follow a couple of conventions when putting my data into this format I can use hashing to get an amortized constant search time for the shadow casting triangles,

The issue is to get the data into the format that I need. If this was C++ the format would be an array of vectors and we're done, but GLSL is not as good at managing memory, does somebody know a way to pass the information in the fashion I described, or am I trying to do something that can't be done?

  • \$\begingroup\$ so what's wrong with dynamic usage of vertex buffers? \$\endgroup\$
    – Sidar
    Jan 14, 2018 at 22:12
  • \$\begingroup\$ They are one dymensional and of constant stride, what I am suggesting requires the innermost dymension of the vertex array to be of varying size 9i'e each entry of the outermost array changes size) This is the differnece between a 2D array and an array of vectors in C++, one can be iterated through column major order, the other one needs to store the dimension of each entry \$\endgroup\$
    – Makogan
    Jan 14, 2018 at 22:31
  • \$\begingroup\$ Could you not upload a separate buffer that gives the offset of the first entry of each "column"? Then you can translate a 2D index into an index into the flat float array with one extra lookup. \$\endgroup\$
    – DMGregory
    Jan 14, 2018 at 22:41
  • \$\begingroup\$ I was thinking of this as well, but if the arrays vary a lot (mobs for example move around), the management and overhead becomes problematic. However you are right in that, this definetely does what I need. \$\endgroup\$
    – Makogan
    Jan 14, 2018 at 22:46


You must log in to answer this question.

Browse other questions tagged .