Instancing

Mar 13, 2012 at 7:27 PM

Hello, could someone experienced in Hieroglyph provide a quick guide on how to render instanced geometry via Hieroglyph's interface, please? Thanks 

Coordinator
Mar 14, 2012 at 12:29 AM

The only place that uses instancing currently is the text rendering system (SpriteRendererDX11).  Take a look at this class and see if that shows a decent example of what you are looking for.  If not, then if you can describe what you want to do, then I can probably whip up another actor class to represent instanced geometry and have your stuff automatically collected and rendered.

Mar 14, 2012 at 11:17 AM
Edited Mar 14, 2012 at 2:06 PM

Thank you, Jason. I'll take a look at it. I would like to implement terrain LOD mechanism based on a quadtree of the same sized regular grids:

quadtree

So I figured out that it would be nice to load the grid to a vertex buffer just once and use the instancing to render all "chunks" (which differs only in position and scale). Is instancing a correct approach or there is a better way how to do this in Direct3D? Would it be difficult to tweak Hieroglyph to support this?

Thanks in advance.

Coordinator
Mar 14, 2012 at 11:21 PM

It certainly sounds like an interesting use of instancing.  Due to the repeated nature of the grid, instancing would be an ideal way to get the data into the pipeline.  The only down side would be that you need to update the attribute vertex buffer (holding the position and scale data) any time the LOD of a particular grid updates.

To make that work nicely with Hieroglyph, you would create a class similar in nature to the GeometryDX11 class.  This class would create the necessary buffers, and manage their contents - so updating the buffers according to LOD would be done here.  It will also implement the PipelineExecutorDX11 interface (as GeometryDX11 does), with the ::Execute(...) method providing the draw calls.  In your case, you would just use one of the draw instanced methods of the PipelineManagerDX11 class to execute the pipeline properly.

Once the class is implemented and ready to go, you just need to set an instance of the class in an Entity3D using the ::SetGeometry() method, and the corresponding material class would also need to be set.  Then the entity could be rendered as any other entity is in the other sample programs.

Give it a shot, and if you have trouble then feel free to post about it here - it would serve as a good wiki entry about creating customized geometry classes!

Apr 12, 2012 at 6:30 PM

After some additional research, I've decided to use the approach from nVidia's terrain tessellation demo (NVIDIA graphics SDK 11). The method described by nVidia is using instancing to get the terrain-tiles into the pipeline (so it probably really makes sense:-)). The method also takes advantage from DX11 tessellation stages, that really improves visual quality of the terrain. 

I'll try to implement this functionality in the way you suggested and once there will be some nice output, I'll post a video here or create some related wiki-page.