Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Unsmooth generated mesh in unity

I'm trying to make a low poly terrain in unity, but for some weird reason it keeps smoothing it out. I tried removing Recalculate Normals, but that did not seem to help (also it wrecked the lighting). Please don't post any links to assets on the assets store.

Also using unity 2020.2.1f1

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The idea behind low poly mesh is to duplicate vertices to achieve sharp edges. When we normally create a mesh, it has N vertices. And when you recalculate normals, Unity generates exactly N normals. That means that for each angle in your mesh there is only one normal vector, which 3D engines try to smooth. So supposing a simplified 2D example, it looks something like this:

Smooth edge

Your goal instead is to duplicate vertex for each triangle, that this vertex belongs, so that each edge would be disjoint, and that would cause Unity to generate separate normals for each edge and sharp the angle. Like this:

Sharp edge

Unfortunately, there is no way to create multiple normals for one vertex, that's because you'd have to duplicate them. So for example you want to create a mesh with two triangles with a sharp edge. In code it would be something similar to this:

var mesh = new Mesh();

// Basically amount of your vertices is equal to amount of indices.
var vertices = new Vector3[6];
var triangles = new int[] { 0, 1, 2, 3, 4, 5 };

// Define first triangle.
vertices[0] = new Vector3(1, 0, 0);
vertices[1] = new Vector3(0, -1, 0);
vertices[2] = new Vector3(0, 0, 0);

// Define second triangle
vertices[3] = vertices[2];    // Duplicating vertex #2.
vertices[4] = vertices[1];    // Duplicating vertex #1.
vertices[5] = new Vector3(-1, 0, 1);

mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.RecalculateNormals();

Also check this article, it describes nicely behaviour of shading in 3D engines depending on shared and separated vertices: Tutorial 9: VBO Indexing

Update: As mentioned in the comments you can also try to use Flat shading model. But as far as I know, it might be not supported on some platforms.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!