Sign in to follow this  
thedodgeruk

instancing vs geometry shader , cant figure out whats best

Recommended Posts

been looking at code from dx 9 and dx10

cant quiet get my head around some thing and i think im getting confused here and mixed up

in dx9 there is instancing were you pass multiple data via D3D10_INPUT_PER_INSTANCE_DATA.


geometry shadering is the new and improved way of doing intsancing , so you need to declare D3D10_INPUT_PER_VERTEX_DATA and send it via the geometry shader

i know you can do point light s on the geometry shader , but i would like to send a matrix via the geometry shader , or a point which will expand it into a mesh .



can some one apart from "dan" help me and clear up my mistakes

Share this post


Link to post
Share on other sites
[quote name='thedodgeruk' timestamp='1318426869' post='4871828']
been looking at code from dx 9 and dx10

cant quiet get my head around some thing and i think im getting confused here and mixed up

in dx9 there is instancing were you pass multiple data via D3D10_INPUT_PER_INSTANCE_DATA.


geometry shadering is the new and improved way of doing intsancing , so you need to declare D3D10_INPUT_PER_VERTEX_DATA and send it via the geometry shader

i know you can do point light s on the geometry shader , but i would like to send a matrix via the geometry shader , or a point which will expand it into a mesh .



can some one apart from "dan" help me and clear up my mistakes
[/quote]

Hi,

You don't need geometry shader to do instancing. Yes, you may duplicate geometry with it, but it isn't as efficient as using the built-in instancing.

The D3D10/11 way of doing instancing is pretty similar to D3D9 way. That is, declaring multiple streams and setting a correct input stream declaration. Of course you may use also constant buffers for the per-instance-data. The key here is [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476412(v=vs.85).aspx"]"DrawInstanced"[/url] command.

Expanding points to quads on geometry shader is slightly a different matter and not directly related to instancing.

Cheers!

Share this post


Link to post
Share on other sites
[quote name='thedodgeruk' timestamp='1318426869' post='4871828']
geometry shadering is the new and improved way of doing intsancing , so you need to declare D3D10_INPUT_PER_VERTEX_DATA and send it via the geometry shader[/quote]
Nope. You got your facts wrong.

The Geometry shader is a way to generate more vertices/triangles from a given triangle. The geometry shader, unlike the vertex shader, can look at all three vertices, not to just a single one. Although geometry shaders can be used to emulate instancing, it's highly innefficient; since Geometry shader's performance drops quickly as the ratio output/input increases.

Geometry shaders is cool for point particles, other billboards (i.e. trees in the distance), and some cool effects . It has been a big dissappointment imho. The most intuitive thing to do was to use it for tesselation, but performance was horrible. That's why DX11 came with a tesselation stage. The [url="http://www.nvidia.com/object/cool_stuff.html#/demos"]medusa demo from NVIDIA[/url] shows a way to use geometry shaders for cool effects (the green energy in the part where the guy gets turned into stone).

If you play it nice, mixing hardware instancing with geometry shaders, it is possible to render an environment map in much less than 6 passes, therefore making it faster. If you play it wrong, it will be slower. There's been a lot of papers about different methods to draw to an env. map in less than 6 passes using geometry shaders. In fact IIRC there was paper published here in GD.Net

But a replacement for HW Instancing? No, that's not really it.

Cheers
Dark Sylinc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this