at this moment I am learning to do shadow mapping in webgl2.0, i was able to generate my first shadows in my 3D scene but I have a couple of doubts to clarify. This is the way im calculating my light space matrix:

const lightPos = vec3.create();
vec3.set(lightPos, 0, 6, 1);
const nearPlane = 1, farPlane = 20;
const projection = mat4.create();
mat4.ortho(projection, -10, 10, -10, 10, nearPlane, farPlane);
const lightView = mat4.create();
const center = vec3.create();
const up = vec3.create();
vec3.set(center, 0, 0, 0);
vec3.set(up, 0, 1, 0);
mat4.lookAt(lightView, lightPos, center, up);
const result = mat4.create();
mat4.mul(result, projection, lightView);


In this way the shadow map is rendered correctly, but the question is the following, if the position of my light is vec3.set(lightPos, 0, 6, 0), the shadow does not render, why is this happening? Theoretically I am positioning the light in the middle, directly 6 units above the scene, why is this happening? As far as I understood, 2 of the properties of the position vector of the light cannot be 0, but why?. I hope I explained myself well, the light is a directional light and the library that im using for the math is gl-matrix, if you need anything else let me know, thanks in advance.

• There is absolutely no reason why a light source can't be axis aligned. Looking directly down any axis. Feb 25, 2023 at 22:43
• Exacly, but the shadow map is all white when i put the light in that position Feb 27, 2023 at 2:47
• So 2 of the position vectors of the light can be zero hence looking directly down an axis. In light space it tends to be better to have an axis aligned light. Feb 27, 2023 at 10:43

I might be wrong here, but the "up" vector must be linearly independent of the light direction in order to create a proper 3-dimensional light space. When the light position is $$(0,6,0)$$, the light direction becomes $$(0,-6,0)$$ which is parallell with the "up" vector $$(0,1,0)$$. Note that the cross-product between two parallell vectors maps to the zero vector, so the resulting light space becomes 1 dimensional.