New InstanceManager: Instancing done the right way
-
- Goblin
- Posts: 287
- Joined: Mon Dec 08, 2008 4:49 pm
- x 10
Re: New InstanceManager: Instancing done the right way
I've tried using the ShaderBased InstanceManager, but when I make the numInstancesPerBatch too big (e.g. 255), it crashes.
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: New InstanceManager: Instancing done the right way
Ooops, thankssparkprime wrote:I noticed this documentation appears to be copy/pasted from something unrelated
First, such high number isn't technically supported (maximum theoretical value is 256 / 3 = 85, truncated) in ShaderBased. InstanceManager should be able to automatically crop it down.sparkprime wrote:I've tried using the ShaderBased InstanceManager, but when I make the numInstancesPerBatch too big (e.g. 255), it crashes
Second, if you're writing in your HLSL/Cg/GLSL shader something like "float4x3 myMatrices[255]" it's probably crashing on that side because it's invalid code.
Third, check the Ogre.log. Probably InstanceManager is telling you there's something wrong with the shader, unless the shader error made Ogre crash before it could warn you.
-
- Gnoblar
- Posts: 4
- Joined: Thu Apr 07, 2011 1:57 pm
- Location: Rennes, France
Re: New InstanceManager: Instancing done the right way
Hi ,
I was testing the new instancing system myself and had what seemed a suspect behaviour.
I tried to make a setVisible(false) to some entities but it seems that when all the entities of a batch don't have the same mVisible, the visibility is not affected.
Is it a bug or am I not using the instancing system the right way ?
Thanks in advance,
I was testing the new instancing system myself and had what seemed a suspect behaviour.
I tried to make a setVisible(false) to some entities but it seems that when all the entities of a batch don't have the same mVisible, the visibility is not affected.
Is it a bug or am I not using the instancing system the right way ?
Thanks in advance,
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: New InstanceManager: Instancing done the right way
Hi adria,
This is definately a bug. I'll check in the bug fix. Meanwhile you can solve it in your locally by going to OgreInstancedEntity.cpp lines 136 & 168 in getTransforms & getTransforms3x4 respectively, and change this line:
with this one:
Thanks for the bug report
Cheers
Dark Sylinc
This is definately a bug. I'll check in the bug fix. Meanwhile you can solve it in your locally by going to OgreInstancedEntity.cpp lines 136 & 168 in getTransforms & getTransforms3x4 respectively, and change this line:
Code: Select all
if( mParentNode )
Code: Select all
if( mParentNode && isVisible() )
Cheers
Dark Sylinc
-
- Gnoblar
- Posts: 4
- Joined: Thu Apr 07, 2011 1:57 pm
- Location: Rennes, France
Re: New InstanceManager: Instancing done the right way
That seems to work ! Thanks !
-
- Gnoblar
- Posts: 11
- Joined: Sat Mar 19, 2011 12:50 pm
Re: New InstanceManager: Instancing done the right way
Really nice work! The hardware instancing is giving me some great performance improvements but I'm curious as to whether support for meshes using multiple materials will be implemented?
-
- Gnoblar
- Posts: 4
- Joined: Thu Apr 07, 2011 1:57 pm
- Location: Rennes, France
Re: New InstanceManager: Instancing done the right way
I have the same question... I'm trying to use it for instancing trees or other objects but that's not so easy to find a tree mesh using just one material...
-
- Gnoblar
- Posts: 2
- Joined: Wed Apr 27, 2011 9:53 am
Re: New InstanceManager: Instancing done the right way
hi ,I was trying to use mutiple InstanceManager in my project. I'm new to Ogre, so I consult the sample. However when I tried to use the model jaiqua instead of robot with the technique Shaderbased , the entity became strange. and with no instancing it's the same .but HW instancing goes well.
here is a screenshot:
i did add a material in the ShaderInstancing.material
can you tell me why?
or what I need is to learn shader programe?
Thank you for your time.
I'm from China,so the network may be slow. Sorry...This is a address for the screenshot
http://hi.baidu.com/twcicle/album/item/ ... 4fe9.html#
here is a screenshot:
i did add a material in the ShaderInstancing.material
can you tell me why?
or what I need is to learn shader programe?
Thank you for your time.
I'm from China,so the network may be slow. Sorry...This is a address for the screenshot
http://hi.baidu.com/twcicle/album/item/ ... 4fe9.html#
Last edited by kangshe on Wed Apr 27, 2011 1:43 pm, edited 1 time in total.
- spacegaier
- OGRE Team Member
- Posts: 4304
- Joined: Mon Feb 04, 2008 2:02 pm
- Location: Germany
- x 135
- Contact:
Re: New InstanceManager: Instancing done the right way
No screenshot visible here.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: New InstanceManager: Instancing done the right way
I was able to see the screenshot. I'll take a look later.
Probably the bone count is very high and the shader doesn't hold enough data. Will research. Thanks for the report.
Cheers
Dark Sylinc
Probably the bone count is very high and the shader doesn't hold enough data. Will research. Thanks for the report.
Check the first post again, I've updated it with a code snippet showing how to do that. Hope it helpsdarkip wrote:Really nice work! The hardware instancing is giving me some great performance improvements but I'm curious as to whether support for meshes using multiple materials will be implemented?
Cheers
Dark Sylinc
-
- Gnoblar
- Posts: 11
- Joined: Sat Mar 19, 2011 12:50 pm
Re: New InstanceManager: Instancing done the right way
Just a small example of what we've done using the basic HW instancing. Ignore the framerate, it's the video recorder being slow.
http://www.inflatablegoldfish.com/swarming.mov
The movement of each entity in the swarm depends on that of it's neighbours. We parallelised the algorithm using openMP and it's pretty impressive!
http://www.inflatablegoldfish.com/swarming.mov
The movement of each entity in the swarm depends on that of it's neighbours. We parallelised the algorithm using openMP and it's pretty impressive!
-
- Gnome
- Posts: 389
- Joined: Mon Jul 26, 2010 10:53 pm
- x 22
Re: New InstanceManager: Instancing done the right way
I'm going to try to use this in my deferred lighting piple to render light volumes. I think what I need is I need to be able to set a few custom variables, variables that is necessary for the radiance computations. I sync + updated to the latest and I begun to look at the code to see how I could approach this. Purely FYI. If I can contribute back anything I will.
-
- Gnome
- Posts: 389
- Joined: Mon Jul 26, 2010 10:53 pm
- x 22
Re: New InstanceManager: Instancing done the right way
I'm going to do some testing first by creating my lights as HW basic instanced entities. For world position I can extract this out of the world transform matrix and keep rest of the parameters as shader constants. This way I can see how it performs before I proceed any further. If instancing turns out to be a good idea then I could either 1) make my own custom thing using HardwareBuffers with instancing, 2) subclass InstanceBatch and just copy what HWBasics is doing--remember I need to implement custom parameters, 3) Implement custom parameters function by modifying VTF, Shader, HW InstanceBatch classes to allow insertion of custom parameters.
-
- Greenskin
- Posts: 105
- Joined: Tue Dec 14, 2010 9:46 am
- x 1
- Contact:
Re: New InstanceManager: Instancing done the right way
Is GLES Render System supported ? I trying use this feature in my iphone app, but it crashes : EXE_BAD_ACCESS.
Thanks for your help!
Thanks for your help!
- masterfalcon
- OGRE Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
- Contact:
Re: New InstanceManager: Instancing done the right way
No, instancing is not supported in GL ES
-
- Gnoblar
- Posts: 4
- Joined: Thu Apr 07, 2011 1:57 pm
- Location: Rennes, France
Re: New InstanceManager: Instancing done the right way
Hello again,
I would like to set a material dynamically like this for an Entity :
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("myMaterial",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mat->setAmbient(r,g,b);
mat->setDiffuse(r,g,b,1);
mat->setSpecular(0,0,0,1);
m_Ent->setMaterialName("myMaterial");
But I see there are no setMarialName function for an InstancedEntity and I would have liked for example to color a mesh according to its velocity... Wouldn't it be possible ?
Thks in advance !
I would like to set a material dynamically like this for an Entity :
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("myMaterial",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mat->setAmbient(r,g,b);
mat->setDiffuse(r,g,b,1);
mat->setSpecular(0,0,0,1);
m_Ent->setMaterialName("myMaterial");
But I see there are no setMarialName function for an InstancedEntity and I would have liked for example to color a mesh according to its velocity... Wouldn't it be possible ?
Thks in advance !
-
- Goblin
- Posts: 287
- Joined: Mon Dec 08, 2008 4:49 pm
- x 10
Re: New InstanceManager: Instancing done the right way
Is there a way to set a renderqueuegroupid for an instancingmanager / batch?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: New InstanceManager: Instancing done the right way
Hi, not at the moment. Should be easy to add (would be per batch).jonim8or wrote:Is there a way to set a renderqueuegroupid for an instancingmanager / batch?
I'm currently with a severe lack of free time unfortunately. Until mid July at least don't expect updates until that time.
You may "hack" around it by calling instancedEntity->_getOwner()->setRenderQueueGroup( ... )
This will affect all instanced entities within that batch, but it won't affect new batches that gets created and you don't have a clean way to tell when when are new batches created.
Cheers
Dark Sylinc
-
- Goblin
- Posts: 287
- Joined: Mon Dec 08, 2008 4:49 pm
- x 10
Re: New InstanceManager: Instancing done the right way
that hack will be fine for now. Thanks!
- Mattan Furst
- OGRE Retired Team Member
- Posts: 260
- Joined: Tue Jan 01, 2008 11:28 am
- Location: Israel
- x 32
Re: New InstanceManager: Instancing done the right way
@dark_sylinc
Hello dark_sylinc,
I want to add some functionality to the instance manager. This idea is meant to improve the framerate when dealing with large animated crowds.
The idea behind this is as follows. Each entity in the crowd may have a different animation. However I make the following assumptions:
When rendering large crowds with complex bone structure this method should cut down on memory usage, cpu time, and memory bandwidth.
Any thoughts?
P.S.
The next phases in this project will be to add support for this to the RTShader and texture atlasing for larger variance in the crowed.
Hello dark_sylinc,
I want to add some functionality to the instance manager. This idea is meant to improve the framerate when dealing with large animated crowds.
The idea behind this is as follows. Each entity in the crowd may have a different animation. However I make the following assumptions:
- All entities have the same mesh and skeleton
- There is a limited amount of unique animations states assigned to the entities. (in my case all entities share among themselves around 20 different animation states).
When rendering large crowds with complex bone structure this method should cut down on memory usage, cpu time, and memory bandwidth.
Any thoughts?
P.S.
The next phases in this project will be to add support for this to the RTShader and texture atlasing for larger variance in the crowed.
it's turtles all the way down
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: New InstanceManager: Instancing done the right way
So basically you suggest more flexibility with the option to use the same animation for different instanced entities, the price is a new 4x3 matrix in the vertex buffer (one per instance), and one more matrix multiplication in the shader. You can still use a one to one ratio of entities to animation - to get the current behavior.
Right?
Is this the only price to pay?
Do you plan also to support the current behavior (without the new 4x3 matrix and matrix multiplication in the shader) or only the new behavior will be supported?
How will the user update the animations?
Right?
Is this the only price to pay?
Do you plan also to support the current behavior (without the new 4x3 matrix and matrix multiplication in the shader) or only the new behavior will be supported?
How will the user update the animations?
Watch out for my OGRE related tweets here.
- masterfalcon
- OGRE Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
- Contact:
Re: New InstanceManager: Instancing done the right way
What about using Texture Buffer Objects(in GL3Plus at least, not sure about DX) for the look up?
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: New InstanceManager: Instancing done the right way
Vertex texture is being used, isn't vertex texture same as "Texture Buffer Objects"?masterfalcon wrote:What about using Texture Buffer Objects(in GL3Plus at least, not sure about DX) for the look up?
Watch out for my OGRE related tweets here.
- masterfalcon
- OGRE Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
- Contact:
Re: New InstanceManager: Instancing done the right way
It could be. I'm not familiar with the DX nomenclature. http://www.opengl.org/registry/specs/EX ... object.txt
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: New InstanceManager: Instancing done the right way
Let me say it this way: vertex textures are "Texture Buffer Objects".
"Texture Buffer Objects" are being used currently in OGRE in this case, Mattan change will not change that.
"Texture Buffer Objects" are being used currently in OGRE in this case, Mattan change will not change that.
Watch out for my OGRE related tweets here.