<p>Typically, you calculate lighting in either world-space or view-space (or camera-space). The benefit to calculating it in camera-space is the increased precision, although this may involve introduce additional math operations in shaders depending on your setup. So it wouldn't be in screenspace, or you would need to reconstruct the positions (which could happen in deferred shading depending on your G-buffer layout).</p>

<p>I assume you are talking about a punctual light type (such as a point light). If so, if your light position equals your camera position, then the view and light angles are the same, which can be factored out in the BRDF that you use, so you save a dot product.</p>

CC BY-SA 3.0
2018-01-07T04:24:10.463Z
2018-01-07T04:55:30.677Z
2018-01-07T04:55:30.677Z
aces
<p>I'm currently making a small 3D renderer and I got stuck in Phong shading.</p>
<p>My questions are:</p>
<ol>
<li><p>Into which space should the light coordinate be converted?</p>
<p>I have my light position at world coordinates (0,0,0). I'd like to calculate &quot;phong shading&quot; after converting all the vertices to screen space (viewport).
So Should I convert the light position to screen space too?</p>
</li>
<li><p>Is there a faster way to calculate Phong shading with normal interpolation if the camera's position equals the light's position?</p>
</li>
</ol>

<rasterizer><shading>
Light coordinate in Phong shading and Normal interpolation
hans-1795
# Light coordinate in Phong shading and Normal interpolation

(Asked by: username_0 on 2018-01-07)

I'm currently making a small 3D renderer and I got stuck in Phong shading.

My questions are:

1. Into which space should the light coordinate be converted?

   I have my light position at world coordinates (0,0,0). I'd like to calculate "phong shading" after converting all the vertices to screen space (viewport).
   So Should I convert the light position to screen space too?
2. Is there a faster way to calculate Phong shading with normal interpolation if the camera's position equals the light's position?

**Tags:** rasterizer, shading


---

## 1 answers

### Answer by username_1 on 2018-01-07. Score: 1

Typically, you calculate lighting in either world-space or view-space (or camera-space). The benefit to calculating it in camera-space is the increased precision, although this may involve introduce additional math operations in shaders depending on your setup. So it wouldn't be in screenspace, or you would need to reconstruct the positions (which could happen in deferred shading depending on your G-buffer layout).

I assume you are talking about a punctual light type (such as a point light). If so, if your light position equals your camera position, then the view and light angles are the same, which can be factored out in the BRDF that you use, so you save a dot product.


---

