Horde3D

Next-Generation Graphics Engine
It is currently 28.04.2024, 20:49

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: instancing and impostors
PostPosted: 07.04.2009, 22:41 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
I remember this mater being discussed in the crowd scaling topic. Since then are there any new developments?

I am starting a new project, that's centered around a vegetation system. Horde3D already comes in handy with deferred lighting but the actual scaling of the ecosystem largely depends on these two features. Are there any plans for these(especially instancing) in the near future?

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 05:28 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
IIRC, instancing was only added to OpenGL in GL3.0 or 3.1.
There is of course the hacky "pseudo instancing" demo (made by NVidia I think) built on GL2.0 - I don't know Marciano's thoughts on this technique.

Impostors can currently be implemented at the application level. Using render-to texture, you can render a particular 3D model down to a 2d texture, which is in turn used by a simple "quad" 3d model - A billboard node would be helpful here.


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 09:00 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
i was looking into nvidia's technique and from what i've seen its made using glsl.(?) so horde being shader based, it just a matter of making a shader?

regarding rtt, i came across this. Is there another aproach, a shader one?

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 11:04 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
RTT is already implemented in horde. The camera node has a param called "OutputTex" which is the ID of a texture resource to render to (or default 0 renders to the screen).


NVidia's pseudo instancing is not just a shader-based technique - it requires the way that the matrices are sent to GL by the CPU to be modified in the engine. NVidia use a hack where they store world matrices inside the texture coordinate storage instead of GLSL uniform storage, which is slightly easier for their drivers to deal with.
From the PDF:
Quote:
Pseudo-instancing applies well to geometry with a small number of per-instance attributes.
The technique does not scale well to complex mesh rendering techniques like skinning; there
are not enough vertex attributes to store all of the bone transforms for each instance.
So this technique would not work for a lot of horde models, such as animated characters - but probably would work for your vegitation.
Quote:
Direct3D instancing reduces the number of DrawIndexedPrimitive() calls from many to one.
This DrawIndexedPrimitive() call reduction has a large performance benefit in Direct3D.
In OpenGL, the application still calls glDrawElements() (or the like) for every instance.
This isn’t too much of a performance hit because glDrawElements() is very efficient in OpenGL.
This points out that instancing solves different problems in GL and DX - in DX, each draw call is very slow, so instancing is used to group them together. In GL, draw calls are much faster, so instancing doesn't help as much here.
Furthermore pseudo instancing doesn't actually reduce draw calls at all - you need the real deal (in GL3.1) to achieve that. Pseudo instancing is only used to slightly speed up the calculation of the world-view-projection matrix.


It should be pretty easy to add to the engine - the only modification is the way in which the world matrix is sent to the shader. Shader resources would require a flag of some sort to indicate to the engine which method to use.


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 22:08 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
DarkAngel is right, instancing is actually a hack that is required in D3D9 since the drawcalls are so slow. Here is an interesting benchmark:

http://www.ozone3d.net/blogs/lab/?p=87

As you can see, in OGL instancing has only an advantage for models with a small number of polygons. Besides that it will not work with characters that require all shader registers for the joint matrices. Real or pseudo instancing could be a nice option for a vegetation system extension (anyone willing to write one? ;)) but I think we do not require it in the engine core at the moment.


Top
 Profile  
Reply with quote  
PostPosted: 13.04.2009, 22:25 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
DarkAngel wrote:
This points out that instancing solves different problems in GL and DX - in DX, each draw call is very slow, so instancing is used to group them together. In GL, draw calls are much faster, so instancing doesn't help as much here.
Furthermore pseudo instancing doesn't actually reduce draw calls at all - you need the real deal (in GL3.1) to achieve that. Pseudo instancing is only used to slightly speed up the calculation of the world-view-projection matrix.
I understand the method better now.
Is the instancing in GL3.1 based on an existing extension that has been moved to the core or is it brand new?

marciano wrote:
As you can see, in OGL instancing has only an advantage for models with a small number of polygons. Besides that it will not work with characters that require all shader registers for the joint matrices. Real or pseudo instancing could be a nice option for a vegetation system extension (anyone willing to write one? ;)) but I think we do not require it in the engine core at the moment.
&&
DarkAngel wrote:
It should be pretty easy to add to the engine - the only modification is the way in which the world matrix is sent to the shader. Shader resources would require a flag of some sort to indicate to the engine which method to use.
Would the "flagged" way to send the matrices be added to Horde3D? Does the extension system provide enough access to achieve that?

So let me get this straight, pseudo instancing brings a performance increase for objects that have few transforms, like static props, right?

LE: I came across this extension, ARB_draw_instanced This is the real deal. Even used with opengl 2.1. An extension build on this could be plausible.

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 23.10.2009, 01:10 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
SpOOky wrote:
LE: I came across this extension, ARB_draw_instanced This is the real deal. Even used with opengl 2.1. An extension build on this could be plausible.
That is the extension which was integrated into GL 3.x. Note that it doesn't seem to offer performance benefits in very many cases - large numbers of static low-polygon models is the only case I have found where there is a benefit.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group