# GM:S 1.4 How do Normal Vectors affect lighting?

Discussion in 'Programming' started by DekuNut, Dec 10, 2018.

1. ### DekuNutMember

Joined:
Jun 29, 2016
Posts:
40
Code:
```d3d_model_vertex_normal_texture(m, x, y, z, nx, ny, nz, xtex, ytex);
```
Could someone help me understand how normal vectors affect lighting on my model? I've looked through a couple tutorials and forum discussions, and they've told me how to calculate the normals, but not exactly what they will do. I understand if all my vectors are pointing up, my model will look flat. I don't know how adjusting them will affect the lighting on the model though.

2. ### icuurd12b42TMC FounderGMC Elder

Joined:
Apr 22, 2016
Posts:
1,840
each point has a vertex normal. they point in the direction, perpendicular to the plane of the facet they are the corner of... in its most simple implementation...

this tells the direction the light reflects, roughly speaking.

each point of the triangle can have it's own vector, as opposed to the entire triangle defining the reflection vector, which allows smoothing... or rounding things by smoothing the lighting..., like each vertex on the cannon has its lighting normals point outward at an angle matching round cylinder for example

Last edited: Dec 10, 2018
Yal and DekuNut like this.
3. ### DekuNutMember

Joined:
Jun 29, 2016
Posts:
40
Wow, thanks for the quick reply and those images were perfect. I think I understand how it works now.

4. ### YalGMC MemerGMC Elder

Joined:
Jun 20, 2016
Posts:
4,214
Generally speaking, the normal vector is the "up" direction of the plane the triangle is in. It's useful for lighting, but it's also important in collisions. For instance, the normal vector of a wall is close to horizontal, the normal vector of a floor points upwards, and the normal vector of a ceiling points downwards - so checking the z component of the normal vector can tell you how to collide with a triangle.