Legacy GM How do Normal Vectors affect lighting?

D

DekuNut

Guest
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.
 
I

icuurd12b42

Guest
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...

upload_2018-12-10_2-40-48.png

this tells the direction the light reflects, roughly speaking.

upload_2018-12-10_2-46-3.png

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

upload_2018-12-10_2-48-36.png
 
Last edited by a moderator:
D

DekuNut

Guest
Wow, thanks for the quick reply and those images were perfect. I think I understand how it works now.
 

Yal

šŸ§ *penguin noises*
GMC Elder
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.
 
Top