How to manipulate Normals in Blender?

Started by
7 comments, last by ShadowFlar3 10 years, 4 months ago

Hi there,

I am following this tutorial. Here he loads on an .obj file and converts it into a model.txt which is later read and rendered. He created his own .obj in Maya. Now I tried to do the same with blender. I got it all the faces, normals and vertices. But I guess that there is something wrong with normals. Rastertek writes:

This particular .OBJ model file represents a 3D cube. It has 8 vertices, 24 texture coordinates and normal vectors, and 6 sides made up of 12 faces in total.

It says 24 normals. Does that mean he has his normal on the vertices? Because the model I created has only 12 normals. Plus they look kinda strange. They are not placed on the vertices but on faces. I had to create some extra faces by always selecting three vertices and pressing F.

How can I make blender save a normal for every vertex?

Advertisement

I think you are looking for "flat" versus "smooth" shading. Also, the edge split modifier would likely give you this result.



First off, let's establish that there are 2 kinds of normals: face normals are placed in the middle of a face and vertex normals are placed at vertices.

For a cube object you have 8 vertices and 6 faces. You can see the vertex and face count for your object in Blender top row and that equals to how many normals of each you should have. If you go to 3D view, edit mode, and bring out the Properties panel (N key) you can enable vertex and face normal display for your object in the Mesh Display section. There are 8 vertex normals and they are pointing away from the cube center, in vector format they are [x,y,z] where all of them are 1 or -1.

I'm not an expert on how this information is stored in various container formats but normals are traditionally calculated information. Blender doesn't even let you modify them manually, as far as I know because it serves little point besides screwing up shading totally. How you should adjust normals is by changing the topology of your model, flipping faces around and adjusting smooth and sharp corners. How each format saves normals might vary as well as how different software display them.

If the tutorial in question says you need 24 normals, that probably means you need to "explode" the cube into 6 non-connected polygons. You can do this in Blender by tabbing into edit mode for the cube, choosing edge selection, selecting all, and using Mesh -> Edges -> Edge Split. That way you get 4*6 = 24 vertices and you should now have 24 vertex normals as well. Looking at the vertex normals now, you have 3 normals at each corner because they are now 3 separate vertices. The vertex normal that was previously [1,1,1] is now 3 normals [1,0,0], [0,1,0] and [0,0,1] so it's been divided into components for each of the 3 faces.

Hello.

The way smoothing groups make faces look smooth or sharp is because the software keeps vertices duplicated internally.

A single vertex that belongs several to faces with sharp corners is duplicated per sharp face. The program does not show you these duplicates or even give you access to them.

if you're trying to export a mesh from 3DS Max, for example, and you want to support smoothing groups, you will have to manually break a vertex and weld the clones that belong to faces with the same smoothing group, and leave separate the clones that belong to faces with different smoothing groups (you can't access the internal vertex clones, but you can retrieve each face's smoothing group).

If you want a cube to have sharp corners, you will have each vertex being duplicated per sharp face. Since each vertex in a cube belongs to 3 faces, you have (8 vertices being split in 3) = 24 total vertices.

Then each face's normal is calculated based on the positions of the vertices that form it. The vertex normals are then calculated by averaging the normals of all faces the vertex belongs to.

With this, in a welded cube with only 8 vertices the vertex normals point in a direction from the center of the cube to each vertex (or in other words, it's the averaged normals of the 3 faces the vertex belongs to, which results in it pointing diagonally outside), and in the broken cube with the 24 separate vertices, the vertex normals are those of the face that the vertex belong to (it's also an average, but of only one value, so it results in that value entirely).

Regarding the editing of normals, Blender unfortunately doesn't support that, although there were some requests for this feature. It's an interesting tool for making game art assets.

If you can alter the vertex normals then you basically control how lighting affects the object without having to resort to multitexturing. The reason you would want that is that, in some cases, it may actually look better than if the normals were just taken from the faces like they usually are.

The best usage for this is with foliage, but there are other applications such as environmental art.

Read more about it: http://wiki.polycount.net/VertexNormal#Foliage_Shading

The difference is mostly this.

Regarding a foliage prop formed by 3 quads:

gal1.gif

With normal editing, you can point the normals to a more convenient direction such as outside (from the center of the object to each vertex), and it'll make the foliage look more volumetric and hide the intersections:

