Jump to content

  • Log In with Google      Sign In   
  • Create Account


Geometry instancing?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Luna Inverse   Members   -  Reputation: 100

Like
0Likes
Like

Posted 22 January 2012 - 04:39 AM

Hello. I have a little question about the geometry instancing in Direct3D9. I understand it should be useful for drawing a lot of objects using the same vertex data, like trees, and limiting the number of calls to the drawing routine.
On the http://msdn.microsof...9(v=vs.85).aspx page it is shown in the examples:
if( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
	for(int i=0; i < g_numObjects; i++)
	{
		pd3dDevice->SetStreamSource(0, g_VB_Geometry, 0,
				D3DXGetDeclVertexSize( g_VBDecl_Geometry, 0 ));

		pd3dDevice->SetVertexDeclaration( ... );
		pd3dDevice->SetVertexShader( ... );
		pd3dDevice->SetIndices( ... );
		pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0,
				g_dwNumVertices, 0, g_dwNumIndices/3 );
	}		
  
	pd3dDevice->EndScene();
}
Which is a contrast to a geometry instancing example.
My question is, is the SetStreamSource method required to be called everytime for each object or it is not enough if it is called before the loop?
Would this change the rendering performance for the objects or geometry instancing is a must in such cases?

Sponsor:

#2 Ripiz   Members   -  Reputation: 529

Like
0Likes
Like

Posted 22 January 2012 - 12:39 PM

g_VB_Geometry seems to be global variable, not per-object data, so yes, you can move it outside.
Technically loop does nothing but render same thing many times in same position, because example doesn't set different matrix anywhere.
I'd assume it's just pseudocode which wasn't well thought through.

#3 mhagain   Crossbones+   -  Reputation: 7610

Like
0Likes
Like

Posted 22 January 2012 - 02:35 PM

That specific loop is for the non-instanced case; my best guess is that it's intended as a backgrounder to show the differences between both cases rather than as anything prescriptive.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS