Normals
Normals
I`m trying to figure out how normals work. I`m using a custom scene node and the normal values in the c s n tutorial don`t make sense to me
Not sure what you need to know. A normal is a direction vector (an arrow showing you the direction) which is perpendicular to a surface. For example on the floor it would be straight up (or down). Don't confuse it with normalized vectors which is something different and just means that a vector as a length of exactly 1. You can calculate a normal if you have at least 2 edges on an area which are not parallel using the so called cross-product (just a formula). Maybe a little confusing can be vertex normals, because being at the corners between polygons they don't really have a surface to which they can be perpendicular. So usually people calculate for example the average of the normals of all adjacent polygons.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
In computer graphics normals are used to calculate light on vertex. If normal and light vector are exactly opposite, maximum light is thrown on vertex ...vertex is facing light source. Bigger the angle between two, less light is on vertex and if light vector and normal are the same, no light is on vertex ...its facing opposite direction from incoming light.
So basically normal of vertex is used to express direction vertex is facing. Normals should be exactly one unit long.
So basically normal of vertex is used to express direction vertex is facing. Normals should be exactly one unit long.
hybrid wrote:For a correct cube implementation, you need all three normals at the corners, for each of the three faces meeting at that corner.
Well, that means 24 vertices for a cube, right?arras wrote:That is because there are 3 vertices per each corner in this case. otherwise cube would not have sharp edges (sharp lighten).
Then why does createCubeMesh only use 12?
Also, what about shared normals:
Wouldn't 8 vertices suffice like that?
Never take advice from someone who likes to give advice, so take my advice and don't take it.
It would, if you don't have textures and don't want correct lighting.Wouldn't 8 vertices suffice like that?
createCubeMesh has 12 vertices because although it's normals are like in your pic (resulting in trying to light the cube like a sphere instead of a cube), you can't have just 8 vertices without some of the faces being textured wrong.
24 vertices allows you to have correct lighting and correct texturing.