* BaseVertex and gl_VertexID

I looked at the specifications and the OpenGL forum, but couldn't figure it out:

Are the versions of the drawing commands *BaseVertex to add *BaseVertex to the GLSL gl_VertexID ? Since it works, gl_VertexID contains an index taken from the ELEMENT_ARRAY_BUFFER border before basevertex is added to it.

So my question is: is this the right behavior? I would suggest that gl_VertexID should contain the index used to extract the vertex.

+6
source share
2 answers

Yes, this is the right bahvir. The scenario for using BaseVertex is that you only need to switch one value instead of adjusting the buffer offsets in the vertex arrays using the gl*Pointer functions.

The idea is that you can load data from multiple cells (model files) into one VBO without the need to adjust indexes.

+4
source

Your guess is correct. gl_VertexID must include the BaseVertex offset.

opengl wiki about the built-in GLSL vars:

Note: gl_VertexID will have a base vertex to it.

About glDrawElementsBaseVertex:

gl_VertexID passed to Vertex Shader will be the index after the basevertex offset, not the index selected from the buffer.

Unfortunately, some older drivers did not implement it correctly.

0
source

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


All Articles