0
我很困惑,爲什麼這不起作用。用數據填充立方體紋理
我試圖將紋理數據添加到每個立方體紋理面。出於某種原因,只有第一個(+ x)的作品。 MSDN文檔是相當稀少,但看起來這應該做的伎倆:
// mip-level 0 data
// R8G8B8A8 texture
uint32_t sizeWidth = textureWidth * sizeof(uint8_t) * 4;
if (isCubeTexture)
{
for (uint32_t index = 0; index < gCubemapNumTextures; ++index)
{
const uint32_t subResourceID = D3D11CalcSubresource(0, index, 1);
context->UpdateSubresource(mTexture, subResourceID, NULL, &textureData.at(sizeWidth * textureHeight * index), sizeWidth, 0);
}
}
調試時,看着臉上的所有除第一面,這似乎負荷罰款只是黑色的。因此,我正在做錯誤的處理,您如何正確地上傳cubetexture數據到所有的面孔?
編輯:遵循用於創建紋理參數:
D3D11_TEXTURE2D_DESC textureDesc;
ZeroMemory(&textureDesc, sizeof(D3D11_TEXTURE2D_DESC));
textureDesc.Width = textureWidth;
textureDesc.Height = textureHeight;
textureDesc.ArraySize = isCubeTexture ? gCubemapNumTextures : 1;
if (isSRGB)
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
else
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 1;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
if (isCubeTexture)
textureDesc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
DXCALL(device->CreateTexture2D(&textureDesc, NULL, &mTexture));
然後將數據上傳後,我產生的MIP鏈是這樣的:
context->GenerateMips(mShaderResourceView);
再次,它工作正常,但只適用於第一個(+ x)臉。
你用來創建紋理的參數是什麼? –