Hi BJS team
I’m implementing a GIS (Geographic Information System).
In this GIS, there are several layers, each one using a unique depth. (ex: tiny roads, highway, railway line, …). A lot of work has already been done, BJS is a great tool
Each layer is represented by a single BJS Mesh. All of these meshes are rendered using custom GLSL shaders (custom AA lines, signed distance fields for texts, …). Some information is passed using VBOs (setVerticesData), other using TBOs (RawTexture in BJS). To order all of these layers, I modify the alphaIndex of the meshes and send appropriate uniform values. All of these stuff cohabit very well.
Now, I would like to duplicate part of my geometry using instances (for performance reason). For this, I’m using BJS 4.1.0 beta 1.
- To create instances, I call myMesh.createInstance().
- I fill some TBOs containing instance meshes related stuff (position, rotation, custom info, …)
- I fill an “instanced” VBO containing the instance ID using myMesh.instancedBuffers.objID (useful to fetch corresponding info in the TBOs).
- I configure meshes params:
instance.alwaysSelectAsActiveMesh = true;
instance.hasVertexAlpha = true;
instance.doNotSyncBoundingInfo = true;
I managed to make instance rendering working. The instanciated meshes are drawn in the right place, with the right orientation, … However, I get some troubles with the depth of my instanciated meshes. Whatever the method I use, I can not set properly the depth of my instanciated meshes. I tried with uniforms, and even by forcing the depth in my shader.
I already use this way of thinking in OpenGL 3.3+ without any particular problem. Therefore, I’m wondering if there is a WebGL limitation or a BJS overlay that prevent me to do this kind of things ?