<p>By lighting in object space, sure, you could avoid transforming the normals into world space. However, you'd have to transform the light positions/vectors into the object's space. Also, if you want any view-dependent shading such as specular, you would have to transform the camera position into object space as well, to calculate view vectors.</p>

<p>Now, all of this can be done straightforwardly using the inverse of the object's world matrix. The inverse world matrix will include the inverse of the object's scale (as well as correctly accounting for the inverse of its rotation and translation), so it will transform the light &amp; camera positions to the appropriate points in the scaled coordinate system. Directional lights don't have a position, but you can transform their direction vector by the inverse world matrix to account for rotation and scale. All of this is fine so far.</p>

<p>However, you will then run into trouble when doing lighting calculations like N·L or N·V. For exactly the same reason that normals don't transform correctly under non-uniform scaling without using a special normal matrix, these dot products will not come out with the same result when done in a non-uniformly scaled object space as compared to world space. Namely, non-uniform scaling distorts angles. So, all your lighting calculations and BRDFs that depend on angles are going to be messed up.</p>

<p>While there <em>are</em> ways one could correct this problem by using additional matrices when calculating dot products... it's generally easier and faster to do lighting in world space (or view space). In any case, transforming the normals to world space is a pretty trivial amount of math by modern GPU standards, especially as it only needs to be done per vertex.</p>

CC BY-SA 4.0
2019-09-05T17:07:50.047Z
2019-09-07T18:47:17.247Z
2019-09-07T18:47:17.247Z
Nathan Reed
<p>If you compute the lighting in object space, before you scale the object then you will get false lighting. Imagine a small cube being lit by a single point light representing a light bulb. Now, scale that cube up to the size of a building. The lighting will have been calculated already, and now the entire building is being lit by a single light bulb. </p>

CC BY-SA 4.0
2019-09-04T20:41:05.087Z
2019-09-04T20:41:05.087Z
Gabriel Rohweder
<p>As a quick reminder, <a href="http://www.lighthouse3d.com/tutorials/glsl-12-tutorial/the-normal-matrix/" rel="nofollow noreferrer">here</a> is what normal matrix is and why do we need it.</p>

<p>Now the question - if I take the light position and transform it into an object space than I don't need the normal matrix at all and actually it will save me a good amount of calculations (don't need to multiply a normal by the matrix). By I can't draw a mental picture of how this could work for a scaled object, what does it mean to transform a point (light position) into a scaled object space? And what about a directional light where I have no position at all?</p>

<lighting><matrix>
Do I need a normal matrix if I calculate lighting in an objects space?
nikitablack
# Do I need a normal matrix if I calculate lighting in an objects space?

(Asked by: username_0 on 2019-08-23)

As a quick reminder, [here](http://www.lighthouse3d.com/tutorials/glsl-12-tutorial/the-normal-matrix/) is what normal matrix is and why do we need it.

Now the question - if I take the light position and transform it into an object space than I don't need the normal matrix at all and actually it will save me a good amount of calculations (don't need to multiply a normal by the matrix). By I can't draw a mental picture of how this could work for a scaled object, what does it mean to transform a point (light position) into a scaled object space? And what about a directional light where I have no position at all?

**Tags:** lighting, matrix


---

## 2 answers

### Answer by username_1 on 2019-09-05. Score: 3 | Accepted answer

By lighting in object space, sure, you could avoid transforming the normals into world space. However, you'd have to transform the light positions/vectors into the object's space. Also, if you want any view-dependent shading such as specular, you would have to transform the camera position into object space as well, to calculate view vectors.

Now, all of this can be done straightforwardly using the inverse of the object's world matrix. The inverse world matrix will include the inverse of the object's scale (as well as correctly accounting for the inverse of its rotation and translation), so it will transform the light & camera positions to the appropriate points in the scaled coordinate system. Directional lights don't have a position, but you can transform their direction vector by the inverse world matrix to account for rotation and scale. All of this is fine so far.

However, you will then run into trouble when doing lighting calculations like N·L or N·V. For exactly the same reason that normals don't transform correctly under non-uniform scaling without using a special normal matrix, these dot products will not come out with the same result when done in a non-uniformly scaled object space as compared to world space. Namely, non-uniform scaling distorts angles. So, all your lighting calculations and BRDFs that depend on angles are going to be messed up.

While there *are* ways one could correct this problem by using additional matrices when calculating dot products... it's generally easier and faster to do lighting in world space (or view space). In any case, transforming the normals to world space is a pretty trivial amount of math by modern GPU standards, especially as it only needs to be done per vertex.


---

### Answer by username_2 on 2019-09-04. Score: 1

If you compute the lighting in object space, before you scale the object then you will get false lighting. Imagine a small cube being lit by a single point light representing a light bulb. Now, scale that cube up to the size of a building. The lighting will have been calculated already, and now the entire building is being lit by a single light bulb.


---

