Jump to content

Flat v. smooth shading


anselm Hexicola
 Share

You are about to reply to a thread that has been inactive for 3662 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

   I have been trying to use both types of shading on adjacent faces of a model ...

... and I cannot get it looking right - looks even worse inworld than it does in Blender!

 

   Here are a couple of screenshots to illustrate my problem:-

 

   

Object mode view

 

Edit mode

 

   Although the 2 highlighted faces are on the same geometric plane (in fact, if I remember right, one was extruded from the other), I cannot get them to appear as continuous.

   I freely admit that my knowledge of shading (and for that matter 3D modelling in general) is very slight, but would welcome any advice and general explanations.

 

    Thanks in advance ...

 

   Btw, is there a way in Blender 2.68 to display the Shading info whilst in Edit mode? What I mean is ... maybe a menu setting that would tell you whether a face was shaded Flat or Smooth? It is easy to lose track of how one had shaded any particular face.

 

Link to comment
Share on other sites

That looks very much like a problem I run into from time to time. The bad news is that I haven't found a solution. There was a thread on this about a week ago but I can't find it now.

Assuming that all your vertexes are joined to one another (no way to pull apart the top from the bottom without moving the top for example) and that you have no double vertices, I am guessing that one of the vertices is pointing in the wrong direction.

When I did research on this last, there was no way (in Blender) to fix that. I would be thrilled if someone has a fix. They were working on it.


What "I" did after an hour or so of trying to fix it  -- until I reallzed what the issue was -- was start over. That was MUCH faster than my fixing attempts.

 

I will keep looking for that thread and if I find it I'll past it in here.  It IS very frustrating. No arguement there.

Link to comment
Share on other sites

curve.jpg

What's happening is a and b are forming a convex curve during smoothing but c and d are concave. To correct: I'd remove d and extend the end of b to where d ended. This will erase the transition between b and d you now have but it may not still look right because you're asking Blender to make some complex calculations at the abc corner. You may have to add a hidden plane to extend the end of a under c and separate smoothing groups here to get it right.

Link to comment
Share on other sites

Just a guess...: It could possibly be fixed by rotating the edge flow of the underlaying triangles. You could try this:

 

  • Select one of the 2 Quads
  • Triangulate the Quad
  • Mesh -> Edges -> Rotate Edge CW

Check if the problem goes away. If so, then keep the triangulated quad as it is so that upon export the rotated edge keeps as it is.

Link to comment
Share on other sites

There is always this kind of problem with complex corners like this. Others may have better solutions, Meanwhile....

I made a simple model to illustrate. The pictures are Matcap display to make the unwanted shading effects more obvious. This helps, as long as you look at it from plenty of angles. In both pictures, the top row is in edit mode with vertex normals turned on. The same objects are shown in the second row in Object mode, to remove the distraction of the edges. They are all smooth shaded throughout, but with some edges split*.

If you look at the first two models, you can see where the problem arises. In the first, all the internal edges are split, so that each quad is a separated mesh with its own unshared vertices. In that case, all the vertex normals are identical to the face normal. When two adjacent faces are coplanar, then you don't really need the split edge between them to get flat shading, because their face normals are already identical, and so will bec the vertex normal. You can see the different vertex normals coming out of the split vertices, and you will notice that they are all perpendicular to the faces of the quads they belong to (if a quad isn't flat, that's a different matter).

In the second model, none of the edges are split. Now each vertex has just one normal, which is the average of the
face normals of the faces using that vertex. Inside each triangle, the normal at any point is a linear intertpolation of the three vertex normals, giving the variation in shading across the triangle. Bacuse the triangles in a quad have only two shared normals, the difference in the third gives rise to the diagonal discontionuities in each quad. The normals are different at opposite edges of the quads, so the overall efeect is shading as if the quad was twisted.

The third model is the same as the second, except that the triangulation of each quad is along its other diagonal, as suggested by Gaia. This changes the direction of the triangular artefacts, and in some cases this may be sufficient, but in this model the vertex normals are still skewed so that the twisting effect is still there.

