0

I'm trying to render multiples mesh with different height on each vertices with a glDrawElementsInstancedcall.

To do so I pass the height of each vertices with a texture, but I'm hurting a huge limit, I can't pass more than 16384 float in a texture. So I thought I could use a UBO but it's limited the same way, so what should I do? Is there any other way to send a float to each vertex of each instance? Or I will have to use an other render methods?

If I have to change my render method, what would be the best replacement to keep the best performance as possible?

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • "*To do so I pass the height of each vertices with a texture*" Is there something wrong with passing the height as an attribute, presumably distinct from the XZ position attribute? Each vertex maps to a specific height, correct? – Nicol Bolas Jul 12 '19 at 02:53
  • 3
    *I can't pass more than 16384 float in a texture* I guess you can't pass more than 16384 floats in a **1D** texture. Use a 2D texture, then your limit is much higher. – BDL Jul 12 '19 at 07:51
  • @NicolBolas when using gldrawElementsInstanced I have to use the same vertices data for each instance, so I can't pass them heigh in it like I would do normaly so I have to find an other solution. – Guillaume Magniadas Jul 12 '19 at 08:06
  • @BDL Yeah, I will think about it, but I'm scared that using texture to send a lot of information could result in a non-compatibility (like my device have a limit of 16000 but someone else could only have 8000) – Guillaume Magniadas Jul 12 '19 at 08:06
  • 1
    @GuillaumeMagniadas: Since OpenGL 4.3, all graphic cards have to support 2D textures of at least 16384x16384. Since the only other option are SSBOs (which were also introduced in 4.3), you either have to limit yourself to that version or use a completely different method. – BDL Jul 12 '19 at 08:30
  • Is this basically a duplicate of https://stackoverflow.com/questions/33589784/ssbo-as-bigger-ubo? – Bartek Banachewicz Jul 12 '19 at 10:00
  • @BDL So, what would be the best solution ? Comming back to glDrawElements and having different vertices for each mesh to store the height or keeping the glDrawElementsInstanced and using an SSBO ? (in term of performance) – Guillaume Magniadas Jul 12 '19 at 10:11
  • 2
    You won't save any space nor gain any performance by using the instanced approach. You need one float per vertex in all cases. So I would use the glDrawElements approach. – BDL Jul 12 '19 at 10:14
  • @GuillaumeMagniadas: "*when using gldrawElementsInstanced I have to use the same vertices data for each instance, so I can't pass them heigh in it like I would do normaly*" ... says who? The whole point of [the attribute divisor](https://www.khronos.org/opengl/wiki/Vertex_Specification#Instanced_arrays) is to allow you to provide per-instance data which is separate from the per-vertex data. – Nicol Bolas Jul 12 '19 at 13:24
  • @NicolBolas Yes I can pass separate data to each instance but not to each vertice of each instance – Guillaume Magniadas Jul 12 '19 at 13:59

1 Answers1

1

Shader storage buffers are pretty similar to UBO's, but without the size limitations. Alternatively you could look at using 3D indexing for textures (i.e. use 2D texture arrays), or simply split the rendering into multiple chunks that fit the current maximums.

robthebloke
  • 9,331
  • 9
  • 12
  • It look to be a good solution but in term of performance it isn't just better to use another rendering method ? like a classic glDrawElement and creating the number of mesh vertices I need all with the height in their data ? – Guillaume Magniadas Jul 12 '19 at 08:08