Download

Smoother Vertex normals in Material?

Hi All,

I am using facing ratio in my shader calculated from VertexNormalWS and CameraVector but since my mesh is fairly low poly I end up with strong faceting.

Is there a good way to get those normals more smoothly interpolated?

I am considering using a normal map but I would love to avoid that for performance reasons. (I imagine it is slower to render)

EDIT: I am just trying PixelNormalWS with a normal map piped into the main shader block, but it the map does not seem to be used in the calculation!?

EDIT2: It looks as if the Morph I have on the mesh, which is stretching it out, might be a cause. Is there anything one needs to do with morph targets to get correct normals?

EDIT3: Hmm…the mesh is a simple cone for a spotlight fog effect and I am having problems even in Maya to get smoothly shaded surface.

Cheers
Fred

Does the mesh itself have smoothing? For example, if you apply another material, does it look smooth?

Yep the mesh have smoothing I have tried that a bunch of times.
It seems it might be impossible to both have low poly count and a smooth mesh when making a simple cone.
The problem is that when you triangulate you end up with a very thin triangle on each quad near one edge. And this makes the engine shade it sharply there, as there’s two poly edges just next to each other.

See these images from maya,

So my next plan was to bake out a normal map after all but even there I don’t seem to get it to work :stuck_out_tongue:
Using the same low poly mesh to bake from and trying both using hard and soft edges none of it makes the cone look round and smooth in UE.
I have tried baking in Maya and in xNormal. I have tried flipping the flipping the green channel, and not.
(it actually seems to shade nice and round in Maya’s viewport 2.0, but I can’t get it in UE)

I never thought I’d sit a whole day just to make a cone!

Does anyone know how to make smooth cones? :slight_smile:

Cheers
Fred

I actually just somehow got that normal map to almost work in Unreal.
It is just not good enough for what I need because as I apply the fresnel/facing ratio it seems to emphasize the small discontinuities and they show up again as sharp lines.
Hmm…what next…?

UE simple shader with the normal map:

UE shader using fresnel pow’ed up a bit,

Sadly, the only solution I can come up with is to use more geometry/edge loops. This is one of those worst case situations for vertex normals. A synced normal map will hide most of the issues, but normal maps still have to work through compression and have enough resolution to hide harsh gradients, and mipping will make those issues worse. So your options are A. Use lot more geometry or B. Use some more geometry + normal maps.

Ok thanks…I will try a 50/50 approach first and see what I get…

Actually the optimal solution would be to just have one vertex at the point and unwrapping it as a circle from a top down view.

Hey that looks very promising!

Great idea! I’m off to try…

EDIT: Weyheeyy!! Nice one Zac! That works really well.
I tried a one vert tip cone before but I didn’t think of UV’ing from the top so it looked bad then.
I’m going to add this to my LinkedIn page now, “New Skill - can make a cone.”

Thanks for your time.

Cheers
Fred

The quality of the normals on an object are determined by vertices. You can use a normal map to compensate, which will incur a bit of a performance cost in the PIXEL shader. Adding more vertices will add a performance cost to the VERTEX shader. These two run side by side to render everything you see. It would actually be the most optimal to use more vertices to get an acceptable representation, but if you want absolute perfection, the texture method will be more accurate than vertices. Performance is a constant tradeoff between pixels and vertices. It’s up to you to figure out what you’re going to save, and what you’re going to use.

what if when you have a complex object

If you apply a top-down UV map with the top in center, this can work, with two caveats:

  1. You MUST generate a normal map – if you don’t, the cone area will look more like a bullet (because the normal of the tip points straight up.)
  2. Right around the tip, there will always be a discontinuity. A user zooming in on the tip will see a pixelated/warped/discontinuous normal.

A more “correct” way to do this is to take a cylinder, and then scale the vertices at the top to zero so they all come together – but DO NOT WELD!!!
And even so, half of the triangles of those walls will have zero area, yet need to be there, and need to have normals that are identical.
This is actually very hard to get right in a manual modeling program, so you might consider writing some script to generate the necessary geometry.

Cone points are actually even worse of a special case than spheres. (You know about the “hairy ball theorem,” right?) Spheres have a continuous surface, and “just” have the problem that there is no perfect way to UV map them. Cones actually have a discontinuity in the surface at the top, as well as in the UV mapping.

Also, if you put “can model a cone” on your resume, expect to get questions about these discontinuities, why they happen, and what to do about them whenever you interview :slight_smile: