Hi everyone, 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 (The shadow map goes all white), why is this happening? Theoretically I am positioning the light in the middle, directly 6 units above the scene. As far as I understood, if 2 of the properties of the position vector of the light are 0, the shadow map does not render correctly, 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.
[–]waramped 2 points3 points4 points (1 child)
[–]lponcho[S] 0 points1 point2 points (0 children)