Jump to content
  • Advertisement
Sign in to follow this  
dreamtheater39

Software Vertex Processing - Lighting not working?

This topic is 3453 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, I've forced device creation to use software vertex processing. But my meshes being rendered are fully black, seems like vertex normals arent being used to calculate lighting. The entire code runs on fixed function pipeline, no shaders. Any ideas what could be the problem? Here are some observations - 1. Turn off D3DRS_LIGHTING (set to false), objects are rendered with textures accurately. 2. When SetMaterial for the mesh is being called, changing ambient color values reflect at render time. So material is being set right too! 3. Lights are created properly and initialized. The same code works fine on mixed vertex processing. Thanks, San [Edited by - dreamtheater39 on January 6, 2009 8:32:10 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Evil Steve
What happens if you use the reference rasterizer? It sounds like the only reason it works with hardware VP is that there's a glitch in the driver. Any output from the Debug Runtimes?


Nothing in the debug spew even at maximum error reporting, max validation on dx debug runtimes.

Really beats me here :-/

Anything else i should be looking for?

Thanks,
San

EDIT: Even in reference rasterizer, it renders as solid black - no lighting.

Share this post


Link to post
Share on other sites
Quote:
Original post by dreamtheater39
EDIT: Even in reference rasterizer, it renders as solid black - no lighting.
That means that it's a driver "feature" that's letting it work in hardware VP.

When you say a mesh, do you mean an ID3DXMesh? Can we see your code?

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by dreamtheater39
EDIT: Even in reference rasterizer, it renders as solid black - no lighting.
That means that it's a driver "feature" that's letting it work in hardware VP.

When you say a mesh, do you mean an ID3DXMesh? Can we see your code?


Yes, its ID3DXMesh that i'm using.
The code is a completely changed/ported version of SkinnedMesh (d3d9) sample in the sdk.

I've just noticed that it doesnt do lighting only when the skinning method is D3DINDEXED or D3DNONINDEXED. The methods which used a VS works.

The render functions for both indexed and nonindexed are fairly straightforward.


else if (g_SkinningMethod == D3DINDEXED)
{
// if hw doesn't support indexed vertex processing, switch to software vertex processing
if (pMeshContainer->UseSoftwareVP)
{
// If hw or pure hw vertex processing is forced, we can't render the
// mesh, so just exit out. Typical applications should create
// a device with appropriate vertex processing capability for this
// skinning method.
if( g_dwBehaviorFlags & D3DCREATE_HARDWARE_VERTEXPROCESSING )
return;

V( pd3dDevice->SetSoftwareVertexProcessing(TRUE) );
}

// set the number of vertex blend indices to be blended
if (pMeshContainer->NumInfl == 1)
{
V( pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_0WEIGHTS) );
}
else
{
V( pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, pMeshContainer->NumInfl - 1) );
}

if (pMeshContainer->NumInfl)
V( pd3dDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, TRUE) );

// for each attribute group in the mesh, calculate the set of matrices in the palette and then draw the mesh subset
pBoneComb = reinterpret_cast<LPD3DXBONECOMBINATION>(pMeshContainer->pBoneCombinationBuf->GetBufferPointer());
for (iAttrib = 0; iAttrib < pMeshContainer->NumAttributeGroups; iAttrib++)
{
// first calculate all the world matrices
for (iPaletteEntry = 0; iPaletteEntry < pMeshContainer->NumPaletteEntries; ++iPaletteEntry)
{
iMatrixIndex = pBoneComb[iAttrib].BoneId[iPaletteEntry];
if (iMatrixIndex != UINT_MAX)
{
D3DXMatrixMultiply( &matTemp, &pMeshContainer->pBoneOffsetMatrices[iMatrixIndex], pMeshContainer->ppBoneMatrixPtrs[iMatrixIndex] );
V( pd3dDevice->SetTransform( D3DTS_WORLDMATRIX( iPaletteEntry ), &matTemp ) );
}
}

// setup the material of the mesh subset - REMEMBER to use the original pre-skinning attribute id to get the correct material id
V( pd3dDevice->SetMaterial( &pMeshContainer->pMaterials[pBoneComb[iAttrib].AttribId].MatD3D ) );
V( pd3dDevice->SetTexture( 0, pMeshContainer->ppTextures[pBoneComb[iAttrib].AttribId] ) );

// finally draw the subset with the current world matrix palette and material state
V( pMeshContainer->MeshData.pMesh->DrawSubset( iAttrib ) );
}

// reset blending state
V( pd3dDevice->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE) );
V( pd3dDevice->SetRenderState(D3DRS_VERTEXBLEND, 0) );

// remember to reset back to hw vertex processing if software was required
if (pMeshContainer->UseSoftwareVP)
{
V( pd3dDevice->SetSoftwareVertexProcessing(FALSE) );
}
}



San

Share this post


Link to post
Share on other sites
Tried everything under the sun, it still beats me. Works perfect in mixed vertex processing while using a vertex shader and it renders with proper lighting, but in software vp it renders as a solid black object :-/ (no lighting)

any other ideas why this could be happening?

Thanks,
San

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!