gal2.gif

If the tutorial in question says you need 24 normals, that probably means you need to "explode" the cube into 6 non-connected polygons. You can do this in Blender by tabbing into edit mode for the cube, choosing edge selection, selecting all, and using Mesh -> Edges -> Edge Split. That way you get 4*6 = 24 vertices and you should now have 24 vertex normals as well. Looking at the vertex normals now, you have 3 normals at each corner because they are now 3 separate vertices. The vertex normal that was previously [1,1,1] is now 3 normals [1,0,0], [0,1,0] and [0,0,1] so it's been divided into components for each of the 3 faces.

Your solution seems to work. This is how I do it.

  1. Take the predefined Cube which has only 6 faces, 8 vertices and 8 normals at first.
  2. Now I go to Mesh->Faces->Triangulate Faces. This is because I need the faces to be triangles.
  3. Now Mesh->Edges(with all edges selected)->Edge Split

Well this actually does the trick. Now I have 12 faces and normals for each vertex which look right to me. The problem is, in the entire process somehow more vertices were generated. I end up with 36 vertices. I can't see them. Tried to go to Mesh->Vetrtices->Remove Duplicates. But this deletes the normals and even the edges I created with triangulation.

Yes, if you want more normals, you have to have vertices to match them. Each face has it's own set of vertices. In some file formats like OBJ, since the positions are the same, it won't duplicate them in the file, but when drawing it will indeed duplicate them, but with different normals. So what you are getting is perfectly normal, as the edge split is taking those faces and splitting them up. If you remove duplicates like that(after applying the edge split modifier) you basically cancel the results of the modifier, and each vertex gets shared onto 3 faces, but then you only one normal, which is not what you want in this case. Also, there is no reason to apply the edge split modifier in most cases, rather you just leave it on the object. Upon export, it applies the modifier for you, so you don't have to do it, making it easier to model things, for when you want more than just a cube.



The problem is, in the entire process somehow more vertices were generated. I end up with 36 vertices. I can't see them. Tried to go to Mesh->Vetrtices->Remove Duplicates. But this deletes the normals and even the edges I created with triangulation.

Remember that you will always have as many face normals as you have faces and as many vertex normals as you have vertices. The vertices are on top of each other so it's hard to see them.

When you triangulate you split each quad face in 2. You'll have twice as many faces and twice as many face normals. For vertices if your cube faces are welded together you still have 8 vertex normals but if the faces are triangulated before edge split you'll have 6 vertices per a quad you triangulated so you'll have 6*6 = 36 vertices.

Looking at this:

8 vertices, 24 texture coordinates and normal vectors, and 6 sides made up of 12 faces in total.

You must first make a cube with separated faces and then triangulate it. In other words the two triangles that make up each side of the cube must be welded together.

How to build this in Blender:

1) Add a cube if you don't already have one

2) Go to edit mode (TAB)

3) Mesh -> Edges -> Edge Split (CTRL+E)

4) Triangulate faces (CTRL+T)

You can now see in the top info row: Verts:24/24 | Edges:30/30 | Faces:12/12 | Tris: 12 and the model should be like you need in the tutorial.

I think the tutorial might have served more as an introduction to concept of vertices, edges, faces, normals in this case :)

How to build this in Blender:

1) Add a cube if you don't already have one

2) Go to edit mode (TAB)

3) Mesh -> Edges -> Edge Split (CTRL+E)

4) Triangulate faces (CTRL+T)

You can now see in the top info row: Verts:24/24 | Edges:30/30 | Faces:12/12 | Tris: 12 and the model should be like you need in the tutorial.

I think the tutorial might have served more as an introduction to concept of vertices, edges, faces, normals in this case smile.png

Hey there this actually worked! Thanks for that. Everything works fine. One important thing to mention here is, one should first apply textures and triangulate and edgesplit later. Otherwise UVs seem to screw up.

Thanks again

Well, the specific thing you needed for the tutorial is not actually how you should model game assets in Blender. Usually you don't triangulate at all because in most cases the engine handles quad models triangulating them as it needs. You also keep the edge split as modifier for sharp/smooth edges and as you export to .fbx the parser just writes smoothing groups and vertex normals based on them.

This topic is closed to new replies.

Advertisement