rendering crowds in OpenGL with VBOs -
i'm trying render large number of copies of same mesh in opengl. know can use small vertex buffer index buffer, each copy have it's own transformation matrix. want pass each matrix shader, vertices belonging same copy use same matrix. therefore, matrix buffer shorter vertex buffer.
the mesh has 4 vertices, need somehow send new matrix every 4 vertices. ideas?
you use instanced rendering: https://www.opengl.org/sdk/docs/man/html/gldrawarraysinstanced.xhtml
or
https://www.opengl.org/sdk/docs/man3/xhtml/gldrawelementsinstanced.xml
you can create vbo filled transformation matrices each index.
set divisor 4 matrix changes after 4 vertices have been sent:
https://www.opengl.org/sdk/docs/man3/xhtml/glvertexattribdivisor.xml
you can use gl_instanceid in vertex shader figure out instance being rendered, , can generate transformation matrix way rather sending every transformation matrix shaders.
Comments
Post a Comment