PDA

View Full Version : general scheme of 3d geometry storage and usage in OpenGL or DirectX



fir___
12-21-2015, 03:10 PM
I know OpenGL only slight and all this docs and tutorials are damn hard to read so i do not helps.. I got some vision though how it could work and only would like some clarification or validation of my vision

I assume 3D world is build from 3d meshes, each mesh may be hold in some array or few arrays (storing the geometry for that mesh).. I assume also that some meshes may be sorta like cloned and used more than once on the scene.. So in my wision i got say 50 meshes but some of them are used more than once... Lets say those clones i would name as a instance of a mesh (each mesh may have 0 instances, 1 instance or more instances)

Is this vision okay? Some more may be added?

I understand that each instance should have its own position and orientation, so do we have some array of instances each element containing one pos-oriantation matrix? or thiose matrices only existing in the code branches (you know what i mean, i set such matrix then send a mesh then modify this position matrix then send the mesh again till all instances are sent) ?

Do this exhaust the geomety (non-shader) part of the things? (then shaders part come which i also not quite understand, there is a tremendous amount of hoax on shaders where this geometry part seem more important to me, well whatever)

Can someone validate the vision i spread here?

GClements
12-21-2015, 03:39 PM
I understand that each instance should have its own position and orientation, so do we have some array of instances each element containing one pos-oriantation matrix? or thiose matrices only existing in the code branches (you know what i mean, i set such matrix then send a mesh then modify this position matrix then send the mesh again till all instances are sent) ?

Both options exist.

You can either make one draw call per instance, setting the appropriate variables before each call, or you can use instanced rendering (glDrawElementsInstanced() etc) along with glVertexAttribDivisor() to make a particular attribute per-instance rather than per-vertex.

The latter is more efficient in the cases where it can be used, the former is more general as you can modify other OpenGL state between draw calls.