paged geometry with hardware instancing


08-12-2013 18:28:24



paged geometry is extremely useful for my project. the standard "BatchPage" static geometry takes too much memory, however. after reading ... ter03.html, i implemented hardware instanced geometry. rather than pay instance count * mesh size in memory you only pay for the mesh once and after that it's just the cost of the per-instance data. (in this case, it supports position, orientation, scale and color packed into a 4x4 matrix)

i'm posting my implementation here incase this is useful for anyone. i'm using and have tested this with ogre 1.8.1, hlsl / directx 9, with texture shadows.

at some point in the future i'll add:
- depth shadow support
- merge in windbatch changes to sway trees, etc

does not support:
- opengl (my project doesn't support opengl so i'm unable to test this)

- add the 4 files to the paged geometry project and recompile the lib.
- alternatively, you can just include these files in your project.
- simply use "BatchPageHw" where you would have used "BatchPage" before.

- fix issue using multiple meshes with the same material names (identified by fratouille below)
- shadows can be enabled or disabled.
- batches now use the same render group as the parent paged geometry. (previously hard coded)
- added sample bumpmap shader. (requires mesh to have tangents: "ogrexmlconverter -t your.mesh.xml your.mesh")

please send any code review feedback, enhancements, etc. i'm not sure how to submit a patch so i'm uploading the files here.



25-05-2014 17:20:04

This is very cool.

The only issue i'm having is that when i try to delete a tree, i'm not able to retrieve it's proper entity / mesh name.

In my application, i'm able to to remove a tree from the batch pages and replace it by a regular entity / scenenode. This allow me to animate it separetly (Lumberjack cutting trees down). For this I rely on a slightly modified Treeloader2D::deleteTrees / Treeloader2D::findTrees. I remove the tree from the batch page, recover a Forests::TreeRef, and from this, clone the entity and attach it to a new scenenode that has same position/scale/yaw as the Forests::TreeRef.

When i use your hardware pages, i'm getting the proper position/yaw/scale, but the entity is sometimes the wrong one. I'm getting a different mesh than the one I just deleted. When using the regular pages, i don't have this issue.

I don't think this project is still activelly maintained, i'm using the version 1.1.4 from, with ImpostorPage fix from this page:


05-06-2014 20:29:25

oh i have a fix for this. when i'm home from work tonight i'll post it.

the workaround (without the fix) is each mesh needs a unique material name. annoying i know.

the issue is the function that determines the unique batch name needs to include the mesh name. otherwise, the second mesh with the same material name will be thrown away as the code assumes it has already added that mesh.

thanks for reporting the problem.


24-09-2014 03:47:58

This is a cool addition loath, I hope you can post future updates on this. Thanks for sharing. :D


04-10-2014 18:27:08

thanks for the support uovne!