- Home /
Trying to create a hard edged procedural torus mesh
I'm using the procedural mesh script on the wiki http://wiki.unity3d.com/index.php/ProceduralPrimitives
to generate a torus in code. However I want to make it with hard edges. I can do with pre made geometry by changing the soothing angle, but I am struggling to get it working on the torus.
Answer by tanoshimi · Dec 28, 2014 at 08:50 AM
Normals are interpolated across faces. If a vertex is shared between two or more adjacent faces, you'll get a "smoothed" surface as its normal is interpolated across either face. To achieve a "flat shaded" effect with hard edges, you have to duplicate vertices in the mesh so that each face is made from 3 vertices that share the same "face normal", and interpolation has no effect. You might end up with several vertices at the same x,y,z but having different normald (this is what setting smoothing angle to 0 does - notice how it increases the vertex count of the mesh)
Hi tanoshimi, thanks for the answer. I understand the logic of what you say, but I have to confess when it comes to implementing that in the torus code on the link above I am at a complete loss!
[ meta: Please don't post comments as answers. And how did you get 1800 silver medals on your profile?!]
Well, I'd suggest you start by working through a simpler example - make a hard edged procedural cube, for example, to get the hang of what's required.
[meta : there was a bug a while ago that gave everybody lots of medals. @meat5000 can provide more info]
Cannot find the answer that included this link : http://gamedevelopment.tutsplus.com/articles/go-beyond-retro-pixel-art-with-flat-shaded-3d-in-unity--gamedev-12259
Answer by BergOnTheJob · Jul 10, 2020 at 04:41 PM
If anyone is looking, this tool can harden edges on a torus or any other shape. https://assetstore.unity.com/packages/slug/166155
Happy Modeling in Unity! =)