   Geometry Instancing questions
  So, I implemented geometry instancing with Direct3D 9, and next is to get it working with OpenGL.I've tried searching for more information, and all I have found so far is to use glDrawElementsInstancedEXT.I was wondering if anyone who has implemented this or knows about it might be able to give me more information, or a site that has more information.In Direct3D 9, essentially you set more than one vertex buffer, the first with the actual geometry and the second with the per instance data. Does it work the same way with OpenGL? If it does, I'm not really sure how it would work currently, so if someone has more details, that would help as well.I also read somewhere about needing to use the geometry shader (it didn't go into detail, just a brief statement I think). I've never used a geometry shader, so I'm not sure how I would do that as well. (assuming I would need to)Essentially, if anyone has more information in anything of these categories, that would be greatly appreciated.   
  Might want to check out this old thread.I think the consensus is that instancing doesn't really provide any benefit to OpenGL like it does with D3D due to the way it is organized. Calling glDrawElements is very cheap compared to an equivalent D3D operation. Read the link for the full story.   ;  Thank you for the information.I've read that about opengl, and witnessed it when drawing 1024 light volumes compared to direct3d 9. I just wasn't sure if opengl would benefit any from instancing I suppose.If anyone has any information on implementing it, I still might want to try it to see what it can give me. Although now I suppose it's less of a priority.   ;  The best way is to use a TextureBuffer, available with the gpu4 extension (same u need for glDrawElementsInstancedEXT).Such buffer u can be bound as a texture and it's data can be fetch in a shader where it behaves like a 1D Texture.So what u should do for instancing is, u put all your instance data in such buffer(ModelMatrix ... other parameter).And then in the Vertex shader u access the bound buffer as a texture and get your instance data by offseting in the buffer with "gl_instance".to creat such buffer:glGenBuffers(1, tbo);glBindBuffer(GL_TEXTURE_BUFFER_EXT, *tbo);glBufferData(GL_TEXTURE_BUFFER_EXT, size, 0, GL_DYNAMIC_DRAW); glGenTextures(1, tex);glBindTexture(GL_TEXTURE_BUFFER_EXT, *tex);glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, *tbo);glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);to change buffer data:glBindBuffer(GL_TEXTURE_BUFFER_EXT, tbo);glMapBuffer(GL_TEXTURE_BUFFER_EXT, GL_WRITE_ONLY);glUnmapBuffer(GL_TEXTURE_BUFFER_EXT);glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);in the shader u need :uniform samplerBuffer tboSampler;float pixel = texelFetchBuffer(tboSampler, position of data).rand when drawing the only thing u need to do is to bind the texture to GL_TEXTURE_BUFFER_EXTand draw using your shaderPS:with the geometry shader it's possible to "render" in a vertexbuffer which can be used for GPGPU stuff like GPU particles.   ;Quote:Original post by Danny02The best way is to use a TextureBuffer, available with the gpu4 extension (same u need for glDrawElementsInstancedEXT).Such buffer u can be bound as a texture and it's data can be fetch in a shader where it behaves like a 1D Texture.So what u should do for instancing is, u put all your instance data in such buffer(ModelMatrix ... other parameter).And then in the Vertex shader u access the bound buffer as a texture and get your instance data by offseting in the buffer with "gl_instance".to creat such buffer:glGenBuffers(1, tbo);glBindBuffer(GL_TEXTURE_BUFFER_EXT, *tbo);glBufferData(GL_TEXTURE_BUFFER_EXT, size, 0, GL_DYNAMIC_DRAW); glGenTextures(1, tex);glBindTexture(GL_TEXTURE_BUFFER_EXT, *tex);glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, *tbo);glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);to change buffer data:glBindBuffer(GL_TEXTURE_BUFFER_EXT, tbo);glMapBuffer(GL_TEXTURE_BUFFER_EXT, GL_WRITE_ONLY);glUnmapBuffer(GL_TEXTURE_BUFFER_EXT);glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);in the shader u need :uniform samplerBuffer tboSampler;float pixel = texelFetchBuffer(tboSampler, position of data).rand when drawing the only thing u need to do is to bind the texture to GL_TEXTURE_BUFFER_EXTand draw using your shaderPS:with the geometry shader it's possible to "render" in a vertexbuffer which can be used for GPGPU stuff like GPU particles.Thanks for that example. I'm going to try and get that implemented as well.I was also looking for an approach as similar to what I had implemented in Direct3D9/10/11, and eventually I was able to find something.For anyone who might be wondering the same thing, here is essentially what I did:All semantics that are needed used:glEnableVertexAttribArray(semanticIndex);glVertexAttribPointer(...);So for all semantics that are per  object, I had to do:glVertexAttribDivisorARB( semanticIndex, 0 );For all semantics that are being used for per instance information, I did:glVertexAttribDivisorARB( semanticIndex, 1 );Then called:glDrawElementsInstanced(...);which is essentially glDrawElements(...) but with an extra parameter for how many instances.Then once I was done with the call, I reset the divisor data to:for (int i = 0; i < 16; i++)    glVertexAttribDivisorARB( i, 0 );I'm using GLEW and I believe I needed the 197.44 drivers from nVidia (the ones that support OpenGL 3.3/4.0). I can't exactly remember if I needed to do that, but glVertexAttribDivisor/ARB didn't seem to work with GLee (didn't set the divisor properly), so I installed them just in case and started using GLEW to test a v3.3 context.Also, using this instancing method, I get similar results as using D3D9; however, this isn't really saying much because it took D3D9 maybe 5ms to render 1000 quads where it took OpenGL 1.2ms, if that, to render the same 1000 quads. They are both around .06ms now, or so it seems by my rough estimates.Anyway, thanks for everyone's help and hope this helps someone as well.   ;  good spot didn't know that function.This function is properly even better then my suggestion   