Attribute divisor without instancing?
Asked Answered
I

1

8

I know that glVertexAttribDivisor can be used to modify the rate at which generic vertex attributes advance during instanced rendering, but I was wondering if there was any way to advance attributes at a specific rate WITHOUT instancing.

Here is an example of what I mean:

Let's say you are defining a list of vertex positions that make up a series of lines, and with each line you wish to associate an ID. So, you create two vbos that each house the data related to one of those attributes (either all the vertex positions or all the vertex IDs). Traditionally, this means each vbo must be the size (in elements) of the number of lines X 2 (as each point contains two lines). This of course means I am duplicating the same ID value for each point in a line.

What I would like to do instead is specify that the IDs advance 1 element for every 2 elements the vertex position buffer advances. I know this requires that my vertex position buffer is declared first (so that I may reference it to tell OpenGL how often to advance the ID buffer) but it still seems like it would be possible. However, I cannot find any functions in the OpenGL specification that allow such a maneuver.

Issuant answered 18/3, 2013 at 0:12 Comment(0)
C
2

What you want is not generally possible in OpenGL. It's effectively a restrained form of multi-indexed rendering, so you'll have to use one of those techniques to get it.

Crenshaw answered 18/3, 2013 at 2:19 Comment(2)
Is it possible to use glMultiDrawArraysIndirect() in this case to draw the line one segment at a time, use attribute divisor 1 over the ID VBO and use the baseIndex part of indirect command structure to increment the index per draw in ID VBO? This'll probably stuff more data in GPU memory but in theory would be possible?Armijo
It would work for that specific case, but not in general.Crenshaw

© 2022 - 2024 — McMap. All rights reserved.