0
我有一个问题,只是用SlimDX(DirectX 11)渲染一个简单的旋转立方体。立方体的旋转,这些都是我得到的图像:奇怪的渲染使用SlimDX(孔中的面孔)
我用这个顶点着色器:
float4x4 WorldViewProj : register(c0);
float4 VShader(float4 position : POSITION) : SV_POSITION
{
return mul(float4(position.xyz, 1.0), WorldViewProj);
}
这也是我如何准备WorldViewProj:
ProjectionMatrix = Matrix.PerspectiveFovLH((float)(Math.PI/4.0), 1f, -1, 20);
ViewMatrix = Matrix.LookAtLH(new Vector3(0f, 0, ypos), new Vector3(0f, 0, 10), new Vector3(0f, 1f, 0f));
Matrix positionMatrix = Matrix.Translation(position);
Matrix rotationMatrix = Matrix.RotationYawPitchRoll(rotation.X, rotation.Y, rotation.Z);
Matrix scaleMatrix = Matrix.Scaling(scale);
Matrix worldMatrix = rotationMatrix * scaleMatrix * positionMatrix;
worldMatrix = Matrix.Transpose(worldMatrix);
Matrix WorldViewProj = ViewMatrix * ProjectionMatrix * worldMatrix;
第一所有我看到这个问题:Incorrect Clipping and 3D Projection when using SlimDX
而且,矩阵有可能是错误的(因为我不是转置视图或投影,而是转换世界 - 在相反的情况下,没有任何东西被渲染)。但即使我将视图矩阵和投影矩阵都设置为单位矩阵,“洞”仍然存在。
请帮助和提前致谢!
我不确定是不是手动操作,但是您不是在Matrix.PerspectiveFovLH()中为近平面指定-1吗?如果是的话,你为什么不设置正值? – Alan 2012-04-20 21:03:06
野生狂猜:z缓冲区分辨率是否太小? – 2012-04-20 21:08:04
即使我这样做(0.0001f或1f) - 图片完全一样。 – 2012-04-20 21:09:53