Im currently having some problems rendering my meshes. Im coming from D3D9 and this is my first project with D3D11. I have my custom mesh class with the meshgeometry and vertex elements. Current i have this simple test:
[source lang="csharp"] Rendering.Geometry.MeshGeometry<uint> geom = Rendering.Geometry.MeshGeometry<uint>.Create(device); var elem = Rendering.Geometry.VertexElement.CreatePosition3D(device); float[] vertices = new float[9] { 0, 0, -3, 0, 0, 3, 0, 5, 0, }; elem.DataStream.WriteRange(vertices); geom.AddVertexElement(elem); var triangle = geom.Triangles.AddFace(); triangle.P1 = 0; triangle.P2 = 1; triangle.P3 = 2; geom.LoadBuffers(); Rendering.Scene.Mesh mesh = new Rendering.Scene.Mesh(); mesh.AttachGeometry(geom); device.Scene.SceneRoot.AttachChild(mesh);Rendering.Effects.Common.BasicEffect basicEffect = new Rendering.Effects.Common.BasicEffect(device); basicEffect.WorldMatrix = SlimDX.Matrix.Identity; basicEffect.ViewMatrix = SlimDX.Matrix.LookAtLH(new SlimDX.Vector3(50, 5, 0), new SlimDX.Vector3(0, 5, 0), new SlimDX.Vector3(0, 1, 0)); basicEffect.ProjectionMatrix = SlimDX.Matrix.PerspectiveFovLH((45.0f * (float)Math.PI) / 180.0f, ((float)f.ClientSize.Width / f.ClientSize.Height), 0.1f, 1000.0f);[/source]
The basic effect looks like that:
Vertexshader:
[source lang="cpp"]cbuffer MatrixBuffer{ matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix;};struct VertexInputType{ float4 position : POSITION;};struct PixelInputType{ float4 position : SV_POSITION;};PixelInputType BasicEffectVS(VertexInputType input){ PixelInputType output = (PixelInputType)0; input.position.w = 1.0f; output.position = mul(input.position, worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); return output;}[/source]
Pixelshader:
[source lang="cpp"]struct PixelInputType{ float4 position : SV_POSITION;};float4 BasicEffectPS(PixelInputType input) : SV_Target{ return float4(1, 1, 1, 1);}[/source]
Rendering is done the following way:
[source lang="csharp"] var ctx = mDevice.ImmediateContext; ctx.InputAssembler.InputLayout = inpLayout; shader.PerformRender((dev) => { ctx.InputAssembler.SetVertexBuffers(0, mVBinding); ctx.InputAssembler.SetIndexBuffer(mIndexBuffer, SlimDX.DXGI.Format.R32_UInt, 0); ctx.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; ctx.DrawIndexed(Triangles.getTriangleCount() * 3, 0, 0); } );[/source]
Now the problem is that nothing is rendered on the screen. Im using PIX to debug my shaders and draw calls.
The results:
As Pre-VS data i get the values from my triangle:
(Vertex, Index, Position)
0, 0, (0.0, 0.0, -3.0, 1.0)
1, 1, (0.0, 0.0, 3.0, 1.0)
2, 2, (0.0, 5.0, 0.0, 1.0)
But then at PostVS i have the following:
0, 0, (5.274, 0.0, -149.0, 0)
1, 1, (-5.274, 0.0, 151.0, 0)
2, 2, (0.0, 12.071, -24.0, 0)
While the first two position values make sense if i translate them on the screen the depth (id say z is depth) is weird. From my vertices depth should be equal for all the 3, or am i wrong? Also the images are not showing what i expect when i have a triangle aligned on the z-axis with a camera looking from the x-axis onto it:

Hopefully someone can help me and point me out what im doing wrong!
Thanks in advance
Plerion
Edited by Plerion, 17 September 2012 - 10:53 AM.






