Hey,
I am writing my first renderer, so sorry if the question is question is stupid :(
I am trying to write my first attempt at shadows, but I am stuck with nothing rendered on my shadow map. Looking at the orthographic projection I am using, the values generated look odd, very small:
_11 0.00210536504 _12 0.000000000 _13 0.000000000 _14 0.000000000
_21 0.000000000 _22 0.00331832888 _23 0.000000000 _24 0.000000000
_31 0.000000000 _32 0.000000000 _33 0.00166944903 _34 0.000000000
_41 0.000000000 _42 0.000000000 _43 -0.00166944903 _44 1.00000000
So I am assuming this kind of matrix will crush any value to almost zero right?
The way I am generating it is:
float near = mainCamera.nearPlane(); // It's 1.0f
float far = mainCamera.farPlane(); // It's 600.0f
vec3 sceneExtent = 0.5*(sceneMax-sceneMin);
float orthowidth = sceneExtent.x; // It's about 950.0f
float orthoheight = sceneExtent.z; // it's about 600.0f
orthoProjM = XMMatrixOrthographicLH(orthowidth, orthoheight, near, far);
Just for sake of completeness my shadow view matrix is computed as:
vec3 center = 0.5f * (sceneMax+sceneMin);
vec3 cameraPos = center - LightDir * 50.0f;
viewM = XMMatrixLookAtLH(cameraPos, cameraPos + LightDir, vec3(0.0f, 0.0f, 1.0f));
So I obviously trust d3d functions, but can anybody explain to me what I am doing wrong?
Thank you very much!!
Sorry if my english is bad, but it's not my first language :)
Jacques
P.S.
Just for the sake of completeness, I am rendering with a depth test of less or equal, setting the viewport to (0,0,shadowRes, shadowRes) and the vertex shader just transform world postions using orthoProjM*viewM
