Geometry Instancing

A couple of small utility classes that can be useful when for geometry instancing has been added to jME (scenegeometryinstancing). TestGeometryInstancing (jmetestscenegeometryinstancing) demonstrates some of the functionality.  :lol:

The idea behind geometry instancing is to combine instances of static objects (with small number of triangles, that has the same render state) into larger batches. This lowers the number of draw calls needed, which removes stress from the CPU. The negative effect of combining batches is that culling can’t be performed on the individual instances. For example when drawing a number of cubes (12 triangles /  8 vertices each), the CPU will spend more time on the draw calls, than the GPU spend on rendering, which means the application is CPU-bound, and the GPU is idle for very long periods. If the cubes are combined to a single batch, the number of draw calls will be fewer and the result is higher frame rate and a better utilization of the GPU.

Comments on the added classes are most welcome  :smiley:

Note: Combining batches with different textures, can be done using a texture atlas.

Links (additional reading):

Batching (nvidia):

Texture atlas (nvidia):

sounds interesting.

initially i thought it has something to do with mr coder's vegetation implementation :slight_smile:

It has something to do with my vegetation implementation :smiley:

Isn't the titel misleading?

I also thought geometry instancing is another thing and thought on vegetation or rocks eg… See page 22 .

You have one mesh, one draw call but # different instances (texture, color, transformation).

And i think batching is a bit different, right?

Of course I may be wrong…

My definitions was:

Batching = compounding objects to larger batches

Geometry instancing = rendering multiple unique instances of same geometry (GPU gems 2)

There are different techniques to render multiple instances of the same object, depending on what kind of objects you have (static, moving, skinned, etc).

The method I have implemented is suited for static objects. It duplicates vertex data, and pre-transforms the geometry. Another method is to use vertex constants to save attributes (transformation, color etc) for the instances in the graphics memory. Every vertex get an additional index to be able to read the correct attributes in the vertex shader. The objects attributes can easily be changed to move the objects (the vertex buffers does not need to be updated). The hardware Geometry Instancing API (in DirectX), does this without duplicating the vertex memory.

I think there is a thin line, where batching becomes geometry instancing… :slight_smile:

Sp you definitions is the same as i would say. ^^

Snylt said:

I think there is a thin line, where batching becomes geometry instancing... :)

I do think the same...

It was just a comment. ^^

Since quite recently, OpenGL has the extension GL_EXT_draw_instanced which allows multiple renderings of the same mesh with different transforms in the same manner as DirectX. LWJGL seems to have support for it, but it only works on the very latest generation of hardware (Geforce 8 series only atm). It would be pretty cool if the new geometry instancing classes would use the extension if available instead of duplicating the data though. Anyone up for the task? cough Naturally, I would volunteer myself, but I don't have a GF8 card yet.  :wink:

I would get it done in 5 minutes if somebody bought me a GF 8800 :smiley:

Isn't it available on a lower card than 8800?