Im models 4 and 5, just the highlighted edges are split. In model 4, this leaves the right hand flap, equivalent to your b and c, are isolated and beacse their face normals are the same, so are all the vertex normals, and they are coplanar and flat. However, we may want smooth shding across the 45 degree crease, which we don't get with this edge split. In model 5, that edge is not split, so the shadinf along that edge is smooth. However, the vertex normal at the nearer two vertices along the crease is 22.5 degrees (half the 45 degrees from averaging), but at the third vertex. which is now unattached because of the split, is on free, so it is at 45 degrees. So there are still different vertex normals at the two ends of the second quad, and the twisting, giving the diagonal shading artefact, is still there in that quad.

The last model uses Leprekhaun's hidden plane extension. You can just see that the horizontal flap adjoining the
45 degree crease is now completed with another hidden quad. Now the third vertex along the crease has exactly the same two face nornals on either side of it as do the first two vertices. So the resulting vertex normals are all the same. The smooth shading along the crease is preserved, but now there is no twisting artefact.

nastycorner1.png

That's fine, as long as we don't want smooth shading between, say, the 45 degree face and the vertical face. That is more tricky. The left model in the second picture has yet another hidden plane, this time going vertically down from the first, with the normal pointing to the rear. This does make the three normals along the crease the same, so at first sight, it looks like we have achieved the effect. However, the normals between the 45 degree flap and the vertical quad are completely wrong, and after looking a bit longer, it is clear that the shading is all wrong, even though it is free of twisting artefacts.

Perhaps the only solution here is to resort to real geometry, by bevelling the 45 degree crease, This is shown on
the right of the second picture. The edges where the vertical and horizontal edges cut throght the bevel have to be split. Otherwise there are other horrible shading artefacts there. This works as wanted, but only at the cost of a lot of extra geometry.

nastycorner2.png

The ideal solution to this kind of situation would be the facility to edit the vertex normals directly, optionally overriding the automatic averaging of the face normals. This is something I think Gaia is trying to get added to Blender. That might allow much more elegant solutions to this kind of problem. It still won't be easy.

*This can be done with the edge split modifier, where it affects shading straight away, but doesn't actually split the vertices until the modifier is applied, or immediately by using Mesh->Edges->Split with the edges selected. It has exactly the same effecft as using flat shading. For SL, the uploader will do the necessary splitting for flat shaded faces.

 

Link to comment
Share on other sites

Thanks for all the detailed pictures. Always a help.

I had this happen (or something very similar) again today. Same scenario, edge split modifier and smoothing. That seems to work beautifully if it is the outside of a curve, but when it is an inside -- as in a arch -- it is NOT pretty (well I did get it to work once :D). In the end, now that I am remembering what the issue is, I turned the model back to flat, added other details and it works quite well.

 

It would be great if this wasn't an issue, but since Blender is free rather than thousands of dollars and works very well on so many things, I am not going to complain. Learning to work around obsticles is an art in itself.

 

 

Link to comment
Share on other sites

   Having studied your overview of the issue (and having noticed the name you gave your screenshots), I now think a better title for this thread would be "Twisted artefacts and nasty corners" ... anyway, I have learnt a great deal from everyone's posts - thanks everybody!

   I tried out several of the suggestions and DID improve my model's shading a bit; however, sometimes it felt like I was chasing my tail. Getting rid of an ugly effect in one area (whether by edge-splitting or altering geometry) would result in an infelicity elsewhere. I am inclined to agree with Chic - I should maybe accept that I will NOT be able to get what I want with this model, and I should probably draw it differently.

   Anyway, for what it's worth, here are 2 sets of screenshots showing my tweaking.

   First, using Gaia's Triangulate and RotateCW method ... (also Edge Split on the highlighted edges - the normals on vertices x and y are still not in harmony with their horizontal neighbours, if that makes sense ..)

              shading (Gaia) - Edit mode.png

 

              shading (Gaia) - Object mode.png

 

Second, I tried Leprekhaun's suggestion of combining faces b and d (as labelled in his post) ... though I didn't extend a, but did Edge Split the same highlighted edges.

              shading (Leprekhaun) - Edit mode.png

              shading (Leprekhaun) - Object mode.png

 

   What I think I myself have learnt from all this is:-

       1. The eventual triangulation of quads (whether in Blender shading or upload to SL) inevitably twists the normals.

           [edited 14th April - this NOT correct; Drongle explains in Message 12 of this thread.]

       2. The visual jarring of resultant  "artefacts" (that Drongle refers to) seems to be worse the greater the difference in relative length between any 2 adjacent faces. 

