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.