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

CC BY-SA 4.0
2023-03-06T15:36:28.670Z
When creating an orthogonal 3D space, you need to specify two vectors that are linearly independent (technically there is a hidden assumption here as well). If you ask someone to create a 3D coordinate system where the only information is that the z-direction is your light direction, there is an infinite amount of answers.
Mathis
CC BY-SA 4.0
2023-03-06T17:55:42.277Z
Actually I read your post to quickly and agree with what it says I deleted the comment. (I agree there is an infinite number of possible answers I was just giving an example of one)
pmw1234
CC BY-SA 4.0
2023-03-04T16:17:36.393Z
2023-03-04T16:17:36.393Z
Mathis
<p>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:</p>
<pre><code>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);
</code></pre>
<p>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.</p>

CC BY-SA 4.0
2023-02-25T22:43:57.990Z
There is absolutely no reason why a light source can't be axis aligned. Looking directly down any axis.
pmw1234
CC BY-SA 4.0
2023-02-27T02:47:33.433Z
Exacly, but the shadow map is all white when i put the light in that position
Luigi Pocay
CC BY-SA 4.0
2023-02-27T10:43:18.623Z
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.
pmw1234
<webgl><shadow-mapping>
Doubt about Light space transform (Shadow map)
Luigi Pocay
# Doubt about Light space transform (Shadow map)

(Asked by: username_0 on 2023-02-23)

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.

**Tags:** webgl, shadow-mapping

> **Comments:**
> **username_1**: There is absolutely no reason why a light source can't be axis aligned. Looking directly down any axis.  
> **username_0**: Exacly, but the shadow map is all white when i put the light in that position  
> **username_1**: 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.  

---

## 1 answers

### Answer by username_2 on 2023-03-04. Score: -1

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.

> **Comments:**
> **username_2**: When creating an orthogonal 3D space, you need to specify two vectors that are linearly independent (technically there is a hidden assumption here as well). If you ask someone to create a 3D coordinate system where the only information is that the z-direction is your light direction, there is an infinite amount of answers.  
> **username_1**: Actually I read your post to quickly and agree with what it says I deleted the comment. (I agree there is an infinite number of possible answers I was just giving an example of one)  

---

