Jump to content
  • Advertisement
Sign in to follow this  

DirectX SDK (August 2009) Instancing10 sample

This topic is 2783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all.
I have some questions on the tree instances.
I'm asking because its time to have some plant life on my terrain, is this the way to go for rendering lots of trees.

Does anyone know what program they put the leaves on this tree, they use in that sample.

It looks like it loads a stack of INSTANCEDATA structures
float fOcc;
from a file called leaves5.mtx(Samples\Media\Data\leaves5.mtx)

and what does the fOcc do. I think its a entry to an array of images for that leaf.
found that fOcc is , is a baked occlusion term used to shade the leaves

and one last question on the sample, it says in the function RenderInstancedQuads
// Draw leaves for all trees but when you set the tree count higher then 1 the debug say's buffer to small. it draws all trees but and there is no loop i can see.

called like this in app
RenderSceneGeometry( pd3dDevice, mView, mProj ); // Render the scene with texture
RenderInstancedQuads( pd3dDevice, mView, mProj ); // Render the instanced leaves for each tree
RenderGrass( pd3dDevice, mView, mProj ); // Render grass

so if the buffer is to small hows all the tress being rendered ????.

[Edited by - ankhd on October 12, 2010 11:08:15 PM]

Share this post

Link to post
Share on other sites
The sample calls UpdateLeafVertexLayout when the number of trees is change by the user, but for my terrain it would change based on trees infront of the camera.

My question is would creating this layout every render pass slow down my app
and what ways can i increase the speed if it is indeed slow.

Here is the function.

// Update the vertex layout for the number of leaves based upon the number
// of trees we're drawing. This is to help us efficiently render leaves using
// instancing across the tree mesh and the leaf points on the trees.
void UpdateLeafVertexLayout( ID3D10Device* pd3dDevice )
SAFE_RELEASE( g_pLeafVertexLayout );

// Define our leaf vertex data layout
const D3D10_INPUT_ELEMENT_DESC leaflayout[] =
{ "mTransform", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA,
g_iNumTreesToDraw },
{ "mTransform", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D10_INPUT_PER_INSTANCE_DATA,
g_iNumTreesToDraw },
{ "mTransform", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D10_INPUT_PER_INSTANCE_DATA,
g_iNumTreesToDraw },
{ "mTransform", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D10_INPUT_PER_INSTANCE_DATA,
g_iNumTreesToDraw },
g_iNumTreesToDraw },
int iNumElements = sizeof( leaflayout ) / sizeof( D3D10_INPUT_ELEMENT_DESC );
D3D10_PASS_DESC PassDesc;
g_pRenderQuad->GetPassByIndex( 0 )->GetDesc( &PassDesc );
pd3dDevice->CreateInputLayout( leaflayout, iNumElements, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pLeafVertexLayout );

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!