Those are basic GL concepts, I could try to explain everything that but that will take too long, I suggest you to look at modern OpenGL books and tutorials (opengl version 3.3 and 4.x). You need to be strong in those concepts before you ever start writing a geometry shader that write to multiple streams :/
When GPU draws triangles on the screen it does nothing more than writing color values in "pixels" and Depth values in a Zbuffer (well that's not precise, nowadays all thos values are wrote to a framebuffer object)
The reason why if you render a box behind a wall you don't see the box is because of Z test. Basically each frame the Zbuffer is resetted. Each pixel of each primitive, performs a Z test (if Z testing is enabled!), if test fails the pixel is not drawn and some computations are skipped. If test succed the pixel is drawn and a new color and Z value are drawn.
When Z testing is enabled rendering order is not important: objects appears in correct order because nearest objects will "overwrite" farest objects, and farest objects will not overwrite nearest objects.
Occlusion query allows to query GPU for occlusion => You rendered a box behind a patch of gras and you want to know how much % of the box is visible. The occlusion query allows to know how much pixels are occluded (not rendered because Z test failed). This is a simple task for the GPU but even the most complex physics engine can't do that efficiently. However occlusion query may not be enough for selecting single vertices (most notable use of occlusion query is to show lens flares when sun is visibile in videogames).
To assign the index of each vertex to the vertex itself you just need to add the index as vertex attribute
Vertices are made of "components" each component have arbitrary values (usually values that make sense to you. not to the GPU)
The type and value is totally free and dependent only on your needs, for example instead of using 3x32bit floating points for position, you could use a 3x16bit integer if your model is made of cubes, this is up to you.
Since every 3D model is made by vertices that are stored in a buffer, those vertices have a implicit index. You must tell to the GPU wich vertices to pick for each triangle,
Example (a quad made by 2 triangles => each triangle have 3 vertices, but there are only 4 totale vertices)
| \ |
| \ |
| \ |
... Since attributes to vertices are totally custom instead of providing a "Vertex Color", you could provide a "Vertex Index" so that when vertex is wrote to a stream who will read the stream will know wich vertex that was. but that's just because you'll need it.
For visible vertices look also at here: https://www.opengl.org/discussion_boards/archive/index.php/t-183434.html
Don't ask my opinion about Unity3D.. here it is !
- Big middle finger to AAA engines, indies team spreaded the word
- Then license price increase, big middle finger to indie teams too
- They integrated third-party ads, they have analytics, and missing their own ad network, missed opportunity of a big middle finger to advertising services.
A Good tool, with a bad marketing.