C++ 在DirectX11顶点和像素着色器之间交换

C++ 在DirectX11顶点和像素着色器之间交换,c++,render,draw,directx-11,C++,Render,Draw,Directx 11,因此,我一直在遵循弗兰克·卢纳(Frank Luna)的书《使用DirectX11进行3D游戏编程》(3D Games programming with DirectX11)中的一个教程,并一直在开发一个天空盒。除了纹理所需的小调整外,此天空框正在正确渲染。我已经为天空盒创建了一个单独的顶点和像素着色器,因为它不需要在.fx文件中做太多工作。当我绘制对象时,它们都会绘制,但当我使用正常工作的法线顶点和像素着色器时,我的对象会显示为黑色(我认为它们无法从着色器获得颜色) 在更改着色器和不使用错误数

因此,我一直在遵循弗兰克·卢纳(Frank Luna)的书《使用DirectX11进行3D游戏编程》(3D Games programming with DirectX11)中的一个教程,并一直在开发一个天空盒。除了纹理所需的小调整外,此天空框正在正确渲染。我已经为天空盒创建了一个单独的顶点和像素着色器,因为它不需要在.fx文件中做太多工作。当我绘制对象时,它们都会绘制,但当我使用正常工作的法线顶点和像素着色器时,我的对象会显示为黑色(我认为它们无法从着色器获得颜色)


在更改着色器和不使用错误数据之间,我是否遗漏了一行代码来清除某些内容???

是对.fx文件进行小编辑时出现的问题,我没有注意到。现在可以通过恢复该文件来修复。

如果有帮助的话
_pImmediateContext->RSSetState(_solidFrame);
_pImmediateContext->VSSetShader(_pSkyVertexShader, nullptr, 0);
_pImmediateContext->PSSetShaderResources(3, 1, &_pTextureSkyMap);
_pImmediateContext->PSSetShaderResources(0, 1, &_pTextureRV);
_pImmediateContext->PSSetShaderResources(1, 1, &_pSpecTextureRV);
_pImmediateContext->PSSetShaderResources(2, 1, &_pNormTextureRV);
_pImmediateContext->PSSetSamplers(0, 1, &_pSamplerLinear);
_pImmediateContext->PSSetShader(_pSkyPixelShader, nullptr, 0);

//Imported Sky
world = XMLoadFloat4x4(&_sky.GetWorld());
cb.mWorld = XMMatrixTranspose(world);
_pImmediateContext->UpdateSubresource(_pConstantBuffer, 0, nullptr, &cb, 0, 0); //Copies the constant buffer to the shaders.
//Draw the Pitch
_sky.Draw(_pd3dDevice, _pImmediateContext);

_pImmediateContext->VSSetShader(_pVertexShader, nullptr, 0);
_pImmediateContext->VSSetConstantBuffers(0, 1, &_pConstantBuffer);
_pImmediateContext->PSSetConstantBuffers(0, 1, &_pConstantBuffer);
_pImmediateContext->PSSetShaderResources(0, 1, &_pTextureMetalRV);
_pImmediateContext->PSSetShaderResources(1, 1, &_pSpecTextureRV);
_pImmediateContext->PSSetShaderResources(2, 1, &_pNormTextureRV);
_pImmediateContext->PSSetSamplers(0, 1, &_pSamplerLinear);
_pImmediateContext->PSSetShader(_pPixelShader, nullptr, 0);

//Floor
// Render opaque objects //
// Set vertex buffer for the Floor
_pImmediateContext->IASetVertexBuffers(0, 1, &_pVertexBufferFloor, &stride, &offset);
// Set index buffer
_pImmediateContext->IASetIndexBuffer(_pIndexBufferFloor, DXGI_FORMAT_R16_UINT, 0);
world = XMLoadFloat4x4(&_worldFloor);
cb.mWorld = XMMatrixTranspose(world);
_pImmediateContext->UpdateSubresource(_pConstantBuffer, 0, nullptr, &cb, 0, 0); //Copies the constant buffer to the shaders.
_pImmediateContext->DrawIndexed(96, 0, 0);

//Imported Pitch
world = XMLoadFloat4x4(&_pitch.GetWorld());
cb.mWorld = XMMatrixTranspose(world);
_pImmediateContext->UpdateSubresource(_pConstantBuffer, 0, nullptr, &cb, 0, 0); //Copies the constant buffer to the shaders.
//Draw the Pitch
_pitch.Draw(_pd3dDevice, _pImmediateContext);

_pImmediateContext->PSSetShaderResources(0, 1, &_pTextureMetalRV);
_pImmediateContext->PSSetShaderResources(1, 1, &_pSpecTextureMetalRV);
_pImmediateContext->PSSetShaderResources(2, 1, &_pNormTextureMetalRV);