mosra / magnum

Lightweight and modular C++11 graphics middleware for games and data visualization
https://magnum.graphics/
Other
4.75k stars 439 forks source link

How to smooth imported mesh? #579

Closed zaichenhu closed 2 years ago

zaichenhu commented 2 years ago

I have imported a triangulated mesh using magnum scene importer, but it was shaded flat when rendering. if there is any api to solve this problem?

zaichenhu commented 2 years ago

change the compile flag to MeshTools::CompileFlag::GenerateSmoothNormals could work , sorry to disturb...

mosra commented 2 years ago

Yup, that's the flag :)

To answer fully -- smooth normal generation relies on the index buffer, so if the mesh is not indexed, you'll still get flat normals. To fix that, perform MeshTools::removeDuplicates() first, which will generate the index buffer.