OpenGL ES 2.0 doesn’t have support for either gl_InstanceID or glDrawElementsInstanced. Then inside the vertex shader you can use that value to reference shader constants and read the required data to transform that particular mesh instance. There are various approaches but the basic idea is to have the hardware reissue the mesh list N times, while at the same time incrementing a value in the shader called gl_InstanceID. Other APIs (including big brother OpenGL since version 3.1, and ES since version 3.0) work around this issue by using a feature called instancing. In plain OpenGL ES 2.0 there is no way to draw a single mesh N times, with N different transforms, in a single draw call. Unfortunately changing the transform implies a draw call. To make it look nice you want to give each mesh its own transform you have complete freedom on where to locate or rotate it. For example a grass mesh, or maybe some weird alien equivalent. Say that you want to repeat a mesh, many times, in a 3D scene. Modern GPUs, including those in smartphones, are very powerful and properly optimized have enormous throughput. One of the things I wanted to do was put a lot of detail on the planet surface. We wanted to do a game about planet exploration and colonization, with randomly generated maps. The first prototype of what became The Spatials was in full 3D. Faking mesh instancing in OpenGL ES 2.0 14 August, 2014
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |