I ripped out all my calls to DirectX Math and started hand writing my matrices for great learning, but I tried to use Right Handed Coords (z decreases into the screen) and built my math library with column major vectors (and post multiplication I guess?).

Anyone know how I'm *supposed* to make that work with D3D?

I ran into z dimension issues. Basically everything was backwards, inside out, or wouldn't render at all (behind the camera). After much effort it renders approximately how I would expect, but I feel like I've jumped the rails and maybe ended back up in a Left Handed coordinate system anyway -- it looks like if I decrease a vertex's z coord it pulls it closer to the camera... but if I increase the camera's z it moves it further away... I'm in Hand Shaking coordinate system.

When switching from DirectX Math (row vector, pre mult, left handed) I had to:

- switch rasterizer FrontCounterClockwise to true
- pass vertex indices in counter clockwise instead of clockwise
- switch DepthFunc to comparison greater
- clear depth buffers to 0.0f instead of 1.0f
- avoid negating camera position when creating view matrix
- use nearZ/zRange instead of farZ/zRange in perspective matrix

Without that last one my z dimension was inverted or something after the perspective divide. My projection matrix looks like this now (where n and f are near/far clip depths):

float fovyRads = gmath::DegsToRads(fovy); float sinFov = gmath::Sin(fovyRads * 0.5f); float cosFov = gmath::Cos(fovyRads * 0.5f); float tanHalf = sinFov/cosFov; float halfH = n * tanHalf; float halfW = halfH * wOverH; float zRange = (f-n); float depth = -n/zRange; float zOffset = n*f/zRange; // NOTE: column major gmath::m4x4 perspM = { 1.0f/halfW, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f/halfH, 0.0f, 0.0f, 0.0f, 0.0f, depth, 1.0f, 0.0f, 0.0f, zOffset, 0.0f };

So... something seems screwy. I can post more of my maths if anyone is interested. But otherwise just let me know if some glaring thing is jumping out.