Hi all,
I am stumped. When I try to render a mesh using diffuse textures for all the submeshes, my mesh is colored all black and I get this debug output from d3d:
"The Pixel Shader unit expects a Shader Resource View at Slot 0, but none is bound."
I googled around but didn't find any information that helped me. I am using the "D3D10_BIND_SHADER_RESOURCE" flag when using D3DX10CreateTextureFromFile() method. I don't really know what else to explain so I will paste the code that creates the diffuse texture and it's resource view, and the code a snippet of rendering code.
// Create Diffuse Texture View
ID3D10Device* pd3dDevice = DXUTGetD3D10Device();
D3DX10_IMAGE_INFO srcInfo;
D3DX10_IMAGE_LOAD_INFO loadInfo;
ZeroMemory( &loadInfo, sizeof(D3DX10_IMAGE_LOAD_INFO) );
D3DX10GetImageInfoFromFile( mpDiffuseTxFilePathName.c_str(), NULL, &srcInfo, NULL );
loadInfo.pSrcInfo = &srcInfo
loadInfo.Format = loadInfo.pSrcInfo->Format;
loadInfo.BindFlags = D3D10_BIND_SHADER_RESOURCE;
V_RETURN(D3DX10CreateTextureFromFile( pd3dDevice, mpDiffuseTxFilePathName.c_str(), &loadInfo, NULL, ( ID3D10Resource** )&mpDiffuseTx, NULL ));
D3D10_SHADER_RESOURCE_VIEW_DESC SRVDesc;
SRVDesc.Format = loadInfo.pSrcInfo->Format;
SRVDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MostDetailedMip = 0;
SRVDesc.Texture2D.MipLevels = loadInfo.pSrcInfo->MipLevels;
V_RETURN(pd3dDevice->CreateShaderResourceView( mpDiffuseTx, &SRVDesc, &mpDiffuseTxRV ));
Rendering code
D3D10_TECHNIQUE_DESC techDesc;
pTechnique->GetDesc( &techDesc );
SubMesh10* pSubMesh;
Material10* pMaterial;
ID3D10ShaderResourceView* pDiffuseRV = NULL;
D3D10_PRIMITIVE_TOPOLOGY primType;
for( UINT passIndex = 0; passIndex < techDesc.Passes; ++passIndex )
{
for( INT meshIndex = 0; meshIndex < pMesh->GetNumSubMeshes(); ++meshIndex )
{
pSubMesh = pMesh->GetSubMesh( meshIndex );
pMaterial = pSubMesh->GetMaterial();
primType = pSubMesh->GetPrimitiveType();
pd3dDevice->IASetPrimitiveTopology( primType );
pDiffuseRV = pMaterial->GetDiffuseResourceView();
pTxDiffuseVariable->SetResource( pDiffuseRV );
pTechnique->GetPassByIndex( passIndex )->Apply( NULL );
INT indexBufferLength = pSubMesh->GetIndexBufferLength();
INT startIndexLocation = pSubMesh->GetStartIndexLocation();
INT baseVertexLocation = pSubMesh->GetBaseVertexLocation();
pd3dDevice->DrawIndexed( indexBufferLength, startIndexLocation, baseVertexLocation );
}
}
Thanks for any help!
[Edited by - link3978 on September 14, 2009 8:06:21 PM]