Link to comment
Share on other sites

Split Normals arrived in Blender today (ok, 15 minutes ago):

 

  • "Split Normals" is basically a replacement for the "Split edge modifier" that modifies the normals instead of adding extra geometry.
  • It is planned to also make the split normals modifiable.
  • Melding normals of adjacent objects is also planned to come within the next few months.

And to clarify: This was made by one of the main Blender developers. I only report the news here :matte-motes-grin:

Link to comment
Share on other sites

"The eventual triangulation of quads (whether in Blender shading or upload to SL) inevitably twists the normals."


I don't think it's the triangulation that does the twisting. If you look at these, you can see that the normals don't change at all when the triangulation changes. In particular, with the central normal in the two at the right of the second row, first there are three horizontal and four vertical triangles, then six horizontal and two vertical triangles. Nevertheless, the normal stays exactly the same. So it certainly isn't as simple as a straightforward averaging of the face normals (components) from each contacting triangle. Does anyone know the mathematics involved in making these vertex normals*? The triangulation does affects the details of the shading errors, because it changes which three normals are used for interpolating at any point, but the twist in the normals is independent of the triangulation.

I added the top right model to illustrate the effect of simple subdivision of the whole mesh, two levels here. This confines the shading errors to the tiny triangles right in the corner. With sufficient subdivision, they becone essentially invisible. I guess this is one of the reasons for the popularity of excessively high poly models, and the costs they incur.

 

nastycorner3.png


*spent a few hours googling this, which was quite interesting. The majority suggest weighting the averaging by the areas of the triangles using the vertex (sum of cross products of edges defining triangles, followed by normalisation). That isn't what's used in Blender, because the normals don't change with the areas (lowering the top of the vertical faces). Instead, it seems to be using weighting by the angles between the defining edges, which is consistent with the behaviour in Blender as far as I can see.  For anyone with mathematical bent, I found the article below which compares a variety of methods for calculating the vertex normals, including the two above (MWAAT and MWA). MWA, which Blender appears to be using, scored well in their more general tests, although it was not so good at highly regular sphere and torus models.

http://users.tricity.wsu.edu/~bobl/personal/mypubs/2003_vertnorm_tvc.pdf

Link to comment
Share on other sites

And that is why vertex normal editing can be such a resource saver:

VertNormals.PNG

Obviously a side view, on the top left a corner with added edgeloops, on the top right a 2-step bevel (or chamfer), on the lower left 1-step bevel with edited normals and on the lower right a 2-step bevel with edited normals.

You can see why the bevel won't result in a nice rounded, isolated corner. The (face) normals will start bending on the very left and very bottom. By editing the vertex normals, you can either save geometry (and get rid of the sharp geometrical corner), as shown on the left, or as shown on the right, a very convincing rounded geometrical corner with correct face normals.

For all the Blender users I hope this option will be available soon.

Link to comment
Share on other sites

I didn't read the article (did open it to find it too lenghty to my taste :) ) and I don't know if this is the complete answer, but:

vertnormcalc.png

It looks like the face normal and angle are taken into the calculation. If the angle in a tri is 90° (left picture), it will have the same affect as two tris with a 45° (right picture). You could imagine variations with even bigger and smaller angles, but as long as the shape of the object stays the same, the vertex normal in the center won't change.

Link to comment
Share on other sites

Yes. You are right, of course. As long as you can keep pointy corners, that is much better. The effect is the same as massive subdivision followed by redundant loop removal, as in this picture. The triangle counts for this, and a final optimisation, are shown there. That's probably the best solution for the OP's case too. (Gaps kept wide so you can see them.)

nastycorner4.png

Link to comment
Share on other sites

And to make it complete:

boxchamf.png

On the left the object with edge loops added, 360 tris. On the right the object with a single chamfer/bevel and corrected vertex normals, if you ask me it looks a lot better since you don't look at strongly rotated normals (the dark lines). The triangle count is 80.

Link to comment
Share on other sites

The sharper the edges, the less it will be noticable, (and I unintentionally cheated a bit, the edges on the right model were a bit sharper than on the other) but the difference in triangle count isn't exactly marginal. Your "final" object could be slightly further optimised without changing the lighting I think, but will always have a lot more triangles.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3662 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...